AppTaskMain.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * AppTaskMain.c
  3. *
  4. * Created on: 2022年2月22日
  5. * Author: QiXiang_CHENJIE
  6. */
  7. #include "AppTaskMain.h"
  8. #include "hal_fls.h"
  9. static void vTimerCallback(TimerHandle_t pxTimer);
  10. void MainTask(void *pvParameters)
  11. {
  12. (void)pvParameters;
  13. TimerHandle_t monitorTimer;
  14. monitorTimer = xTimerCreate("monitor", 10, pdTRUE, (void *)0, vTimerCallback);
  15. xTimerStart(monitorTimer, 0);
  16. TimerHandle_t monitorTimer1ms;
  17. monitorTimer1ms = xTimerCreate("monitor1ms", 1, pdTRUE, (void *)0, vTimer1msCallback);
  18. xTimerStart(monitorTimer1ms, 0);
  19. sleep_mutex = xSemaphoreCreateBinary();
  20. uint32 *eppromAddStart = 0x14000000;
  21. if (*(uint8 *)(eppromAddStart) == 0xff)
  22. {
  23. HAL_EEP_Write(0, (uint8 *)&AppConfigInfo, sizeof(AppConfigInfo));
  24. }
  25. HAL_EEP_Read(0, (uint8 *)&AppConfigInfo, sizeof(AppConfigInfo));
  26. HAL_EEP_Read(200, (uint8 *)&BcuAppSaveDataInfo, sizeof(BcuAppSaveDataInfo));
  27. while (1)
  28. {
  29. vTaskDelay(pdMS_TO_TICKS(10));
  30. if (HAL_Is100msTickTimeout())
  31. {
  32. if (IsFeedWdg == TRUE)
  33. {
  34. WATCHDOG_HAL_Feed();
  35. }
  36. }
  37. if (AppConfigInfo.appSaveFlg)
  38. {
  39. AppConfigInfo.appSaveFlg = false;
  40. HAL_EEP_Write(0, (uint8 *)&AppConfigInfo, sizeof(AppConfigInfo));
  41. }
  42. if(BcuAppSaveDataInfo.bcuSaveFlg)
  43. {
  44. BcuAppSaveDataInfo.bcuSaveFlg = false;
  45. HAL_EEP_Write(200, (uint8 *)&BcuAppSaveDataInfo, sizeof(BcuAppSaveDataInfo));
  46. }
  47. if (Fota_update_flag==1)
  48. {
  49. // 重启前保存数据
  50. AppConfigInfo.appSaveFlg = false;
  51. HAL_EEP_Write(0, (uint8 *)&AppConfigInfo, sizeof(AppConfigInfo));
  52. HAL_EEP_Write(200, (uint8 *)&BcuAppSaveDataInfo, sizeof(BcuAppSaveDataInfo));
  53. SystemSoftwareReset();
  54. }
  55. #ifndef SEGGER_RTT_PRINTF
  56. MCUEnterSleep();
  57. #endif
  58. }
  59. }
  60. static void vTimerCallback(TimerHandle_t pxTimer)
  61. {
  62. uint32 ulTimerID;
  63. ulTimerID = (uint32)pvTimerGetTimerID(pxTimer);
  64. if (ulTimerID == 0)
  65. {
  66. TimerCounter = TimerCounter + 10;
  67. }
  68. }