|
@@ -190,7 +190,12 @@ static void Main_Task(void* arg)
|
|
|
UINT16 Uart_index = 0;
|
|
|
UINT16 Tcp_index = 0;
|
|
|
uint32_t sleep_index = 0;
|
|
|
+ uint32_t sleep_time_flag;
|
|
|
int32_t inParam = 0xAABBCCDD;
|
|
|
+ uint32_t Chrgend_Work_time = 180000;
|
|
|
+ uint32_t Wakeup_Work_time = 6000;
|
|
|
+ uint32_t Sleep_Time = 600000;
|
|
|
+ //上述参数应写入文件里
|
|
|
slpManWakeSrc_e Wakeup_source;
|
|
|
PROC_MAIN_STATE_SWITCH(PROCESS_STATE_IDLE);
|
|
|
NetSocDisplay(LED_SOC_0,LED_TURN_OFF);
|
|
@@ -221,6 +226,19 @@ static void Main_Task(void* arg)
|
|
|
#ifdef USING_PRINTF
|
|
|
printf("Wakeup_source:%d \n",Wakeup_source);
|
|
|
#endif
|
|
|
+ if (Wakeup_source==0)
|
|
|
+ {
|
|
|
+ sleep_time_flag = Wakeup_Work_time;
|
|
|
+ }
|
|
|
+ else if (Wakeup_source==1)
|
|
|
+ {
|
|
|
+ sleep_time_flag = Wakeup_Work_time;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sleep_time_flag = Chrgend_Work_time;
|
|
|
+ }
|
|
|
+
|
|
|
if((slpstate == SLP_SLP2_STATE) || (slpstate == SLP_HIB_STATE))
|
|
|
{
|
|
|
PROC_MAIN_STATE_SWITCH(PROCESS_STATE_WORK);
|
|
@@ -253,7 +271,7 @@ static void Main_Task(void* arg)
|
|
|
PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_WORK);
|
|
|
Uart_index = 0;
|
|
|
}
|
|
|
- if (Can_index >=10)//Can 1s 调用一次
|
|
|
+ if (Can_index >=100)//Can 1s 调用一次
|
|
|
{
|
|
|
PROC_CAN_STATE_SWITCH(PROCESS_CAN_STATE_RECV);
|
|
|
Can_index = 0;
|
|
@@ -271,7 +289,7 @@ static void Main_Task(void* arg)
|
|
|
{
|
|
|
sleep_index = 0;
|
|
|
}
|
|
|
- if (sleep_index >=6000)
|
|
|
+ if (sleep_index >=sleep_time_flag)
|
|
|
{
|
|
|
PROC_MAIN_STATE_SWITCH(PROCESS_STATE_SLEEP);
|
|
|
sleep_index = 0;
|
|
@@ -316,7 +334,7 @@ static void Main_Task(void* arg)
|
|
|
#ifdef USING_PRINTF
|
|
|
printf("which slpstate can go now :%d \n",slpstate);
|
|
|
#endif
|
|
|
- slpManDeepSlpTimerStart(deepslpTimerID, 60000);
|
|
|
+ slpManDeepSlpTimerStart(deepslpTimerID, Sleep_Time);
|
|
|
while(1)
|
|
|
{
|
|
|
osDelay(60000/portTICK_PERIOD_MS);
|
|
@@ -402,8 +420,6 @@ uint8_t* Uart_Receive_func(Uart_Receive_Type Uart_Receive_Msg,uint8_t* Uart_Rece
|
|
|
}
|
|
|
if (isRecvComplete == true)
|
|
|
{
|
|
|
- #ifdef USING_PRINTF
|
|
|
- #endif
|
|
|
isRecvComplete = false;
|
|
|
CRC_Rece_buffer =*(Uart_Rece_buffer+Data_Len-1)<<8|*(Uart_Rece_buffer+Data_Len-2);
|
|
|
CRC_chk_buffer = crc_chk(Uart_Rece_buffer,Data_Len-2);
|
|
@@ -413,7 +429,7 @@ uint8_t* Uart_Receive_func(Uart_Receive_Type Uart_Receive_Msg,uint8_t* Uart_Rece
|
|
|
{
|
|
|
printf("%x ",*(Uart_Rece_buffer+i));
|
|
|
}
|
|
|
- printf("crcchk:%x,%x\n ",CRC_chk_buffer,CRC_Rece_buffer);
|
|
|
+ printf("\ncrcchk:%x,%x\n ",CRC_chk_buffer,CRC_Rece_buffer);
|
|
|
#endif
|
|
|
if (CRC_Rece_buffer == CRC_chk_buffer)//满足校验
|
|
|
{
|
|
@@ -422,8 +438,7 @@ uint8_t* Uart_Receive_func(Uart_Receive_Type Uart_Receive_Msg,uint8_t* Uart_Rece
|
|
|
else //接收数据的校验不过屏蔽
|
|
|
{
|
|
|
osDelay(2000);
|
|
|
- memset(Uart_Rece_buffer,0x00,Data_Len);
|
|
|
- USARTdrv->Initialize(USART_callback);
|
|
|
+ memset(Uart_Rece_buffer,0xff,Data_Len);
|
|
|
return Uart_Rece_buffer;
|
|
|
}
|
|
|
}
|
|
@@ -431,8 +446,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(100);
|
|
|
- USARTdrv->Initialize(USART_callback);
|
|
|
+ osDelay(1000);
|
|
|
return Uart_Rece_buffer;
|
|
|
}
|
|
|
|
|
@@ -516,6 +530,7 @@ static void Uart_Task(void* arg)
|
|
|
Data_Len = Uart_Receive_Msg.Reg_Num_L*2+5;
|
|
|
memset(Uart_Rece_buffer,0x00,Data_Len);
|
|
|
Uart_Rece_buffer = Uart_Receive_func(Uart_Receive_Msg,Uart_Rece_buffer,Data_Len);
|
|
|
+
|
|
|
Uart_Rece_BattI = *(Uart_Rece_buffer+3+0)<<8 |*(Uart_Rece_buffer+3+1);
|
|
|
break;
|
|
|
}
|
|
@@ -1084,7 +1099,7 @@ static void Tcp_Task(void* arg)
|
|
|
uint8_t NB_send_len;
|
|
|
appSetEDRXSettingSync(0,5,0);
|
|
|
appSetPSMSettingSync(1,3*60*60,10);
|
|
|
- appGetPSMSettingSync(&pmode,&tau,&act);
|
|
|
+
|
|
|
#ifdef USING_PRINTF
|
|
|
printf("psm:pmode-%d,tau-%d,act-%d!\n",pmode,tau,act);
|
|
|
#endif
|
|
@@ -1148,6 +1163,7 @@ static void Tcp_Task(void* arg)
|
|
|
#ifdef USING_PRINTF
|
|
|
printf("TCP_STATE_WORK!\n");
|
|
|
#endif
|
|
|
+ appGetPSMSettingSync(&pmode,&tau,&act);
|
|
|
#ifdef USING_PRINTF
|
|
|
printf("psm:pmode-%d,tau-%d,act-%d!\n",pmode,tau,act);
|
|
|
#endif
|
|
@@ -1332,9 +1348,9 @@ void appInit(void *arg)
|
|
|
{
|
|
|
Main_Task_Init();
|
|
|
Uart_Task_Init();
|
|
|
- Can_Task_Init();
|
|
|
- GpsTaskInit();
|
|
|
- Tcp_Task_Init();
|
|
|
+ //Can_Task_Init();
|
|
|
+ //GpsTaskInit();
|
|
|
+ //Tcp_Task_Init();
|
|
|
}
|
|
|
//主函数入口
|
|
|
void main_entry(void) {
|