main.c 954 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "bootloader.h"
  2. #include "can.h"
  3. #include "dwt.h"
  4. #include "global.h"
  5. #include "iap.h"
  6. #include "led.h"
  7. #include "queue.h"
  8. #include "system_stm32f4xx.h"
  9. #include <stm32f4xx.h>
  10. extern SqQueue CanQueueImportant; // CANÖØÒªÊý¾Ý¶ÓÁÐ
  11. int main(void)
  12. {
  13. u16 cnt = 0;
  14. CanData_TypeDef element;
  15. NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
  16. DWT_Init();
  17. LED_Init();
  18. InitQueue(&CanQueueImportant);
  19. CAN2_Init();
  20. while (1)
  21. {
  22. if (GetHead(&CanQueueImportant, &element) != ERROR)
  23. {
  24. cnt = 0;
  25. LED_RUN_ON();
  26. iap_process(&element);
  27. }
  28. else if (flash_up_is_ok() == TRUE)
  29. {
  30. Iap_from_Flash();
  31. boot_goto_app(APP_ADDRESS);
  32. }
  33. else
  34. {
  35. cnt++;
  36. bsp_DelayMS(10);
  37. if (cnt > 100)
  38. {
  39. boot_goto_app(APP_ADDRESS);
  40. }
  41. }
  42. }
  43. }