//开机初始化 void All_Init( void ) { const uint32_t NewDeviationAddr = 0x4000; /* BootLoad引导程序时,必须在Main中添加,同时更改“魔术棒--Target选项卡的ROM偏移地址” */ NVIC_SetVectorTable(NVIC_VectTab_FLASH,NewDeviationAddr); /* 外设初始化 */ lcd_init(); rtc_init(); led_init(); uart3_init(BAUD_38400); print_init(); //波特率19200 timeout_init(); TIM5_TimeoutInit(); link_init(); tf_init(); eep_init(); delay_init_t2(); beep_init(); SysTick_Config(SYSTICK_10MS); // PrintSystemParameter(); //串口打印系统参数信息,用于调试 #ifdef ENABLE_BEEP BEEP_START(); #endif set_page(system_init); }
int main(void) { systick_init(); eep_init(); //读取EEPROM内的数据 lcd_init(); key_init(); io_init(); pwm_init(); ntc_init(); while (1) { if (time_1ms_flag == 1) { //1ms进入一次 time_1ms_flag = 0; } if(time_10ms_flag == 1) { //10ms进入一次 time_10ms_flag = 0; key_scan(); } if(time_100ms_flag == 1) { //100ms进入一次 time_100ms_flag = 0; key_done(); } if(time_1s_flag == 1) { //1s执行一次 time_1s_flag = 0; } } }
void main(void) { #else int main(void) { #endif /* Ensure that the Watchdog is not running. */ wdt_disable(); /* Initialize system. */ if (true != avr_init()) { error_handler(); } else if (true != eep_init()) { eep_deinit(); error_handler(); } else if (true != cmd_if_init()) { cmd_if_deinit(); error_handler(); } /* Disable modules that are not needed any more. */ eep_deinit(); LED_ORANGE_ON(); /* Enable interrupts. */ sei(); /* Endless application loop. */ for(;;) { /* Dispatch events from the event queue. */ vrt_dispatch_event(); /* Poll modules that require this. */ vrt_timer_task(); usb_task(); air_capture_task(); cmd_if_task(); } }
void main(void) { #else int main(void) { #endif /* Ensure that the watchdog is not running. */ wdt_disable(); /* Initialize AVR peripheral modules. */ (bool)avr_init(); /* Check if the RX and TX pins are shorted. If they are shorted, the RZUSBSTICK * shall start the bootloader. If not, continue to verify if the application * requested to enter the bootloader. */ /* Check if the application has requested to enter the bootloader. */ if ((BOOT_PIN & (1 << BOOT_RX)) != (1 << BOOT_RX)) { /* Check that RX goes high when TX is pulled high. */ BOOT_PORT |= (1 << BOOT_TX); nop(); nop(); nop(); nop(); if ((BOOT_PIN & (1 << BOOT_RX)) != (1 << BOOT_RX)) { start_application(); } } else { /* Check if the application has requested to enter the bootloader. */ uint8_t volatile magic_value = 0xAA; EEGET(magic_value, EE_BOOT_MAGIC_ADR); if (EE_BOOT_MAGIC_VALUE != magic_value) { start_application(); } else { EEPUT(EE_BOOT_MAGIC_ADR, 0xFF); } } /* Set the interrupt vectors to the bootloader, initialize the LEDs and the * VRT kernel. */ ENTER_CRITICAL_REGION(); uint8_t temp_mcucr = MCUCR; MCUCR = (1 << IVCE); MCUCR = (1 << IVSEL); MCUCR = temp_mcucr; LEAVE_CRITICAL_REGION(); LED_INIT(); vrt_init(); if (true != eep_init()) { error_handler(); } else if (true != cmd_if_init()) { error_handler(); } LED_ORANGE_ON(); /* Enable Interrupts. */ sei(); /* Enter the endless application loop. */ for (;;) { vrt_dispatch_event(); usb_task(); } }