AppTaskMain.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. // MCUEnterSleep();
  49. }
  50. }
  51. static void vTimerCallback(TimerHandle_t pxTimer)
  52. {
  53. uint32 ulTimerID;
  54. ulTimerID = (uint32)pvTimerGetTimerID(pxTimer);
  55. if (ulTimerID == 0)
  56. {
  57. TimerCounter = TimerCounter + 10;
  58. }
  59. }