1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- /*
- * AppTaskMain.c
- *
- * Created on: 2022年2月22日
- * Author: QiXiang_CHENJIE
- */
- #include "AppTaskMain.h"
- #include "hal_fls.h"
- static void vTimerCallback(TimerHandle_t pxTimer);
- 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();
- // HAL_EEP_Read(400, (uint8 *)&BcuSaveDataInfo, sizeof(BcuSaveDataInfo));
- // if (*(uint8 *)(eppromAddStart + 400) == 0xff || BcuSaveDataInfo.BcuAppSaveDataInfo.CRC != bcc_chk(&(BcuAppSaveDataInfo.CRC)+1,sizeof(BcuAppSaveDataInfo)-1));
- // {
- // memset(&BcuAppSaveDataInfo,0,sizeof(BcuAppSaveBody));
- // BcuAppSaveDataInfo.CRC = bcc_chk(&(BcuAppSaveDataInfo.CRC)+1,sizeof(BcuAppSaveDataInfo)-1);
- // BcuAppSaveDataInfo.bcuSaveFlg = false;
- // HAL_EEP_Write(400, (uint8 *)&BcuAppSaveDataInfo, sizeof(BcuAppSaveDataInfo));
- // }
- 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));
- globalSaveFlag = 0;
- }
- if(BcuSaveDataInfo.BcuAppSaveDataInfo.bcuSaveFlg)
- {
- BcuSaveDataInfo.BcuAppSaveDataInfo.bcuSaveFlg = false;
- BcuSaveDataInfo.header.crc = bcc_chk(&(BcuSaveDataInfo.BcuAppSaveDataInfo),sizeof(BcuSaveDataInfo.BcuAppSaveDataInfo));
- HAL_EEP_Write(400, (uint8 *)&BcuSaveDataInfo, sizeof(BcuSaveDataInfo));
- }
- if (Fota_update_flag==1)
- {
- // 重启前保存数据
- AppConfigInfo.appSaveFlg = false;
- HAL_EEP_Write(0, (uint8 *)&AppConfigInfo, sizeof(AppConfigInfo));
- HAL_EEP_Write(200, (uint8 *)&AppConfigInfo, sizeof(AppConfigInfo));
- BcuSaveDataInfo.BcuAppSaveDataInfo.bcuSaveFlg = false;
- BcuSaveDataInfo.header.crc = bcc_chk(&(BcuSaveDataInfo.BcuAppSaveDataInfo),sizeof(BcuSaveDataInfo.BcuAppSaveDataInfo));
- HAL_EEP_Write(400, (uint8 *)&BcuSaveDataInfo, sizeof(BcuSaveDataInfo));
- SystemSoftwareReset();
- }
- #ifndef SEGGER_RTT_PRINTF
- MCUEnterSleep();
- #endif
- }
- }
- static void vTimerCallback(TimerHandle_t pxTimer)
- {
- uint32 ulTimerID;
- ulTimerID = (uint32)pvTimerGetTimerID(pxTimer);
- if (ulTimerID == 0)
- {
- TimerCounter = TimerCounter + 10;
- }
- }
|