main.c 1018 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "board.h"
  2. #include "bootloader.h"
  3. #include "global.h"
  4. #include "iap.h"
  5. #include "queue.h"
  6. #include "stm32f4xx_gpio.h"
  7. #include "system_stm32f4xx.h"
  8. #include <stm32f4xx.h>
  9. extern SqQueue CanQueueImportant; // CANÖØÒªÊý¾Ý¶ÓÁÐ
  10. int main(void)
  11. {
  12. rt_hw_board_init();
  13. u16 cnt = 0;
  14. CanData_TypeDef element;
  15. rt_pin_mode(RED_LED_PIN, PIN_MODE_OUTPUT);
  16. rt_pin_mode(GREEN_LED_PIN, PIN_MODE_OUTPUT);
  17. InitQueue(&CanQueueImportant);
  18. while (1)
  19. {
  20. if (GetHead(&CanQueueImportant, &element) != ERROR)
  21. {
  22. cnt = 0;
  23. delay_ms(1000);
  24. GPIO_ToggleBits(GPIOF, GPIO_Pin_9);
  25. iap_process(&element);
  26. }
  27. else if (flash_up_is_ok() == TRUE)
  28. {
  29. iap_from_flash();
  30. boot_goto_app(APP_ADDRESS);
  31. }
  32. else
  33. {
  34. cnt++;
  35. delay_ms(10);
  36. if (cnt > 100)
  37. {
  38. boot_goto_app(APP_ADDRESS);
  39. }
  40. }
  41. }
  42. }