Browse Source

有一定几率重启

CHENJIE-PC\QiXiang_CHENJIE 4 years ago
parent
commit
1de3c597c7
2 changed files with 13 additions and 12 deletions
  1. 11 10
      src/app.c
  2. 2 2
      src/bsp_custom.c

+ 11 - 10
src/app.c

@@ -436,8 +436,8 @@ static void Uart_Task(void* arg)
     Uart_Receive_Type Uart_Receive_Msg;
     memset(&battbuffer[0],0x00,100);
 	PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_IDLE);
-    //slpManApplyPlatVoteHandle("UARTSLP",&UartSlpHandler);
-    //slpManPlatVoteDisableSleep(UartSlpHandler, SLP_SLP2_STATE); 
+    slpManApplyPlatVoteHandle("UARTSLP",&UartSlpHandler);
+    slpManPlatVoteDisableSleep(UartSlpHandler, SLP_SLP2_STATE); 
     Uart_Receive_Msg.Bms_Address = 0x01;
     Uart_Receive_Msg.Bms_Read_Funcode = 0x03;
     uint8_t *Uart_Rece_buffer = NULL;
@@ -456,12 +456,12 @@ static void Uart_Task(void* arg)
             }
             case PROCESS_UART_STATE_CHECK:
             {
+                Uart_Rece_buffer = (uint8_t *)malloc(Uart_Rece_LEN);
                 Uart_Receive_Msg.Reg_Begin_H = 0x00;
                 Uart_Receive_Msg.Reg_Begin_L= 0x02+Batt_Cell_Num;
                 Uart_Receive_Msg.Reg_Num_H = 0x00;
                 Uart_Receive_Msg.Reg_Num_L = 0x01;
                 Data_Len = Uart_Receive_Msg.Reg_Num_L*2+5;
-                Uart_Rece_buffer = (uint8_t *)malloc(Data_Len);
                 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);
@@ -592,7 +592,7 @@ static void Uart_Task(void* arg)
             }
             case PROCESS_UART_STATE_SLEEP:
             {
-                //slpManPlatVoteEnableSleep(UartSlpHandler, SLP_SLP2_STATE);
+                slpManPlatVoteEnableSleep(UartSlpHandler, SLP_SLP2_STATE);
                 #ifdef USING_PRINTF
                     printf("UART_STATE_SLEEP\n");
                 #endif
@@ -638,8 +638,8 @@ static void Can_Task(void* arg)
     HAL_Can_Init(param);
     int send_index = 0;
     uint16_t Batt_Cell_addU = 0x0000;
-    //slpManApplyPlatVoteHandle("CanSlp",&CanSlpHandler);
-    //slpManPlatVoteDisableSleep(CanSlpHandler, SLP_SLP2_STATE);
+    slpManApplyPlatVoteHandle("CanSlp",&CanSlpHandler);
+    slpManPlatVoteDisableSleep(CanSlpHandler, SLP_SLP2_STATE);
     volatile bool Can_Flag=false;
     PROC_CAN_STATE_SWITCH(PROCESS_CAN_STATE_IDLE);
     while(1)
@@ -666,6 +666,7 @@ static void Can_Task(void* arg)
                 }
                 else
                 {
+                    PROC_CAN_STATE_SWITCH(PROCESS_CAN_STATE_IDLE);
                     Can_Enable = false;
                 }
                 break;
@@ -819,7 +820,7 @@ static void Can_Task(void* arg)
             }
             case PROCESS_CAN_STATE_SLEEP:
             {
-                //slpManPlatVoteEnableSleep(CanSlpHandler, SLP_SLP2_STATE); 
+                slpManPlatVoteEnableSleep(CanSlpHandler, SLP_SLP2_STATE); 
                 #ifdef USING_PRINTF
                     printf("CAN_STATE_SLEEP\n");
                 #endif
@@ -979,8 +980,8 @@ static void Tcp_Task(void* arg)
     hints.ai_protocol = IPPROTO_TCP;
     psEventQueueHandle = xQueueCreate(APP_EVENT_QUEUE_SIZE, sizeof(eventCallbackMessage_t*));
     int NB_send_len=59+Batt_Cell_Num_2+Batt_Temp_Num;//设定tcp发送的最大数值,以电池数据为上线
-    //slpManApplyPlatVoteHandle("TcpSlp",&TcpSlpHandler);
-    //slpManPlatVoteDisableSleep(TcpSlpHandler, SLP_SLP2_STATE);
+    slpManApplyPlatVoteHandle("TcpSlp",&TcpSlpHandler);
+    slpManPlatVoteDisableSleep(TcpSlpHandler, SLP_SLP2_STATE);
     PROC_TCP_STATE_SWITCH(PROCESS_TCP_STATE_IDLE);
     uint8_t Tcp_Index = 0;
     uint8_t* TcpSendBuffer=NULL;
@@ -1109,7 +1110,7 @@ static void Tcp_Task(void* arg)
             }
             case PROCESS_TCP_STATE_SLEEP:
             {
-                //slpManPlatVoteEnableSleep(TcpSlpHandler, SLP_SLP2_STATE); 
+                slpManPlatVoteEnableSleep(TcpSlpHandler, SLP_SLP2_STATE); 
                 closesocket(sockfd);
                 deregisterPSEventCallback(socketRegisterPSUrcCallback);//注销NB网络事件函数
                 #ifdef USING_PRINTF

+ 2 - 2
src/bsp_custom.c

@@ -109,8 +109,8 @@ static void PMU_WakeupPadInit(void)
 {
     const padWakeupSettings_t cfg =
     {
-        true, true,             // group0 posedge, negedge
-        false, false,             // group1 posedge, negedge
+        false, true,             // group0 posedge, negedge
+        true, true,             // group1 posedge, negedge
         false, false,             // group2 posedge, negedge
     };