AppTaskMain.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. extern uint32 timerCANIdle;
  11. void MainTask(void *pvParameters)
  12. {
  13. (void)pvParameters;
  14. TimerHandle_t monitorTimer;
  15. monitorTimer = xTimerCreate("monitor",10,pdTRUE,(void *)0,vTimerCallback);
  16. xTimerStart(monitorTimer,0);
  17. TimerHandle_t monitorTimer1ms;
  18. monitorTimer1ms = xTimerCreate("monitor1ms",1,pdTRUE,(void *)0,vTimer1msCallback);
  19. xTimerStart(monitorTimer1ms,0);
  20. sleep_mutex = xSemaphoreCreateBinary();
  21. uint32 *eppromAddStart = 0x14000000;
  22. if(*(uint8 *)(eppromAddStart)==0xff)
  23. {
  24. HAL_EEP_Write(0,(uint8 *)&AppConfigInfo,sizeof(AppConfigInfo));
  25. }
  26. HAL_EEP_Read(0,(uint8 *)&AppConfigInfo,sizeof(AppConfigInfo));
  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(Fota_update_flag || Fota_error_flag)
  43. {
  44. //ÖØÆôÇ°±£´æÊý¾Ý
  45. AppConfigInfo.appSaveFlg = false;
  46. HAL_EEP_Write(0,(uint8 *)&AppConfigInfo,sizeof(AppConfigInfo));
  47. SystemSoftwareReset();
  48. }
  49. if(pdTRUE == xSemaphoreTake(sleep_mutex,1))
  50. {
  51. vTaskSuspend(Uart_Hal_RecvTask_Handle);
  52. vTaskSuspend(Uart_Hal_SendTask_Handle);
  53. vTaskSuspend(CanTask_Handle);
  54. vTaskSuspend(GpsTask_Handle);
  55. vTaskSuspend(Uart_4G_Task_Handle);
  56. SystemPeripheralDeinit();
  57. SystemPrepareForSleep();
  58. coreInit();
  59. SystemModulesInit();
  60. /* Initialize all pins*/
  61. #if (PORT_PRECOMPILE_SUPPORT == STD_ON)
  62. Port_Init(NULL_PTR);
  63. #elif (PORT_PRECOMPILE_SUPPORT == STD_OFF)
  64. Port_Init(&Port_Config_VS_0);
  65. #endif
  66. vTaskDelay(pdMS_TO_TICKS(100));
  67. // vTaskDelay(pdMS_TO_TICKS(100));
  68. // currentMode = Mcu_GetPowerModeState();
  69. Dio_WriteChannel(DioConf_DioChannel_PTE9_GPIO_OUT_MCU_LED5, STD_OFF);
  70. // vTaskDelay(pdMS_TO_TICKS(500));
  71. // Icu_DeInit();
  72. //4G module power on
  73. // vTaskDelay(pdMS_TO_TICKS(1000));
  74. timerCANIdle = 0;
  75. Dio_WriteChannel(DioConf_DioChannel_PTA6_GPIO_OUT_MCU_4G_POW_EN, STD_ON);
  76. vTaskDelay(pdMS_TO_TICKS(1000));
  77. Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_ON);
  78. vTaskDelay(pdMS_TO_TICKS(500));
  79. Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_OFF);
  80. //GPS module power on
  81. Dio_WriteChannel(DioConf_DioChannel_PTD1_GPIO_OUT_MCU_GPS_POW_EN, STD_ON);
  82. // vTaskDelay(pdMS_TO_TICKS(1000));
  83. vTaskResume(Uart_Hal_RecvTask_Handle);
  84. vTaskResume(Uart_Hal_SendTask_Handle);
  85. vTaskResume(CanTask_Handle);
  86. vTaskResume(GpsTask_Handle);
  87. vTaskResume(Uart_4G_Task_Handle);
  88. }
  89. }
  90. }
  91. static void vTimerCallback(TimerHandle_t pxTimer)
  92. {
  93. uint32 ulTimerID;
  94. ulTimerID = (uint32)pvTimerGetTimerID(pxTimer);
  95. if(ulTimerID==0)
  96. {
  97. TimerCounter = TimerCounter + 10;
  98. }
  99. }