#include "board.h" #include "bootloader.h" #include "global.h" #include "iap.h" #include "queue.h" #include "stm32f4xx_gpio.h" #include "system_stm32f4xx.h" #include extern SqQueue CanQueueImportant; // CAN重要数据队列 int main(void) { rt_hw_board_init(); u16 cnt = 0; CanData_TypeDef element; rt_pin_mode(RED_LED_PIN, PIN_MODE_OUTPUT); rt_pin_mode(GREEN_LED_PIN, PIN_MODE_OUTPUT); InitQueue(&CanQueueImportant); while (1) { if (GetHead(&CanQueueImportant, &element) != ERROR) { cnt = 0; delay_ms(1000); GPIO_ToggleBits(GPIOF, GPIO_Pin_9); iap_process(&element); } else if (flash_up_is_ok() == TRUE) { iap_from_flash(); boot_goto_app(APP_ADDRESS); } else { cnt++; delay_ms(10); if (cnt > 100) { boot_goto_app(APP_ADDRESS); } } } }