|
@@ -35,8 +35,8 @@ static void MainTask(void* arg)
|
|
|
TimerHandle_t work_timer = NULL;
|
|
|
TimerHandle_t sleep_timer = NULL;
|
|
|
monitor_timer = xTimerCreate("monitor_timer", 100 / portTICK_RATE_MS, pdTRUE, NULL, monitor_timer_callback);
|
|
|
- work_timer = xTimerCreate("work_timer", 5*60*1000 / portTICK_RATE_MS, pdTRUE, NULL, work_timer_callback);
|
|
|
- sleep_timer = xTimerCreate("sleep_timer", 60*60*1000 / portTICK_RATE_MS, pdTRUE, NULL, sleep_timer_callback);
|
|
|
+ work_timer = xTimerCreate("work_timer", WORK_TIME*60*1000 / portTICK_RATE_MS, pdTRUE, NULL, work_timer_callback);
|
|
|
+ sleep_timer = xTimerCreate("sleep_timer", SLEEP_TIME*60*1000 / portTICK_RATE_MS, pdTRUE, NULL, sleep_timer_callback);
|
|
|
PROC_MAIN_STATE_SWITCH(PROCESS_STATE_IDLE);
|
|
|
slpManSetPmuSleepMode(true,SLP_HIB_STATE,false);
|
|
|
slpManApplyPlatVoteHandle("MainSlp",&MainSlpHandler);
|
|
@@ -63,6 +63,7 @@ static void MainTask(void* arg)
|
|
|
AppDataInfo.SysReStartCount = AppDataInfo.SysReStartCount + 1;
|
|
|
}
|
|
|
xTimerStart(monitor_timer, 0);
|
|
|
+ UINT8 Temp = 0;
|
|
|
while(true)
|
|
|
{
|
|
|
switch(gProcess_Main_Task)
|
|
@@ -88,13 +89,19 @@ static void MainTask(void* arg)
|
|
|
printf("[%d]%x - %x - %x - %x - %x\n",__LINE__,WorkTimerEnd,BMS_Fota_update_flag,TCPWorkState,BattWorkStateDelay,PadInterrupt);
|
|
|
#endif
|
|
|
}
|
|
|
- if((WorkTimerEnd==TRUE)&&(BMS_Fota_update_flag==FALSE)&&(TCPWorkState==0x00)&&(BattWorkStateDelay==BATT_IDLE_SYM)&&(PadInterrupt==0x00))//从工作转换为监听的条件
|
|
|
+ if(WorkTimerEnd==TRUE)//从工作转换为监听的条件,定时器结束
|
|
|
{
|
|
|
PROC_MAIN_STATE_SWITCH(PROCESS_STATE_LISTEN);
|
|
|
xTimerStop(work_timer,0);
|
|
|
xTimerStart(sleep_timer, 0);
|
|
|
WorkTimerEnd = FALSE;
|
|
|
NVIC_EnableIRQ(PadWakeup1_IRQn);
|
|
|
+ PadInterrupt = 0x00;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if((BMS_Fota_update_flag!=FALSE)||(TCPWorkState!=0x00)||(BattWorkStateDelay!=BATT_IDLE_SYM)||(PadInterrupt!=0x00))
|
|
|
+ {
|
|
|
+ xTimerReset(work_timer,0);
|
|
|
}
|
|
|
if(TcpErrorcount>=10 &&PadInterrupt==0x00)
|
|
|
{
|
|
@@ -125,12 +132,17 @@ static void MainTask(void* arg)
|
|
|
case PROCESS_STATE_LISTEN:
|
|
|
{
|
|
|
PROC_APP_STATE_SWITCH(LISTEN);
|
|
|
- osDelay(100);
|
|
|
if(PadInterrupt!=0x00)
|
|
|
{
|
|
|
+ osDelay(10);
|
|
|
PadInterrupt_clrCounter++;
|
|
|
+ Temp = PadInterrupt;
|
|
|
PadInterrupt = 0x00;
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ osDelay(100);
|
|
|
+ }
|
|
|
if(AppDataInfo.appDataModify)
|
|
|
{
|
|
|
SaveAppData();
|
|
@@ -142,8 +154,12 @@ static void MainTask(void* arg)
|
|
|
#ifdef USING_PRINTF1
|
|
|
printf("[%d]%x - %x - %x - %x\n",__LINE__,SleepTimerEnd,BMS_Fota_update_flag,TCPWorkState,PadInterrupt);
|
|
|
#endif
|
|
|
- if((SleepTimerEnd)||(TCPWorkState==1)||(PadInterrupt_clrCounter>=3))//从监听转换为工作的条件
|
|
|
+ if((SleepTimerEnd)||(TCPWorkState==1)||(PadInterrupt_clrCounter>=2))//从监听转换为工作的条件
|
|
|
{
|
|
|
+ #ifdef USING_PRINTF
|
|
|
+ printf("[%d]-%x",__LINE__,battWorkState);
|
|
|
+ printf("[%d]%x - %x - %x - %x - %x-%d\n",__LINE__,WorkTimerEnd,BMS_Fota_update_flag,TCPWorkState,BattWorkStateDelay,Temp,PadInterrupt_clrCounter);
|
|
|
+ #endif
|
|
|
PROC_MAIN_STATE_SWITCH(PROCESS_STATE_IDLE);
|
|
|
xTimerStop(sleep_timer,0);
|
|
|
SleepTimerEnd = FALSE;
|