Browse Source

Merge branch 'V2版本集成' into 发布版本

CHENJIE-PC\QiXiang_CHENJIE 3 years ago
parent
commit
d342a8739e
4 changed files with 43 additions and 42 deletions
  1. 2 2
      inc/app.h
  2. 2 20
      src/CANTask.c
  3. 14 7
      src/MainTask.c
  4. 25 13
      src/UartTask.c

+ 2 - 2
inc/app.h

@@ -43,8 +43,8 @@ extern "C" {
 #define HWVERSION		    0x0102    //硬件主版本,现为V1.2板
 #define	BLSWVERSION		0x01020000    //BootLoader版本号V1.2.0.0
 #define	DRVSWVERSION		0x01040000     //驱动层版本号V1.4.0.0
-//#define	APPSWVERSION		0x01020201     
-#define	APPSWVERSION		0x02000004
+//#define	APPSWVERSION		0x01020206     
+#define	APPSWVERSION		0x02000005
 //--------------------------------------------------------------------------------
 
 #define APP_CONFIG_FILE_LATEST_VERSION 0

+ 2 - 20
src/CANTask.c

@@ -118,25 +118,6 @@ static void Can_Receive()
 					{	
 						UDS_Service();
 						udsFlag = 0;							
-					}
-					if(Timer_count%10==0)
-					{
-						osMutexAcquire(UartMutex, osWaitForever);
-						CANSendBuffer.Id = 0x7A9;
-						CANSendBuffer.DLC = 8;
-						CANSendBuffer.Data[0] = UartReadMsg.data[(0x19+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2+1];
-						CANSendBuffer.Data[1] = UartReadMsg.data[(0x19+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2];
-						CANSendBuffer.Data[2] = UartReadMsg.data[(0x1A+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2+1];
-						CANSendBuffer.Data[3] = UartReadMsg.data[(0x1A+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2];
-						CANSendBuffer.Data[4] = UartReadMsg.data[(0x0B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2+1];
-						CANSendBuffer.Data[5] = UartReadMsg.data[(0x0B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2];
-						CANSendBuffer.Data[6] = 0x00;
-						CANSendBuffer.Data[7] = 0x00;
-						if(UartReadMsg.len>0)
-						{
-						HAL_Can_Transmit(CANSendBuffer);
-						}
-						osMutexRelease(UartMutex); 
 					}		
 					break;
 				}
@@ -148,7 +129,8 @@ static void Can_Receive()
 	            while(true)
 	            {
 	                osDelay(60000/portTICK_PERIOD_MS);
-	            }	            
+	            }
+				osThreadExit();	            
 	            break;
 	       }
 	   }

+ 14 - 7
src/MainTask.c

@@ -92,7 +92,10 @@ static void MainTask(void* arg)
     TimerHandle_t montior_timer = NULL;
     TimerHandle_t work_timer = NULL;
     slpManWakeSrc_e Wakeup_source;
-
+    Wakeup_source =  slpManGetWakeupSrc();//获取唤醒源
+    #ifdef USING_PRINTF
+        printf("Wakeup_source:%d \n",Wakeup_source);
+    #endif
 	appGetNVMSavedData();
     LoadAppDataInfo();
     #ifdef USING_PRINTF1
@@ -143,11 +146,11 @@ static void MainTask(void* arg)
 	AdcSendReq(ADC_REQ_BITMAP_INRES_CALI,&param,1,ADC_GET_RESULT_TIMOUT);
 
 	
-	NetSocDisplay(LED_SOC_0,LED_TURN_OFF);
-	NetSocDisplay(LED_SOC_1,LED_TURN_OFF);
-	NetSocDisplay(LED_SOC_2,LED_TURN_OFF);
-	NetSocDisplay(LED_SOC_3,LED_TURN_OFF);
-	FaultDisplay(LED_TURN_OFF);
+	// NetSocDisplay(LED_SOC_0,LED_TURN_OFF);
+	// NetSocDisplay(LED_SOC_1,LED_TURN_OFF);
+	// NetSocDisplay(LED_SOC_2,LED_TURN_OFF);
+	// NetSocDisplay(LED_SOC_3,LED_TURN_OFF);
+	// FaultDisplay(LED_TURN_OFF);
     PROC_MAIN_STATE_SWITCH(PROCESS_STATE_IDLE);
     while(true)
     {
@@ -172,6 +175,7 @@ static void MainTask(void* arg)
                     #endif
                     xTimerStop(montior_timer, 0);
                     PROC_MAIN_STATE_SWITCH(PROCESS_STATE_SLEEP);
+                    break;
                 }
                 if(TcpService!=0x00||UDSSwitch==1||BMS_Fota_update_flag)
                 {
@@ -235,8 +239,11 @@ static void MainTask(void* arg)
 				    slpManDeepSlpTimerStart(deepslpTimerID, AppNVMData.sleepTime*1000*60);
                     osDelay(1*60*1000/portTICK_PERIOD_MS);
                     sleeptime_count++;
-                    if(sleeptime_count>5)
+                    if(sleeptime_count>10)
                     {
+                        #ifdef USING_PRINTF
+                            printf("sleeptime_count :%d \n",sleeptime_count);
+                        #endif
                         EC_SystemReset();
                     }
                 }

+ 25 - 13
src/UartTask.c

@@ -58,7 +58,7 @@ static process_Uart             gProcess_Uart_Task = PROCESS_UART_STATE_IDLE;
 
 //函数声明区
 void USART_callback(uint32_t event);
-UINT8 Uart_Transmit_func(UINT8* Uart_Read_Msg,UINT8* Uart_Recv_Buffer);
+UINT8 Uart_DataRecv_func(UINT8* Uart_Read_Msg,UINT8* Uart_Recv_Buffer);
 UINT8 Uart_WriteCmd_func(Uart_Write_Data_Type UartWriteData);
 UINT16 crc_chk(UINT8* data, UINT8 length);
 void battSOCDisplay(void);
@@ -128,7 +128,7 @@ static void UartTask(void* arg)
                 else if(Timer_count%10==0)
                 {
                     #ifdef USING_PRINTF
-                        printf("[%d]Uart Timer 5s:%d\n",__LINE__,Timer_count);
+                        printf("[%d]Uart Timer 5s:%d,Header:%x\n",__LINE__,Timer_count,UartReadMsg.Header[2]);
                     #endif
                     if(osMessageQueueGet(UartWriteCmdHandle,&UartWriteData,0,0)==osOK)
                     {
@@ -179,7 +179,7 @@ static void UartTask(void* arg)
             }
             case PROCESS_UART_STATE_READ:
             {
-                osStatus_t result = osMutexAcquire(UartMutex, osWaitForever);
+				osStatus_t result = osMutexAcquire(UartMutex, osWaitForever);
                 Reg_Num = 0x21+BATT_CELL_VOL_NUM+BATT_TEMP_NUM + 2;//按照协议里面的0x21+X+N的结束地址
                 Uart_Read_Msg.Bms_Address = BMS_ADDRESS_CODE;
                 Uart_Read_Msg.Bms_Funcode = UART_READ_CODE;
@@ -188,8 +188,8 @@ static void UartTask(void* arg)
                 Uart_Read_Msg.Reg_Num_H = Reg_Num>>8;
                 Uart_Read_Msg.Reg_Num_L = Reg_Num;
                 Uart_Uds_LEN = Reg_Num*2;
-                memset(UartReadMsg.Header,0x00,Uart_Uds_LEN);
-                Uart_Recv_LEN = Uart_Transmit_func((UINT8 *)&Uart_Read_Msg,UartReadMsg.Header);
+                Uart_Recv_LEN = Uart_DataRecv_func((UINT8 *)&Uart_Read_Msg,UartReadMsg.Header);
+				osMutexRelease(UartMutex);
 				if(Uart_Recv_LEN>0)
 				{
 					UartReadMsg.UartFlag = TRUE;
@@ -216,7 +216,6 @@ static void UartTask(void* arg)
 					}
 					printf("\n");
 				#endif
-                osMutexRelease(UartMutex);
                 break;
             }
             case PROCESS_UART_STATE_WRITE:
@@ -237,6 +236,7 @@ static void UartTask(void* arg)
                 {
                     osDelay(60000/portTICK_PERIOD_MS);
                 }
+				osThreadExit();
                 break;
             }
         }
@@ -377,7 +377,7 @@ UINT8 Uart_WriteCmd_func(Uart_Write_Data_Type UartWriteData)
     }
 }
 //Uart发送接收函数
-UINT8 Uart_Transmit_func(UINT8* Uart_Read_Msg,UINT8* Uart_Recv_Buffer)
+UINT8 Uart_DataRecv_func(UINT8* Uart_Read_Msg,UINT8* Uart_Recv_Buffer)
 {
     UINT16 CRC_Rece_buffer;
     UINT16 CRC_chk_buffer;
@@ -397,18 +397,30 @@ UINT8 Uart_Transmit_func(UINT8* Uart_Read_Msg,UINT8* Uart_Recv_Buffer)
         printf("\n");
     #endif
     USARTdrv->Receive(Uart_Recv_Buffer,Data_Len);
-    while((isRecvTimeout == false) && (isRecvComplete == false))
+	while(true)
     {
+        
         timeout++;
-        osDelay(100);
-        if (timeout>=50)
+
+        if((isRecvTimeout == true) || (isRecvComplete == true))
         {
-            timeout =0;
-            isRecvTimeout = true;
             break;
         }
+        else
+        {
+            osDelay(100);
+            if (timeout>=50)
+            {
+                timeout =0;
+                isRecvTimeout = true;
+            }
+        } 
     }
-    #ifdef USING_PRINTF
+	#ifdef USING_PRINTF  
+             printf("%s[%d]\r\n",__FUNCTION__, __LINE__);
+             printf("timeout = %d\n",timeout);
+            #endif
+    #ifdef USING_PRINTF1
         printf("Uart_Rece_buffer: ");
         for(int i=0;i<Data_Len;i++)
         {