01 > ȸҰ

 
작성일 : 16-11-05 09:40
SPOT REV 3.3 OLED & Rotary Encoder & 스폿 hex file ,회로도 ,소스코드
 글쓴이 : 이로직…
조회 : 12,884  
   SPOT_OLED_CTRL.hex (96.3K) [30] DATE : 2016-11-05 09:40:16
   SPOT_OLED_CTRL_3_2.hex (96.4K) [5] DATE : 2016-11-24 14:28:43
   Flash_loader+%281%29.zip (9.4M) [10] DATE : 2017-01-08 18:14:45
   spot_rotary_ctrl1207.zip (4.0M) [13] DATE : 2016-12-16 11:02:08
   spot_ctrl_rev_3_1.pdf (92.2K) [14] DATE : 2016-12-20 11:39:17
   spot_encoder_board.pdf (47.1K) [9] DATE : 2016-12-20 11:39:17
   SPOT_AUTO_DELAY_CTRL.hex (98.7K) [19] DATE : 2016-12-28 09:48:16
   Spot_controller_manual_v3_1.pdf (2.3M) [31] DATE : 2017-01-08 18:14:21
SPOT REV 3.0 OLED & Rotary Encoder 지원 Main Program hex file , 회로도
<버전 변경사항>
rev 3.1 : OLED 추가 버전
rev 3.2 : 스폿 간격 디폴트 18에서 변경 가능으로 수정 (full 소스 코드 제공) IAR 6.5이상 지원됨
rev 3.3: Auto Spot 추가 : 회로에 1차,2차 코일 연결후 2차 코일 전압이 1.2V 이상에서만 메뉴가 변경됨
자동스폿 : 키입력에 따라서 delay time 조절 ( 0.7, 0.8, 0.9,1.0초 ) file 이름: spot_auto_delay_ctrl.hex



#include
#include "includes.h"

#define CHAR_LCD 0

#if CHAR_LCD
#define LCD_Write_string(x,y, s) charLCD_Write_string(x,y, s)
#define LCD_Write(x,y, s) charLCD_Write(x,y, s)
#define LCD_Clear() charLCD_Clear()

#define ROW1 0x80 //DDRAM address : 0x00 -> 0x80+0x00
#define ROW2 0xC0 //DDRAM address : 0x40 -> 0x80+0x40
#define ROW3 0x94 //DDRAM address : 0x14 -> 0x80+0x14
#define ROW4 0xD4 //DDRAM address : 0x54 -> 0x80+0x54

#else


#define LCD_Write_string(x,y, s) gLCD_Write_string(x,y, s)
#define LCD_Write(x,y, s) gLCD_Write(x,y, s)
#define LCD_Clear() gLCD_Clear()

#define ROW1 0x00
#define ROW2 0x02
#define ROW3 0x04
#define ROW4 0x06


#endif

#define RCC_PLL_MCO ((u32)(0x04<<24))
#define RCC_PLL_XTPRE ((u32)(0x01<<17))

#define RCC_CFGR2_REG (*(volatile u32*)(0x4002102C))

#define ADC_PORT 10

#define I2C_SPEED 50000
#define I2C1_SSD1306_SLAVE_ADDRESS8 0x78 // 8 bit slave address (write)
#define I2C_TIMEOUT 100000



unsigned long ulClockMS = 0;
RCC_ClocksTypeDef g_RCC_ClocksStatus;

extern BUFFER_TBL gps_buff;
extern uint8_t global_display_buffer[(128*64)/8];
extern int rotary_lock ;
extern int rotary_key_value ;

Int32U CriticalSecCntr;

void Button_Test(void);
void LED_Test(void);
void Lcd_Test(void);
void buzzer_test(void);
void gps_test(void);
void tenkey_test(void);
void adc_test(void);
void sht11_test(void);

void spot_menu_display(void);

extern int ssd1306_i2c_draw_buffer(I2C_TypeDef *I2Cx, uint8_t slave_address, uint8_t *buffer_pointer);

void * function[][2]=
{
{(void *)LED_Test, "LED Test "},
{(void *)Button_Test, "Button Test "},
{(void *)Lcd_Test, "Lcd test "},
{(void *)buzzer_test, "buzzer_test "},
{(void *)gps_test, "gps_test "},
{(void *)tenkey_test, "tenkey_test "},
{(void *)adc_test, "adc_test "},
{(void *)sht11_test, "sht11_test "},
{0,0}
};


void Clk_Init (void)
{
// 1. Clocking the controller from internal HSI RC (8 MHz)
// RCC_HSICmd(ENABLE);
// wait until the HSI is ready
while(RCC_GetFlagStatus(RCC_FLAG_HSIRDY) == RESET);
RCC_SYSCLKConfig(RCC_SYSCLKSource_HSI);
// 2. Enable ext. high frequency OSC
RCC_HSEConfig(RCC_HSE_ON);
// wait until the HSE is ready
while(RCC_GetFlagStatus(RCC_FLAG_HSERDY) == RESET);
// 3. Init PLL
RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9|RCC_PLL_MCO); // 8Mhz x 9 = 72MHz
RCC_PLLCmd(ENABLE);
// wait until the PLL is ready
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);
// 4. Set system clock dividers
RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5);
RCC_ADCCLKConfig(RCC_PCLK2_Div8);
RCC_PCLK2Config(RCC_HCLK_Div1); //1
RCC_PCLK1Config(RCC_HCLK_Div2); //2
RCC_HCLKConfig(RCC_SYSCLK_Div1);

#ifdef EMB_FLASH
// 5. Init Embedded Flash
// Zero wait state, if 0 < HCLK 24 MHz
// One wait state, if 24 MHz < HCLK 56 MHz
// Two wait states, if 56 MHz < HCLK 72 MHz d
// Flash wait state
FLASH_SetLatency(FLASH_Latency_2);
// Half cycle access
FLASH_HalfCycleAccessCmd(FLASH_HalfCycleAccess_Disable);
// Prefetch buffer
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
#endif // EMB_FLASH
// 5. Clock system from PLL
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
}



extern unsigned char column ;
extern int bUart3Recv;
int spot_timer_value = 0 ;
int adc_delay_timer = 0;

int spot_timer_delay = 0;

int oled_error = 0;


BYTE key_pressed(void)
{
int key = 0;
key = ((GPIO_ReadInputData(GPIOC) >> 4) & 0x0001);
key = ~key & 0x01;
return (BYTE)key;
}


int AC_Detection(void)
{
int ac_key = 0;
ac_key = (GPIO_ReadInputData(GPIOB) >> 1) & 0x01 ;
return ac_key;
}


BYTE oled_num = 0;
BYTE multy_spot_value = 1;
BYTE spot_period_value = 0;
BYTE Spot_Tap = 0;
//--------------------------------------------------------------------
void main(void)
{
Int16U key_value =0;
int ac_lock = 0;
int led_blink_count;


char prev_oled_num;
char hex_num;
int spot_count_value = 0;
BYTE Spot_Control_Value[3] = {25,1,18}; // SPOT TIME, MULTI SPOT, SPOT PERIODE

// Init clock system
ENTR_CRT_SECTION(); // Main IRQ Disable
Clk_Init();

// NVIC init
NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
LED_GPIO_init();
segment_out_pin_init(); // status segment
digital_out_pin_init() ; // SPOT EN, DIGITAL OUTPUT

digital_input_pin_init();


init_i2c1_peripheral(I2C2); // To Do - Move All this into init_i2c1_peripheral()
KeyInit() ; // key board initialize
// Enable timer counting
Timer1_initalize();
// adcPort_Init(); //adc port initialize
UART_Initialize(UART1, 115200) ;
EXT_CRT_SECTION();
// Init sequence for 128x64 OLED module
Dly100us((void *)800); // loop 300
oled_error = ssd1306_i2c_init(I2C2, I2C1_SSD1306_SLAVE_ADDRESS8);
oled_error = ssd1306_i2c_init(I2C2, I2C1_SSD1306_SLAVE_ADDRESS8);
//EXT_CRT_SECTION(); // Main IRQ Enable
adc_delay_timer = 100;
Dly100us((void *)300); // loop 300
Uart_Printf("ssd1306_i2c_draw_buffer...\r\n");
if( oled_error != -1){
ssd1306_clear_display_buffer(global_display_buffer);
}
Uart_Printf("===================================================\r\n");
Uart_Printf("Spot Controller Firmware Test Program by eLogics!!!\r\n");
Uart_Printf("================================================== \r\n");

// LCD CLEAR
Dly100us((void *)5000); // loop 300
if( oled_error != -1){
ssd1306_clear_display_buffer(global_display_buffer);
oled_num = Spot_Control_Value[0];
multy_spot_value = Spot_Control_Value[1];
spot_period_value = Spot_Control_Value[2];
spot_menu_display();
}
// main loop
oled_num = 0;
int menu_display_flag = 0;
while(1)
{
key_value = Getkey();//

if(rotary_key_value==0x02 && rotary_lock == 1 ){ // increament process
if(Spot_Tap == 0x00)
if(Spot_Control_Value[Spot_Tap] > 250) Spot_Control_Value[Spot_Tap] = 0; // spot time
else Spot_Control_Value[Spot_Tap]++;
else if(Spot_Tap == 0x01)
if(Spot_Control_Value[Spot_Tap] > 6) Spot_Control_Value[Spot_Tap] = 1; // multy spot
else Spot_Control_Value[Spot_Tap]++;
else if(Spot_Tap == 0x02)
if(Spot_Control_Value[Spot_Tap] > 50) Spot_Control_Value[Spot_Tap] = 0; // spot 간격
else Spot_Control_Value[Spot_Tap]++;
menu_display_flag = 1;
}
else if(rotary_key_value==0x04 && rotary_lock ==1 ){ // deccreament process
if(Spot_Tap == 0x00)
if(Spot_Control_Value[Spot_Tap] <= 0) Spot_Control_Value[Spot_Tap] = 250; // spot time
else Spot_Control_Value[Spot_Tap]--;
else if(Spot_Tap == 0x01)
if(Spot_Control_Value[Spot_Tap] <= 1) Spot_Control_Value[Spot_Tap] = 6; // multy spot
else Spot_Control_Value[Spot_Tap]--;
else if(Spot_Tap == 0x02)
if(Spot_Control_Value[Spot_Tap] <=0) Spot_Control_Value[Spot_Tap] = 50; // spot 간격
else Spot_Control_Value[Spot_Tap]--;
menu_display_flag = 1;
}
else if(key_value == 0x08) {
Spot_Tap++;
if(Spot_Tap >= 3) Spot_Tap =0;
menu_display_flag = 1;
}
else if(key_value ==0x01 ) { // spot key check
for(int i =0;i
if(ac_lock==0) {
while((AC_Detection() == 0x00));
ac_lock = 1;
}
spot_timer_value = oled_num; // spot timer set
while(spot_timer_value!=0 ); //여기서 spot 됨
spot_timer_delay = 18; // spot time delay;
while(spot_timer_delay != 0);
} // FOR STATE
led_blink_count = 65000;
while(1){
led_blink();
if( key_pressed() == 0x00) break;
}
Uart_Printf("Totoal Spot_count_value: %d\r\n", spot_count_value++);
}
if( menu_display_flag == 1){
menu_display_flag = 0;
oled_num = Spot_Control_Value[0];
multy_spot_value = Spot_Control_Value[1];
spot_period_value = Spot_Control_Value[2];
if( oled_error != -1){
spot_menu_display();
}
rotary_lock = 0;
// Uart_Printf("Spot_Tap Value: %d\r\n", Spot_Tap);
if(Spot_Tap == 0)
Uart_Printf("Spot_Time_Value: %d\r\n", Spot_Control_Value[Spot_Tap]);
else if(Spot_Tap == 1)
Uart_Printf("Multi Spot_Value: %d\r\n", Spot_Control_Value[Spot_Tap]);
else if(Spot_Tap == 2)
Uart_Printf("Spot_Period_Value: %d\r\n", Spot_Control_Value[Spot_Tap]);
}
led_sw_blink1(oled_num);
Dly100us((void *)300); // loop 300
} // while loop
}



//-----------------------------------------------
void Button_Test(void)
{

Uart_Printf("Tachyon 2/3 Firmware Button Test !!!\r\n");
LCD_Clear();
LCD_Write_string(0,ROW1,"button Test");
}


void spot_menu_display(void)
{
char seg_num;
ssd1306_HAN_string_to_buffer (0, 0, "스폿제어기", global_display_buffer);
ssd1306_string_to_buffer &nbs

촬스킴 16-12-16 13:09
답변 삭제  
항상 배우고 있습니다. 감샇합니다
내멋으… 16-12-16 14:08
답변  
귀한 자료 공개해 주셔서 감사합니다