123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- /*
- * AppTaskMain.c
- *
- * Created on: 2022Äê2ÔÂ22ÈÕ
- * Author: QiXiang_CHENJIE
- */
- #include "AppTaskMain.h"
- #include "hal_fls.h"
- static void vTimerCallback(TimerHandle_t pxTimer);
- extern uint32 timerCANIdle;
- void MainTask(void *pvParameters)
- {
- (void)pvParameters;
- TimerHandle_t monitorTimer;
- monitorTimer = xTimerCreate("monitor",10,pdTRUE,(void *)0,vTimerCallback);
- xTimerStart(monitorTimer,0);
- TimerHandle_t monitorTimer1ms;
- monitorTimer1ms = xTimerCreate("monitor1ms",1,pdTRUE,(void *)0,vTimer1msCallback);
- xTimerStart(monitorTimer1ms,0);
- sleep_mutex = xSemaphoreCreateBinary();
- uint32 *eppromAddStart = 0x14000000;
- if(*(uint8 *)(eppromAddStart)==0xff)
- {
- HAL_EEP_Write(0,(uint8 *)&AppConfigInfo,sizeof(AppConfigInfo));
- }
- HAL_EEP_Read(0,(uint8 *)&AppConfigInfo,sizeof(AppConfigInfo));
- while(1)
- {
- vTaskDelay(pdMS_TO_TICKS(10));
- if(HAL_Is100msTickTimeout())
- {
- if(IsFeedWdg == TRUE)
- {
- WATCHDOG_HAL_Feed();
- }
- }
- if(AppConfigInfo.appSaveFlg)
- {
- AppConfigInfo.appSaveFlg = false;
- HAL_EEP_Write(0,(uint8 *)&AppConfigInfo,sizeof(AppConfigInfo));
- }
- if(Fota_update_flag || Fota_error_flag)
- {
- //ÖØÆôÇ°±£´æÊý¾Ý
- AppConfigInfo.appSaveFlg = false;
- HAL_EEP_Write(0,(uint8 *)&AppConfigInfo,sizeof(AppConfigInfo));
- SystemSoftwareReset();
- }
- if(pdTRUE == xSemaphoreTake(sleep_mutex,1))
- {
- vTaskSuspend(Uart_Hal_RecvTask_Handle);
- vTaskSuspend(Uart_Hal_SendTask_Handle);
- vTaskSuspend(CanTask_Handle);
- vTaskSuspend(GpsTask_Handle);
- vTaskSuspend(Uart_4G_Task_Handle);
- SystemPeripheralDeinit();
- SystemPrepareForSleep();
- coreInit();
- SystemModulesInit();
- /* Initialize all pins*/
- #if (PORT_PRECOMPILE_SUPPORT == STD_ON)
- Port_Init(NULL_PTR);
- #elif (PORT_PRECOMPILE_SUPPORT == STD_OFF)
- Port_Init(&Port_Config_VS_0);
- #endif
- vTaskDelay(pdMS_TO_TICKS(100));
- // vTaskDelay(pdMS_TO_TICKS(100));
- // currentMode = Mcu_GetPowerModeState();
- Dio_WriteChannel(DioConf_DioChannel_PTE9_GPIO_OUT_MCU_LED5, STD_OFF);
- // vTaskDelay(pdMS_TO_TICKS(500));
- // Icu_DeInit();
- //4G module power on
- // vTaskDelay(pdMS_TO_TICKS(1000));
- timerCANIdle = 0;
- Dio_WriteChannel(DioConf_DioChannel_PTA6_GPIO_OUT_MCU_4G_POW_EN, STD_ON);
- vTaskDelay(pdMS_TO_TICKS(1000));
- Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_ON);
- vTaskDelay(pdMS_TO_TICKS(500));
- Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_OFF);
- //GPS module power on
- Dio_WriteChannel(DioConf_DioChannel_PTD1_GPIO_OUT_MCU_GPS_POW_EN, STD_ON);
- // vTaskDelay(pdMS_TO_TICKS(1000));
- vTaskResume(Uart_Hal_RecvTask_Handle);
- vTaskResume(Uart_Hal_SendTask_Handle);
- vTaskResume(CanTask_Handle);
- vTaskResume(GpsTask_Handle);
- vTaskResume(Uart_4G_Task_Handle);
- }
- }
- }
- static void vTimerCallback(TimerHandle_t pxTimer)
- {
- uint32 ulTimerID;
- ulTimerID = (uint32)pvTimerGetTimerID(pxTimer);
- if(ulTimerID==0)
- {
- TimerCounter = TimerCounter + 10;
- }
- }
|