|
@@ -181,22 +181,29 @@ static void Main_Task(void* arg)
|
|
|
{
|
|
|
case PROCESS_STATE_IDLE:
|
|
|
{
|
|
|
- #ifdef USING_PRINTF
|
|
|
- printf("Main_IDLE \n");
|
|
|
- #endif
|
|
|
- osDelay(100/portTICK_PERIOD_MS);
|
|
|
- if(true)
|
|
|
+ osDelay(10/portTICK_PERIOD_MS);
|
|
|
+ Uart_index++;
|
|
|
+ if (Uart_index >10)//Uart 1s 调用一次
|
|
|
+ {
|
|
|
+ #ifdef USING_PRINTF
|
|
|
+ printf("Uart_check \n");
|
|
|
+ #endif
|
|
|
+ PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_CHECK);
|
|
|
+ Uart_index = 0;
|
|
|
+ }
|
|
|
+ if(true)//电流为0满足
|
|
|
{
|
|
|
sleep_index++;
|
|
|
- if(sleep_index>=50)
|
|
|
- {
|
|
|
- sleep_index=0;
|
|
|
- PROC_MAIN_STATE_SWITCH(PROCESS_STATE_SLEEP);
|
|
|
- }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- PROC_Task_STATE_SWITCH(PROCESS_STATE_WORK);
|
|
|
+ sleep_index=0;
|
|
|
+ PROC_MAIN_STATE_SWITCH(PROCESS_STATE_WORK);
|
|
|
+ }
|
|
|
+ if(sleep_index>=500)
|
|
|
+ {
|
|
|
+ sleep_index=0;
|
|
|
+ PROC_MAIN_STATE_SWITCH(PROCESS_STATE_SLEEP);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
@@ -211,6 +218,7 @@ static void Main_Task(void* arg)
|
|
|
#ifdef USING_PRINTF
|
|
|
printf("Uart_start \n");
|
|
|
#endif
|
|
|
+ PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_WORK);
|
|
|
Uart_index = 0;
|
|
|
}
|
|
|
if (Can_index >=100)//Can 1s 调用一次
|
|
@@ -244,7 +252,11 @@ static void Main_Task(void* arg)
|
|
|
}
|
|
|
case PROCESS_STATE_SLEEP:
|
|
|
{
|
|
|
- PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_SLEEP);
|
|
|
+ while(gProcess_Uart_Task!=PROCESS_UART_STATE_SLEEP)
|
|
|
+ {
|
|
|
+ PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_SLEEP);
|
|
|
+ }
|
|
|
+
|
|
|
slpManSlpState_t State;
|
|
|
uint8_t cnt;
|
|
|
if(slpManCheckVoteState(MainSlpHandler, &State, &cnt)==RET_TRUE)
|
|
@@ -329,19 +341,18 @@ uint8_t* Uart_Receive_func(Uart_Receive_Type Uart_Receive_Msg,uint8_t* Uart_Rece
|
|
|
CRC_chk_buffer = crc_chk(Uart_Send_buffer,6);
|
|
|
Uart_Send_buffer[6] = CRC_chk_buffer;
|
|
|
Uart_Send_buffer[7] = CRC_chk_buffer>>8;
|
|
|
- uint8_t timeout = 0x00;
|
|
|
+ uint32_t timeout = 0x00000000;
|
|
|
USARTdrv->Send(Uart_Send_buffer,8);
|
|
|
USARTdrv->Receive(Uart_Rece_buffer,Data_Len);
|
|
|
while((isRecvTimeout == false) && (isRecvComplete == false))
|
|
|
{
|
|
|
timeout++;
|
|
|
- if (timeout>=500)
|
|
|
+ if (timeout>=7000000)
|
|
|
{
|
|
|
timeout =0;
|
|
|
isRecvTimeout = true;
|
|
|
break;
|
|
|
}
|
|
|
- osDelay(10);
|
|
|
}
|
|
|
if (isRecvComplete == true)
|
|
|
{
|
|
@@ -376,7 +387,7 @@ uint8_t* Uart_Receive_func(Uart_Receive_Type Uart_Receive_Msg,uint8_t* Uart_Rece
|
|
|
{
|
|
|
memset(Uart_Rece_buffer,0x00,Data_Len);
|
|
|
isRecvTimeout = false;
|
|
|
- osDelay(1000);
|
|
|
+ osDelay(100);
|
|
|
return Uart_Rece_buffer;
|
|
|
}
|
|
|
|
|
@@ -467,6 +478,9 @@ static void Uart_Task(void* arg)
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+ #ifdef USING_PRINTF
|
|
|
+ printf("Rece:%d\n",Rece_index);
|
|
|
+ #endif
|
|
|
Rece_index++;
|
|
|
break;
|
|
|
}
|