AppTaskMain.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * @Author: chenjie
  3. * @Date: 2022-06-06
  4. * @LastEditTime: 2022-10-27
  5. * @LastEditors: chenjie
  6. * @Description:
  7. * @FilePath: \S32K146_4G\code\app\AppTaskMain.c
  8. * Copyright (c) 2022 by chenjie, All Rights Reserved.
  9. */
  10. #include "AppTaskMain.h"
  11. #include "hal_fls.h"
  12. static void vTimerCallback(TimerHandle_t pxTimer);
  13. void MainTask(void *pvParameters)
  14. {
  15. (void)pvParameters;
  16. TimerHandle_t monitorTimer;
  17. monitorTimer = xTimerCreate("monitor",10,pdTRUE,(void *)0,vTimerCallback);
  18. xTimerStart(monitorTimer,0);
  19. TimerHandle_t monitorTimer1ms;
  20. monitorTimer1ms = xTimerCreate("monitor1ms",1,pdTRUE,(void *)0,vTimer1msCallback);
  21. xTimerStart(monitorTimer1ms,0);
  22. uint32 *eppromAddStart = 0x14000000;
  23. if(*(uint8 *)(eppromAddStart)==0xff)
  24. {
  25. HAL_EEP_Write(0,(uint8 *)&AppConfigInfo,sizeof(AppConfigInfo));
  26. }
  27. HAL_EEP_Read(0,(uint8 *)&AppConfigInfo,sizeof(AppConfigInfo));
  28. while(1)
  29. {
  30. vTaskDelay(pdMS_TO_TICKS(10));
  31. if(HAL_Is100msTickTimeout())
  32. {
  33. if(IsFeedWdg == TRUE)
  34. {
  35. WATCHDOG_HAL_Feed();
  36. }
  37. }
  38. if(TimerCounter%1000==0)
  39. {
  40. if(AppConfigInfo.eolFlg==true)
  41. {
  42. Dio_FlipChannel(DioConf_DioChannel_PTE9_GPIO_OUT_MCU_LED5);
  43. }
  44. else
  45. {
  46. Dio_WriteChannel(DioConf_DioChannel_PTE9_GPIO_OUT_MCU_LED5, STD_ON);
  47. }
  48. }
  49. if(AppConfigInfo.appSaveFlg)
  50. {
  51. AppConfigInfo.appSaveFlg = false;
  52. HAL_EEP_Write(0,(uint8 *)&AppConfigInfo,sizeof(AppConfigInfo));
  53. }
  54. if(Fota_update_flag || Fota_error_flag)//升级指令发出,进行重启,或者FTP服务器出现问题,进行重启
  55. {
  56. //重启前保存数据
  57. AppConfigInfo.appSaveFlg = false;
  58. HAL_EEP_Write(0,(uint8 *)&AppConfigInfo,sizeof(AppConfigInfo));
  59. SystemSoftwareReset();
  60. }
  61. }
  62. }
  63. static void vTimerCallback(TimerHandle_t pxTimer)
  64. {
  65. uint32 ulTimerID;
  66. ulTimerID = (uint32)pvTimerGetTimerID(pxTimer);
  67. if(ulTimerID==0)
  68. {
  69. TimerCounter = TimerCounter + 10;
  70. }
  71. }