AppTaskMain.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. while (1)
  27. {
  28. vTaskDelay(pdMS_TO_TICKS(10));
  29. if (HAL_Is100msTickTimeout())
  30. {
  31. if (IsFeedWdg == TRUE)
  32. {
  33. WATCHDOG_HAL_Feed();
  34. }
  35. }
  36. if (AppConfigInfo.appSaveFlg)
  37. {
  38. AppConfigInfo.appSaveFlg = false;
  39. HAL_EEP_Write(0, (uint8 *)&AppConfigInfo, sizeof(AppConfigInfo));
  40. }
  41. if (Fota_update_flag || Fota_error_flag)
  42. {
  43. // 重启前保存数据
  44. AppConfigInfo.appSaveFlg = false;
  45. HAL_EEP_Write(0, (uint8 *)&AppConfigInfo, sizeof(AppConfigInfo));
  46. SystemSoftwareReset();
  47. }
  48. #ifndef SEGGER_RTT_PRINTF
  49. MCUEnterSleep();
  50. #endif
  51. }
  52. }
  53. static void vTimerCallback(TimerHandle_t pxTimer)
  54. {
  55. uint32 ulTimerID;
  56. ulTimerID = (uint32)pvTimerGetTimerID(pxTimer);
  57. if (ulTimerID == 0)
  58. {
  59. TimerCounter = TimerCounter + 10;
  60. }
  61. }