3 Commits cf63bf1cfd ... b8cf0f7b38

Author SHA1 Message Date
  CHENJIE-PC\QiXiang_CHENJIE b8cf0f7b38 充电重启不允许充电更改 2 years ago
  CHENJIE-PC\QiXiang_CHENJIE 707a58a106 【V3.1.242.65】故障清除Bug修复 2 years ago
  CHENJIE-PC\QiXiang_CHENJIE 74b236f465 【V3.1.243.65】加热逻辑更改,故障清除更改,测试版本 2 years ago

+ 2 - 2
inc/AppConfig.h

@@ -2,7 +2,7 @@
  * @Author       : ChenJie
  * @Date         : 2021-10-14 09:27:15
  * @LastEditors  : ChenJie
- * @LastEditTime : 2022-01-01 21:03:45
+ * @LastEditTime : 2022-01-04 16:06:32
  * @Description  : App Config H file 配置文件,可以针对不同参数进行更改
  * @FilePath     : \PLAT\project\ec616_0h00\apps\qx_app\inc\AppConfig.h
  */
@@ -16,7 +16,7 @@
 #define DEFAULT_SN "RLTEST00000000001" //默认上传的SN编码
 
 #define APPSWRELEASE 0          //软件测试版本标志位,0-测试,1-发布
-#define APPSWVERSION 0x0301F441 //数据模块软件版本号
+#define APPSWVERSION 0x0301F241 //数据模块软件版本号
 
 #define RELAYCONFIG 1              //继电器配置
 #define TCP_ADD "iotp.fast-fun.cn" //数据上传的地址

+ 2 - 1
src/AppTaskTcp.c

@@ -880,12 +880,13 @@ static void TcpDataInfoRecvHandle()
                     MEMCPY(AppDataInfo.ExpiryTimeArray, ExpiryUTC8TimeArray, 6);
                     AppDataInfo.appDataModify = TRUE;
                     tcpipConnectionSend(socContext.id, TcpCmdAnswer, 31, 0, 0, 0);
-#ifdef USING_PRINTF
+#ifdef USING_PRINTF1
                     printf("rental!\n");
                     for (UINT8 i = 0; i < 6; i++)
                         printf("%d  ", ExpiryUTC8TimeArray[i]);
 #endif
                     BattLockFunc();
+                    ihd_flg_DTCClear = 1;
                 }
                 else
                 {

+ 196 - 192
src/AppTaskUart.c

@@ -2,7 +2,7 @@
  * @Author       : ChenJie
  * @Date         : 2021-10-14 09:27:15
  * @LastEditors  : ChenJie
- * @LastEditTime : 2021-11-16 21:38:19
+ * @LastEditTime : 2022-01-04 18:36:45
  * @Description  : file content
  * @FilePath     : \PLAT\project\ec616_0h00\apps\qx_app\src\AppTaskUart.c
  */
@@ -38,7 +38,7 @@ static void UartTask(void *arg)
 	UINT8 ret = 0x00;
 	UINT8 EncryptFlag = 0x00;
 	UINT8 EncryptCount = 0;
-	if (UartWriteCmdHandle == NULL) //Uart控制命令传输指针
+	if (UartWriteCmdHandle == NULL) // Uart控制命令传输指针
 	{
 		UartWriteCmdHandle = osMessageQueueNew(1, sizeof(UartWriteData_S), NULL);
 	}
@@ -92,7 +92,7 @@ static void UartTask(void *arg)
 
 			if (TimeCounter % 10 == 0 && gProcess_app == WORK)
 			{
-				//ECOMM_TRACE(UNILOG_PLA_APP, UartAppTask_83, P_SIG, 0, "Uart work begin:%02x", PadInterrupt);
+				// ECOMM_TRACE(UNILOG_PLA_APP, UartAppTask_83, P_SIG, 0, "Uart work begin:%02x", PadInterrupt);
 				memset(&(UartWriteDataHandleRecv), 0x00, sizeof(UartWriteDataHandleRecv));
 				if (osMessageQueueGet(UartWriteCmdHandle, &UartWriteDataHandleRecv, 0, 10) == osOK && UartRecvFlag == 1)
 				{
@@ -278,7 +278,7 @@ static UINT8 Uart_WriteCmd_func(UartWriteData_S UartWriteData)
 void Uart_Cmd_Control(QueueHandle_t UartWriteCmdHandle, UartBuffer UartAnswerData)
 {
 	UartWriteData_S UartWriteData;
-	memset(&(UartWriteData), 0x00, sizeof(UartWriteData_S)); //Uart控制命令初始化
+	memset(&(UartWriteData), 0x00, sizeof(UartWriteData_S)); // Uart控制命令初始化
 	UINT8 HeatSwitch = 0;
 	UINT8 ChargePermitState = 1;
 	UINT8 DischargePermitState = 1;
@@ -295,7 +295,7 @@ void Uart_Cmd_Control(QueueHandle_t UartWriteCmdHandle, UartBuffer UartAnswerDat
 	//控制充电禁止
 	if (getbit(BcuFltAct, 6) == 0)
 	{
-		if ((maxCellVol > 4190 && maxCellVol < 5000) && battSOC >= 99)
+		if (maxCellVol > 4190 && maxCellVol < 5000 && BattWorkStateDelay == BATT_CHARGE_SYM)
 		{
 			ChargeForbiddenControl = 1;
 		}
@@ -303,6 +303,10 @@ void Uart_Cmd_Control(QueueHandle_t UartWriteCmdHandle, UartBuffer UartAnswerDat
 		{
 			ChargeForbiddenControl = 0;
 		}
+		else if (maxCellVol > 4150 && maxCellVol < 5000 && BattWorkStateDelay == BATT_IDLE_SYM)
+		{
+			ChargeForbiddenControl = 1;
+		}
 	}
 	else if (getbit(BcuFltAct, 6) == 1)
 	{
@@ -343,13 +347,13 @@ void Uart_Cmd_Control(QueueHandle_t UartWriteCmdHandle, UartBuffer UartAnswerDat
 			}
 		}
 	}
-	else if (RelayForceControl == 1) //close
+	else if (RelayForceControl == 1) // close
 	{
 		RelayForbiddenControl = 0;
 		AppDataInfo.appDataModify = TRUE;
 		AppDataInfo.RelayControl = FALSE;
 	}
-	else if (RelayForceControl == 2) //open
+	else if (RelayForceControl == 2) // open
 	{
 		RelayForbiddenControl = 1;
 		AppDataInfo.appDataModify = TRUE;
@@ -363,7 +367,7 @@ void Uart_Cmd_Control(QueueHandle_t UartWriteCmdHandle, UartBuffer UartAnswerDat
 		UartWriteData.Data[1] = HeatSwitch & 0xFF;
 		osMessageQueuePut(UartWriteCmdHandle, &UartWriteData, 0, 10);
 	}
-	if (ChargeForbiddenControl == 0x01 && (ChargePermitState != 0x00)) //try to lock lock the charge
+	if (ChargeForbiddenControl == 0x01 && (ChargePermitState != 0x00)) // try to lock lock the charge
 	{
 #ifdef USING_PRINTF1
 		printf("[%d]try to lock charge \n", __LINE__);
@@ -373,7 +377,7 @@ void Uart_Cmd_Control(QueueHandle_t UartWriteCmdHandle, UartBuffer UartAnswerDat
 		UartWriteData.Data[1] = 0x00 | DischargePermitState;
 		osMessageQueuePut(UartWriteCmdHandle, &UartWriteData, 0, 10);
 	}
-	else if ((ChargeForbiddenControl == 0x00) && (ChargePermitState != 0x01) && (ChargeProtectState == 0)) //try to unlock lock the charge,
+	else if ((ChargeForbiddenControl == 0x00) && (ChargePermitState != 0x01) && (ChargeProtectState == 0)) // try to unlock lock the charge,
 	{
 #ifdef USING_PRINTF1
 		printf("[%d]try to unlock charge \n", __LINE__);
@@ -383,7 +387,7 @@ void Uart_Cmd_Control(QueueHandle_t UartWriteCmdHandle, UartBuffer UartAnswerDat
 		UartWriteData.Data[1] = 0x02 | DischargePermitState;
 		osMessageQueuePut(UartWriteCmdHandle, &UartWriteData, 0, 10);
 	}
-	if ((BattWorkStateDelay == BATT_IDLE_SYM) && (DisChargeForbiddenControl == 1) && (DischargePermitState) != 0x00) //try to lock lock the discharge
+	if ((BattWorkStateDelay == BATT_IDLE_SYM) && (DisChargeForbiddenControl == 1) && (DischargePermitState) != 0x00) // try to lock lock the discharge
 	{
 		UartWriteData.WriteCmd = 0x01;
 		UartWriteData.Data[0] = (RelayControlState << 7) | 0x00;
@@ -574,8 +578,8 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 	UINT32 currentPackageStartAddr = 0;
 	BMS_Update_Recv_Msg_Type pUpdateMsgRecv;
 	UINT8 bmsUpdateFlag = 1;
-	//BMS_Update_Recv_Msg_Type bmsMsg;
-	//static UpdateStep step = UPDATE_STEP_CHECK_VERSION;
+	// BMS_Update_Recv_Msg_Type bmsMsg;
+	// static UpdateStep step = UPDATE_STEP_CHECK_VERSION;
 	UINT8 Cycle_conut = 0;
 	while (bmsUpdateFlag && Cycle_conut < 2)
 	{
@@ -585,17 +589,17 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 
 			dataLen = 0;
 			updateMsgSendLen = 7;
-			pUpdateMsgSend[0] = 0xEB; //start flag
-			pUpdateMsgSend[1] = 0x01; //add flag
-			pUpdateMsgSend[2] = 0x01; //read
-			pUpdateMsgSend[3] = 0x03; //data len
-			pUpdateMsgSend[4] = 0x90; //cmd
-			pUpdateMsgSend[5] = 0x93; //checksum
-			pUpdateMsgSend[6] = 0xF5; //end flag
-			//printf("updateMsgSendLen0 = %x\n",updateMsgSendLen);
+			pUpdateMsgSend[0] = 0xEB; // start flag
+			pUpdateMsgSend[1] = 0x01; // add flag
+			pUpdateMsgSend[2] = 0x01; // read
+			pUpdateMsgSend[3] = 0x03; // data len
+			pUpdateMsgSend[4] = 0x90; // cmd
+			pUpdateMsgSend[5] = 0x93; // checksum
+			pUpdateMsgSend[6] = 0xF5; // end flag
+			// printf("updateMsgSendLen0 = %x\n",updateMsgSendLen);
 			memset((UINT8 *)(&pUpdateMsgRecv), 0, sizeof(BMS_Update_Recv_Msg_Type));
 			ret = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), sizeof(BMS_Update_Recv_Msg_Type), 500);
-			//printf("updateMsgSendLen1 = %x\n",updateMsgSendLen);
+			// printf("updateMsgSendLen1 = %x\n",updateMsgSendLen);
 			if (ret != 0)
 			{
 				if (pUpdateMsgRecv.startFlag == 0xEB && pUpdateMsgRecv.endFlag == 0xF5)
@@ -628,7 +632,7 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 				errorCount++;
 			}
 #ifdef USING_PRINTF1
-			//printf("update step:%d\n",updateStep);
+			// printf("update step:%d\n",updateStep);
 			printf("query:");
 
 			for (j = 0; j < updateMsgSendLen; j++)
@@ -655,14 +659,14 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 		case UPDATE_STEP_REQUEST_UPDATE:
 			dataLen = 1;
 			updateMsgSendLen = 8;
-			pUpdateMsgSend[0] = 0xEB; //start flag
-			pUpdateMsgSend[1] = 0x01; //add flag
-			pUpdateMsgSend[2] = 0x00; //write
-			pUpdateMsgSend[3] = 0x04; //data len
-			pUpdateMsgSend[4] = 0x80; //cmd
-			pUpdateMsgSend[5] = 0x22; //data
-			pUpdateMsgSend[6] = 0xA6; //check
-			pUpdateMsgSend[7] = 0xF5; //end flag
+			pUpdateMsgSend[0] = 0xEB; // start flag
+			pUpdateMsgSend[1] = 0x01; // add flag
+			pUpdateMsgSend[2] = 0x00; // write
+			pUpdateMsgSend[3] = 0x04; // data len
+			pUpdateMsgSend[4] = 0x80; // cmd
+			pUpdateMsgSend[5] = 0x22; // data
+			pUpdateMsgSend[6] = 0xA6; // check
+			pUpdateMsgSend[7] = 0xF5; // end flag
 			memset((UINT8 *)(&pUpdateMsgRecv), 0, sizeof(BMS_Update_Recv_Msg_Type));
 			ret = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), sizeof(BMS_Update_Recv_Msg_Type), 500);
 			if (ret != 0)
@@ -723,18 +727,18 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 		case UPDATE_STEP_START_UPDATE:
 			dataLen = 1;
 			updateMsgSendLen = 8;
-			pUpdateMsgSend[0] = 0xEB; //start flag
-			pUpdateMsgSend[1] = 0x01; //add flag
-			pUpdateMsgSend[2] = 0x00; //write
-			pUpdateMsgSend[3] = 0x04; //data len
-			pUpdateMsgSend[4] = 0x80; //cmd
-			pUpdateMsgSend[5] = 0x55; //data
-			pUpdateMsgSend[6] = 0xD9; //check
-			pUpdateMsgSend[7] = 0xF5; //end flag
+			pUpdateMsgSend[0] = 0xEB; // start flag
+			pUpdateMsgSend[1] = 0x01; // add flag
+			pUpdateMsgSend[2] = 0x00; // write
+			pUpdateMsgSend[3] = 0x04; // data len
+			pUpdateMsgSend[4] = 0x80; // cmd
+			pUpdateMsgSend[5] = 0x55; // data
+			pUpdateMsgSend[6] = 0xD9; // check
+			pUpdateMsgSend[7] = 0xF5; // end flag
 			memset((UINT8 *)(&pUpdateMsgRecv), 0, sizeof(BMS_Update_Recv_Msg_Type));
 			ret = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), 0, 500);
-			//updateStep = UPDATE_STEP_SET_BAUD_RATE;
-			updateStep = UPDATE_STEP_CHECK_VERSION_AGAIN; //2021-04-09跳过波特率设置
+			// updateStep = UPDATE_STEP_SET_BAUD_RATE;
+			updateStep = UPDATE_STEP_CHECK_VERSION_AGAIN; // 2021-04-09跳过波特率设置
 #ifdef USING_PRINTF1
 
 			printf("query:");
@@ -755,17 +759,17 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 		case UPDATE_STEP_CHECK_VERSION_AGAIN:
 			dataLen = 0;
 			updateMsgSendLen = 7;
-			pUpdateMsgSend[0] = 0xEB; //start flag
-			pUpdateMsgSend[1] = 0x01; //add flag
-			pUpdateMsgSend[2] = 0x01; //read
-			pUpdateMsgSend[3] = 0x03; //data len
-			pUpdateMsgSend[4] = 0x90; //cmd
-			pUpdateMsgSend[5] = 0x93; //checksum
-			pUpdateMsgSend[6] = 0xF5; //end flag
-			//printf("updateMsgSendLen0 = %x\n",updateMsgSendLen);
+			pUpdateMsgSend[0] = 0xEB; // start flag
+			pUpdateMsgSend[1] = 0x01; // add flag
+			pUpdateMsgSend[2] = 0x01; // read
+			pUpdateMsgSend[3] = 0x03; // data len
+			pUpdateMsgSend[4] = 0x90; // cmd
+			pUpdateMsgSend[5] = 0x93; // checksum
+			pUpdateMsgSend[6] = 0xF5; // end flag
+			// printf("updateMsgSendLen0 = %x\n",updateMsgSendLen);
 			memset((UINT8 *)(&pUpdateMsgRecv), 0, sizeof(BMS_Update_Recv_Msg_Type));
 			ret = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), sizeof(BMS_Update_Recv_Msg_Type), 100);
-			//printf("updateMsgSendLen1 = %x\n",updateMsgSendLen);
+			// printf("updateMsgSendLen1 = %x\n",updateMsgSendLen);
 			if (ret != 0)
 			{
 				if (pUpdateMsgRecv.startFlag == 0xEB && pUpdateMsgRecv.endFlag == 0xF5)
@@ -798,7 +802,7 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 				errorCount++;
 			}
 #ifdef USING_PRINTF1
-			//printf("update step:%d\n",updateStep);
+			// printf("update step:%d\n",updateStep);
 			printf("query:");
 
 			for (j = 0; j < updateMsgSendLen; j++)
@@ -825,18 +829,18 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 			printf("start step %d\n", updateStep);
 			dataLen = 4;
 			updateMsgSendLen = 12;
-			pUpdateMsgSend[0] = 0xEB; //start flag
-			pUpdateMsgSend[1] = 0x01; //add flag
-			pUpdateMsgSend[2] = 0x00; //write
-			pUpdateMsgSend[3] = 0x08; //data len
-			pUpdateMsgSend[4] = 0x81; //cmd
-			pUpdateMsgSend[5] = 0x33; //data
-			pUpdateMsgSend[6] = 0x00; //baud rate:9600
+			pUpdateMsgSend[0] = 0xEB; // start flag
+			pUpdateMsgSend[1] = 0x01; // add flag
+			pUpdateMsgSend[2] = 0x00; // write
+			pUpdateMsgSend[3] = 0x08; // data len
+			pUpdateMsgSend[4] = 0x81; // cmd
+			pUpdateMsgSend[5] = 0x33; // data
+			pUpdateMsgSend[6] = 0x00; // baud rate:9600
 			pUpdateMsgSend[7] = 0x00;
 			pUpdateMsgSend[8] = 0x25;
 			pUpdateMsgSend[9] = 0x80;
-			pUpdateMsgSend[10] = 0x61; //check
-			pUpdateMsgSend[11] = 0xF5; //end flag
+			pUpdateMsgSend[10] = 0x61; // check
+			pUpdateMsgSend[11] = 0xF5; // end flag
 #ifdef USING_PRINTF1
 			printf("query:");
 			for (j = 0; j < updateMsgSendLen; j++)
@@ -886,7 +890,7 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 			}
 
 #ifdef USING_PRINTF1
-			//printf("update step:%d\n",updateStep);
+			// printf("update step:%d\n",updateStep);
 			printf("query:");
 			for (j = 0; j < updateMsgSendLen; j++)
 			{
@@ -907,14 +911,14 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 			printf("start step %d\n", updateStep);
 			dataLen = 1;
 			updateMsgSendLen = 8;
-			pUpdateMsgSend[0] = 0xEB; //start flag
-			pUpdateMsgSend[1] = 0x01; //add flag
-			pUpdateMsgSend[2] = 0x00; //write
-			pUpdateMsgSend[3] = 0x04; //data len
-			pUpdateMsgSend[4] = 0x81; //cmd
-			pUpdateMsgSend[5] = 0x44; //data
-			pUpdateMsgSend[6] = 0xC9; //check
-			pUpdateMsgSend[7] = 0xF5; //end flag
+			pUpdateMsgSend[0] = 0xEB; // start flag
+			pUpdateMsgSend[1] = 0x01; // add flag
+			pUpdateMsgSend[2] = 0x00; // write
+			pUpdateMsgSend[3] = 0x04; // data len
+			pUpdateMsgSend[4] = 0x81; // cmd
+			pUpdateMsgSend[5] = 0x44; // data
+			pUpdateMsgSend[6] = 0xC9; // check
+			pUpdateMsgSend[7] = 0xF5; // end flag
 			memset((UINT8 *)(&pUpdateMsgRecv), 0, sizeof(BMS_Update_Recv_Msg_Type));
 			ret = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), sizeof(BMS_Update_Recv_Msg_Type), 500);
 			if (ret != 0)
@@ -955,7 +959,7 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 			}
 
 #ifdef USING_PRINTF1
-			//printf("update step:%d\n",updateStep);
+			// printf("update step:%d\n",updateStep);
 			printf("query:");
 			for (j = 0; j < updateMsgSendLen; j++)
 			{
@@ -977,17 +981,17 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 			BSP_QSPI_Read_Safe(&updateDataTotalByteLen, FLASH_BMS_FOTA_START_ADDR, 4);
 			updateDataTotalByteLen = (((updateDataTotalByteLen)&0xFF) << 24) | (((updateDataTotalByteLen >> 8) & 0xFF) << 16) | (((updateDataTotalByteLen >> 16) & 0xFF) << 8) | (((updateDataTotalByteLen >> 24) & 0xFF));
 			updateMsgSendLen = 11;
-			pUpdateMsgSend[0] = 0xEB;								   //start flag
-			pUpdateMsgSend[1] = 0x01;								   //add flag
-			pUpdateMsgSend[2] = 0x00;								   //write
-			pUpdateMsgSend[3] = 0x07;								   //data len
-			pUpdateMsgSend[4] = 0x82;								   //cmd
-			pUpdateMsgSend[5] = (updateDataTotalByteLen >> 24) & 0xFF; //data: package byte len
+			pUpdateMsgSend[0] = 0xEB;								   // start flag
+			pUpdateMsgSend[1] = 0x01;								   // add flag
+			pUpdateMsgSend[2] = 0x00;								   // write
+			pUpdateMsgSend[3] = 0x07;								   // data len
+			pUpdateMsgSend[4] = 0x82;								   // cmd
+			pUpdateMsgSend[5] = (updateDataTotalByteLen >> 24) & 0xFF; // data: package byte len
 			pUpdateMsgSend[6] = (updateDataTotalByteLen >> 16) & 0xFF;
 			pUpdateMsgSend[7] = (updateDataTotalByteLen >> 8) & 0xFF;
 			pUpdateMsgSend[8] = (updateDataTotalByteLen)&0xFF;
-			pUpdateMsgSend[9] = SP_BMS_Update_CheckSUM(&pUpdateMsgSend[3], dataLen + 2); //check sum
-			pUpdateMsgSend[10] = 0xF5;													 //end flag
+			pUpdateMsgSend[9] = SP_BMS_Update_CheckSUM(&pUpdateMsgSend[3], dataLen + 2); // check sum
+			pUpdateMsgSend[10] = 0xF5;													 // end flag
 
 			memset((UINT8 *)(&pUpdateMsgRecv), 0, sizeof(BMS_Update_Recv_Msg_Type));
 			ret = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), sizeof(BMS_Update_Recv_Msg_Type), 500);
@@ -1029,7 +1033,7 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 			}
 
 #ifdef USING_PRINTF1
-			//printf("update step:%d\n",updateStep);
+			// printf("update step:%d\n",updateStep);
 			printf("query:");
 			for (j = 0; j < updateMsgSendLen; j++)
 			{
@@ -1049,14 +1053,14 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 		case UPDATE_STEP_PREPARE_SEND_UPDATE_DATA:
 			dataLen = 1;
 			updateMsgSendLen = 8;
-			pUpdateMsgSend[0] = 0xEB; //start flag
-			pUpdateMsgSend[1] = 0x01; //add flag
-			pUpdateMsgSend[2] = 0x00; //write
-			pUpdateMsgSend[3] = 0x04; //data len
-			pUpdateMsgSend[4] = 0x81; //cmd
-			pUpdateMsgSend[5] = 0x55; //data
-			pUpdateMsgSend[6] = 0xDA; //check
-			pUpdateMsgSend[7] = 0xF5; //end flag
+			pUpdateMsgSend[0] = 0xEB; // start flag
+			pUpdateMsgSend[1] = 0x01; // add flag
+			pUpdateMsgSend[2] = 0x00; // write
+			pUpdateMsgSend[3] = 0x04; // data len
+			pUpdateMsgSend[4] = 0x81; // cmd
+			pUpdateMsgSend[5] = 0x55; // data
+			pUpdateMsgSend[6] = 0xDA; // check
+			pUpdateMsgSend[7] = 0xF5; // end flag
 			memset((UINT8 *)(&pUpdateMsgRecv), 0, sizeof(BMS_Update_Recv_Msg_Type));
 			ret = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), sizeof(BMS_Update_Recv_Msg_Type), 500);
 			if (ret != 0)
@@ -1097,7 +1101,7 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 			}
 
 #ifdef USING_PRINTF1
-			//printf("update step:%d\n",updateStep);
+			// printf("update step:%d\n",updateStep);
 			printf("query:");
 			for (j = 0; j < updateMsgSendLen; j++)
 			{
@@ -1121,18 +1125,18 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 			{
 				currentPackageStartAddr = currentPackage * 64;
 
-				pUpdateMsgSend[0] = 0xEB; //start flag
-				pUpdateMsgSend[1] = 0x01; //add flag
-				pUpdateMsgSend[2] = 0x00; //write
-				pUpdateMsgSend[3] = 0x47; //data len
-				pUpdateMsgSend[4] = 0x82; //cmd
+				pUpdateMsgSend[0] = 0xEB; // start flag
+				pUpdateMsgSend[1] = 0x01; // add flag
+				pUpdateMsgSend[2] = 0x00; // write
+				pUpdateMsgSend[3] = 0x47; // data len
+				pUpdateMsgSend[4] = 0x82; // cmd
 				pUpdateMsgSend[5] = (currentPackageStartAddr >> 24) & 0xFF;
 				pUpdateMsgSend[6] = (currentPackageStartAddr >> 16) & 0xFF;
 				pUpdateMsgSend[7] = (currentPackageStartAddr >> 8) & 0xFF;
 				pUpdateMsgSend[8] = currentPackageStartAddr & 0xFF;
-				BSP_QSPI_Read_Safe(&pUpdateMsgSend[9], FLASH_BMS_FOTA_START_ADDR + 4 + currentPackage * dataLen, dataLen); //data
-				pUpdateMsgSend[8 + dataLen + 1] = SP_BMS_Update_CheckSUM(&pUpdateMsgSend[3], dataLen + 6);				   //check sum
-				pUpdateMsgSend[8 + dataLen + 2] = 0xF5;																	   //end flag
+				BSP_QSPI_Read_Safe(&pUpdateMsgSend[9], FLASH_BMS_FOTA_START_ADDR + 4 + currentPackage * dataLen, dataLen); // data
+				pUpdateMsgSend[8 + dataLen + 1] = SP_BMS_Update_CheckSUM(&pUpdateMsgSend[3], dataLen + 6);				   // check sum
+				pUpdateMsgSend[8 + dataLen + 2] = 0xF5;																	   // end flag
 				memset((UINT8 *)(&pUpdateMsgRecv), 0, sizeof(BMS_Update_Recv_Msg_Type));
 				ret = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), sizeof(BMS_Update_Recv_Msg_Type), 500);
 				if (ret != 0)
@@ -1176,7 +1180,7 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 					break;
 				}
 #ifdef USING_PRINTF1
-				//printf("update step:%d\n",updateStep);
+				// printf("update step:%d\n",updateStep);
 				printf("query:");
 				for (j = 0; j < updateMsgSendLen; j++)
 				{
@@ -1197,14 +1201,14 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 		case UPDATE_STEP_SEND_DATA_END:
 			dataLen = 1;
 			updateMsgSendLen = 8;
-			pUpdateMsgSend[0] = 0xEB; //start flag
-			pUpdateMsgSend[1] = 0x01; //add flag
-			pUpdateMsgSend[2] = 0x00; //write
-			pUpdateMsgSend[3] = 0x04; //data len
-			pUpdateMsgSend[4] = 0x81; //cmd
-			pUpdateMsgSend[5] = 0x66; //data
-			pUpdateMsgSend[6] = 0xEB; //check
-			pUpdateMsgSend[7] = 0xF5; //end flag
+			pUpdateMsgSend[0] = 0xEB; // start flag
+			pUpdateMsgSend[1] = 0x01; // add flag
+			pUpdateMsgSend[2] = 0x00; // write
+			pUpdateMsgSend[3] = 0x04; // data len
+			pUpdateMsgSend[4] = 0x81; // cmd
+			pUpdateMsgSend[5] = 0x66; // data
+			pUpdateMsgSend[6] = 0xEB; // check
+			pUpdateMsgSend[7] = 0xF5; // end flag
 			memset((UINT8 *)(&pUpdateMsgRecv), 0, sizeof(BMS_Update_Recv_Msg_Type));
 			ret = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), sizeof(BMS_Update_Recv_Msg_Type), 500);
 			if (ret != 0)
@@ -1245,7 +1249,7 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 			}
 
 #ifdef USING_PRINTF1
-			//printf("update step:%d\n",updateStep);
+			// printf("update step:%d\n",updateStep);
 			printf("query:");
 			for (j = 0; j < updateMsgSendLen; j++)
 			{
@@ -1265,21 +1269,21 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 		case UPDATE_STEP_START_INSTALL:
 			dataLen = 1;
 			updateMsgSendLen = 8;
-			pUpdateMsgSend[0] = 0xEB; //start flag
-			pUpdateMsgSend[1] = 0x01; //add flag
-			pUpdateMsgSend[2] = 0x00; //write
-			pUpdateMsgSend[3] = 0x04; //data len
-			pUpdateMsgSend[4] = 0x81; //cmd
-			pUpdateMsgSend[5] = 0x99; //data
-			pUpdateMsgSend[6] = 0x1E; //check
-			pUpdateMsgSend[7] = 0xF5; //end flag
+			pUpdateMsgSend[0] = 0xEB; // start flag
+			pUpdateMsgSend[1] = 0x01; // add flag
+			pUpdateMsgSend[2] = 0x00; // write
+			pUpdateMsgSend[3] = 0x04; // data len
+			pUpdateMsgSend[4] = 0x81; // cmd
+			pUpdateMsgSend[5] = 0x99; // data
+			pUpdateMsgSend[6] = 0x1E; // check
+			pUpdateMsgSend[7] = 0xF5; // end flag
 			memset((UINT8 *)(&pUpdateMsgRecv), 0, sizeof(BMS_Update_Recv_Msg_Type));
 			UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), 0, 500);
 
 			updateStep = UPDATE_STEP_END;
 
 #ifdef USING_PRINTF1
-			//printf("update step:%d\n",updateStep);
+			// printf("update step:%d\n",updateStep);
 			printf("query:");
 			for (j = 0; j < updateMsgSendLen; j++)
 			{
@@ -1303,14 +1307,14 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 		case UPDATE_STEP_RESET:
 			dataLen = 1;
 			updateMsgSendLen = 8;
-			pUpdateMsgSend[0] = 0xEB; //start flag
-			pUpdateMsgSend[1] = 0x01; //add flag
-			pUpdateMsgSend[2] = 0x00; //write
-			pUpdateMsgSend[3] = 0x04; //data len
-			pUpdateMsgSend[4] = 0x81; //cmd
-			pUpdateMsgSend[5] = 0xAA; //data
-			pUpdateMsgSend[6] = 0x2F; //check
-			pUpdateMsgSend[7] = 0xF5; //end flag
+			pUpdateMsgSend[0] = 0xEB; // start flag
+			pUpdateMsgSend[1] = 0x01; // add flag
+			pUpdateMsgSend[2] = 0x00; // write
+			pUpdateMsgSend[3] = 0x04; // data len
+			pUpdateMsgSend[4] = 0x81; // cmd
+			pUpdateMsgSend[5] = 0xAA; // data
+			pUpdateMsgSend[6] = 0x2F; // check
+			pUpdateMsgSend[7] = 0xF5; // end flag
 			memset((UINT8 *)(&pUpdateMsgRecv), 0, sizeof(BMS_Update_Recv_Msg_Type));
 			UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), 0, 500);
 			osDelay(50);
@@ -1332,14 +1336,14 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 		case UPDATE_STEP_DOWNLOAD_BREAK_OFF:
 			dataLen = 1;
 			updateMsgSendLen = 8;
-			pUpdateMsgSend[0] = 0xEB; //start flag
-			pUpdateMsgSend[1] = 0x01; //add flag
-			pUpdateMsgSend[2] = 0x00; //write
-			pUpdateMsgSend[3] = 0x04; //data len
-			pUpdateMsgSend[4] = 0x81; //cmd
-			pUpdateMsgSend[5] = 0xBB; //data
-			pUpdateMsgSend[6] = 0x40; //check
-			pUpdateMsgSend[7] = 0xF5; //end flag
+			pUpdateMsgSend[0] = 0xEB; // start flag
+			pUpdateMsgSend[1] = 0x01; // add flag
+			pUpdateMsgSend[2] = 0x00; // write
+			pUpdateMsgSend[3] = 0x04; // data len
+			pUpdateMsgSend[4] = 0x81; // cmd
+			pUpdateMsgSend[5] = 0xBB; // data
+			pUpdateMsgSend[6] = 0x40; // check
+			pUpdateMsgSend[7] = 0xF5; // end flag
 			memset((UINT8 *)(&pUpdateMsgRecv), 0, sizeof(BMS_Update_Recv_Msg_Type));
 			UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), 0, 500);
 			osDelay(50);
@@ -1396,7 +1400,7 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
 	BOOL bmsUpdateFlag = TRUE;
 	UINT8 bmsAnswerMsg[8];
 
-	//static UpdateStep step = UPDATE_STEP_CHECK_VERSION;
+	// static UpdateStep step = UPDATE_STEP_CHECK_VERSION;
 	UINT8 Cycle_conut = 0;
 	UINT16 CRCtemp = 0;
 	UINT8 headerLen = 5;
@@ -1408,7 +1412,7 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
 	BSP_QSPI_Read_Safe(&checkSum, FLASH_BMS_FOTA_START_ADDR, 1);
 
 	memset(ReadNVMTemp, 0, 64);
-	BSP_QSPI_Read_Safe(ReadNVMTemp, FLASH_BMS_FOTA_START_ADDR + 1, 4); //data
+	BSP_QSPI_Read_Safe(ReadNVMTemp, FLASH_BMS_FOTA_START_ADDR + 1, 4); // data
 
 	updateDataTotalByteLen = ((ReadNVMTemp[0] << 24) & 0xFF000000) | ((ReadNVMTemp[1] << 16) & 0xFF0000) | ((ReadNVMTemp[2] << 8) & 0xFF00) | (ReadNVMTemp[3] & 0xFF);
 	updateDataPackageCount = (updateDataTotalByteLen + (64 - 1)) / 64; //进一法 e = (a+(b-1))/b
@@ -1459,19 +1463,19 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
 		switch (updateStep)
 		{
 
-		case MS_UPDATE_STEP_SEND_FIRMWARE_UPDATE_REQUEST_AND_JUMP_TO_BOOTLOADER: //0x01
+		case MS_UPDATE_STEP_SEND_FIRMWARE_UPDATE_REQUEST_AND_JUMP_TO_BOOTLOADER: // 0x01
 			dataLen = 0x00;
 			updateMsgSendLen = 6 + dataLen;
 			updateMsgReadLen = 8;
 
-			pUpdateMsgSend[0] = 0x01;		//node byte
-			pUpdateMsgSend[1] = 0x40;		//func byte
-			pUpdateMsgSend[2] = updateStep; //cmd byte
-			pUpdateMsgSend[3] = dataLen;	//data len
-											//no data type
+			pUpdateMsgSend[0] = 0x01;		// node byte
+			pUpdateMsgSend[1] = 0x40;		// func byte
+			pUpdateMsgSend[2] = updateStep; // cmd byte
+			pUpdateMsgSend[3] = dataLen;	// data len
+											// no data type
 			CRCtemp = MS_BMS_Update_CRC16(pUpdateMsgSend, 4);
 			pUpdateMsgSend[4] = (CRCtemp >> 8) & 0xFF; // CRC High
-			pUpdateMsgSend[5] = CRCtemp & 0xFF;		   //CRC Low
+			pUpdateMsgSend[5] = CRCtemp & 0xFF;		   // CRC Low
 
 			memset((UINT8 *)(bmsAnswerMsg), 0, 8);
 			ret0 = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(bmsAnswerMsg), updateMsgReadLen, 1000);
@@ -1488,11 +1492,11 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
 			{
 				if (bmsAnswerMsg[0] == 0x01 && bmsAnswerMsg[1] == 0x40) // node and func byte
 				{
-					if (bmsAnswerMsg[2] == MS_UPDATE_STEP_FIRMWARE_UPDATE_REQUEST_ANSWER && bmsAnswerMsg[3] == 0x02) //answer cmd byte:0x02, answer data len:0x02
+					if (bmsAnswerMsg[2] == MS_UPDATE_STEP_FIRMWARE_UPDATE_REQUEST_ANSWER && bmsAnswerMsg[3] == 0x02) // answer cmd byte:0x02, answer data len:0x02
 					{
-						if (bmsAnswerMsg[4] == 0x00) //answer data byte1
+						if (bmsAnswerMsg[4] == 0x00) // answer data byte1
 						{
-							if (bmsAnswerMsg[5] == 0x00) //answer data byte2
+							if (bmsAnswerMsg[5] == 0x00) // answer data byte2
 							{
 								updateStep = MS_UPDATE_STEP_SEND_FIRMWARE_INFO;
 								errorCount = 0;
@@ -1549,17 +1553,17 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
 			osDelay(50);
 			printf(" step 1 ret = %d\n", ret);
 			break;
-		case MS_UPDATE_STEP_SEND_FIRMWARE_INFO: //0x03
+		case MS_UPDATE_STEP_SEND_FIRMWARE_INFO: // 0x03
 			dataLen = 52;
 			updateMsgSendLen = 6 + dataLen;
 			updateMsgReadLen = 7;
-			pUpdateMsgSend[0] = 0x01;		//node byte
-			pUpdateMsgSend[1] = 0x40;		//func byte
-			pUpdateMsgSend[2] = updateStep; //cmd byte
-			pUpdateMsgSend[3] = dataLen;	//data len
+			pUpdateMsgSend[0] = 0x01;		// node byte
+			pUpdateMsgSend[1] = 0x40;		// func byte
+			pUpdateMsgSend[2] = updateStep; // cmd byte
+			pUpdateMsgSend[3] = dataLen;	// data len
 
 			memset(ReadNVMTemp, 0, 64);
-			BSP_QSPI_Read_Safe(ReadNVMTemp, FLASH_BMS_FOTA_START_ADDR + headerLen, 16); //data
+			BSP_QSPI_Read_Safe(ReadNVMTemp, FLASH_BMS_FOTA_START_ADDR + headerLen, 16); // data
 			MEMCPY(&pUpdateMsgSend[4], ReadNVMTemp, 16);								//厂家信息,未开启校验
 			MEMCPY(&pUpdateMsgSend[4 + 16], ReadNVMTemp, 16);							//保护板硬件序列号,未开启校验
 			pUpdateMsgSend[4 + 16 * 2 + 0] = (updateDataTotalByteLen >> 24) & 0xFF;		//固件包大小
@@ -1571,7 +1575,7 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
 			CRCtemp = MS_BMS_Update_CRC16(pUpdateMsgSend, 4 + dataLen);
 
 			pUpdateMsgSend[4 + dataLen] = (CRCtemp >> 8) & 0xFF; // CRC High
-			pUpdateMsgSend[5 + dataLen] = CRCtemp & 0xFF;		 //CRC Low
+			pUpdateMsgSend[5 + dataLen] = CRCtemp & 0xFF;		 // CRC Low
 
 			memset((UINT8 *)(bmsAnswerMsg), 0, 8);
 			ret0 = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(bmsAnswerMsg), updateMsgReadLen, 1000);
@@ -1587,9 +1591,9 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
 			{
 				if (bmsAnswerMsg[0] == 0x01 && bmsAnswerMsg[1] == 0x40) // node and func byte
 				{
-					if (bmsAnswerMsg[2] == MS_UPDATE_STEP_FIRMWARE_INFO_CHECK_AND_UPDATE_REQEST_ANSWER && bmsAnswerMsg[3] == 0x01) //answer cmd byte:0x04, answer data len:0x01
+					if (bmsAnswerMsg[2] == MS_UPDATE_STEP_FIRMWARE_INFO_CHECK_AND_UPDATE_REQEST_ANSWER && bmsAnswerMsg[3] == 0x01) // answer cmd byte:0x04, answer data len:0x01
 					{
-						if (bmsAnswerMsg[4] == 0x00) //answer data byte1
+						if (bmsAnswerMsg[4] == 0x00) // answer data byte1
 						{
 							updateStep = MS_UPDATE_STEP_EREASE_APP_FLASH_REQUEST;
 							errorCount = 0;
@@ -1642,19 +1646,19 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
 			printf(" step 3 ret = %d\n", ret);
 			osDelay(50);
 			break;
-		case MS_UPDATE_STEP_EREASE_APP_FLASH_REQUEST: //0x05
+		case MS_UPDATE_STEP_EREASE_APP_FLASH_REQUEST: // 0x05
 			dataLen = 0;
 			updateMsgSendLen = 6 + dataLen;
 			updateMsgReadLen = 8;
-			pUpdateMsgSend[0] = 0x01;		//node byte
-			pUpdateMsgSend[1] = 0x40;		//func byte
-			pUpdateMsgSend[2] = updateStep; //cmd byte
-			pUpdateMsgSend[3] = dataLen;	//data len
+			pUpdateMsgSend[0] = 0x01;		// node byte
+			pUpdateMsgSend[1] = 0x40;		// func byte
+			pUpdateMsgSend[2] = updateStep; // cmd byte
+			pUpdateMsgSend[3] = dataLen;	// data len
 
 			CRCtemp = MS_BMS_Update_CRC16(pUpdateMsgSend, 4 + dataLen);
 
 			pUpdateMsgSend[4 + dataLen] = (CRCtemp >> 8) & 0xFF; // CRC High
-			pUpdateMsgSend[5 + dataLen] = CRCtemp & 0xFF;		 //CRC Low
+			pUpdateMsgSend[5 + dataLen] = CRCtemp & 0xFF;		 // CRC Low
 
 			memset((UINT8 *)(bmsAnswerMsg), 0, 8);
 			ret0 = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(bmsAnswerMsg), updateMsgReadLen, 1000);
@@ -1670,11 +1674,11 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
 			{
 				if (bmsAnswerMsg[0] == 0x01 && bmsAnswerMsg[1] == 0x40) // node and func byte
 				{
-					if (bmsAnswerMsg[2] == MS_UPDATE_STEP_EREASE_FLASH_ANSWER && bmsAnswerMsg[3] == 0x02) //answer cmd byte:0x06, answer data len:0x02
+					if (bmsAnswerMsg[2] == MS_UPDATE_STEP_EREASE_FLASH_ANSWER && bmsAnswerMsg[3] == 0x02) // answer cmd byte:0x06, answer data len:0x02
 					{
-						if (bmsAnswerMsg[4] == 0x00) //answer data byte1, erease successed
+						if (bmsAnswerMsg[4] == 0x00) // answer data byte1, erease successed
 						{
-							updateStep = MS_UPDATE_STEP_SEND_UPDATE_DATA; //0x07
+							updateStep = MS_UPDATE_STEP_SEND_UPDATE_DATA; // 0x07
 							errorCount = 0;
 						}
 						else if (bmsAnswerMsg[4] == 0x01) //擦除失败
@@ -1709,12 +1713,12 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
 			}
 			osDelay(50);
 			break;
-		case MS_UPDATE_STEP_SEND_UPDATE_DATA: //0x07
+		case MS_UPDATE_STEP_SEND_UPDATE_DATA: // 0x07
 
 			updateMsgReadLen = 7;
-			pUpdateMsgSend[0] = 0x01;		//node byte
-			pUpdateMsgSend[1] = 0x40;		//func byte
-			pUpdateMsgSend[2] = updateStep; //cmd byte
+			pUpdateMsgSend[0] = 0x01;		// node byte
+			pUpdateMsgSend[1] = 0x40;		// func byte
+			pUpdateMsgSend[2] = updateStep; // cmd byte
 
 			for (i = 0; i < updateDataPackageCount; i++)
 			{
@@ -1734,10 +1738,10 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
 
 				CRCtemp = MS_BMS_Update_CRC16(ReadNVMTemp, tempLen);
 
-				dataLen = tempLen + 6;			//data len =count(2+2 byte) + crc(2byte) +  update data len
+				dataLen = tempLen + 6;			// data len =count(2+2 byte) + crc(2byte) +  update data len
 				updateMsgSendLen = 6 + dataLen; // updateMsgSendLen = data len + header len(6byte)
 
-				pUpdateMsgSend[3] = dataLen; //data len
+				pUpdateMsgSend[3] = dataLen; // data len
 
 				pUpdateMsgSend[4] = ((i + 1) >> 8) & 0xFF; //当前包序号,大端模式
 				pUpdateMsgSend[5] = (i + 1) & 0xFF;
@@ -1745,14 +1749,14 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
 				pUpdateMsgSend[6] = (updateDataPackageCount >> 8) & 0xFF;
 				pUpdateMsgSend[7] = updateDataPackageCount & 0xFF;
 				pUpdateMsgSend[8] = (CRCtemp >> 8) & 0xFF; // data CRC High
-				pUpdateMsgSend[9] = CRCtemp & 0xFF;		   //data CRC Low
+				pUpdateMsgSend[9] = CRCtemp & 0xFF;		   // data CRC Low
 
 				MEMCPY(&pUpdateMsgSend[4 + 6], ReadNVMTemp, 64); //升级数据,64字节
 
 				CRCtemp = MS_BMS_Update_CRC16(pUpdateMsgSend, 4 + dataLen);
 
 				pUpdateMsgSend[4 + dataLen] = (CRCtemp >> 8) & 0xFF; // CRC High
-				pUpdateMsgSend[5 + dataLen] = CRCtemp & 0xFF;		 //CRC Low
+				pUpdateMsgSend[5 + dataLen] = CRCtemp & 0xFF;		 // CRC Low
 
 				memset((UINT8 *)(bmsAnswerMsg), 0, 8);
 				ret0 = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(bmsAnswerMsg), updateMsgReadLen, 1000);
@@ -1768,9 +1772,9 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
 				{
 					if (bmsAnswerMsg[0] == 0x01 && bmsAnswerMsg[1] == 0x40) // node and func byte
 					{
-						if (bmsAnswerMsg[2] == MS_UPDATE_STEP_UPDATE_DATA_WRITE_ANSWER && bmsAnswerMsg[3] == 0x01) //answer cmd byte:0x04, answer data len:0x01
+						if (bmsAnswerMsg[2] == MS_UPDATE_STEP_UPDATE_DATA_WRITE_ANSWER && bmsAnswerMsg[3] == 0x01) // answer cmd byte:0x04, answer data len:0x01
 						{
-							if (bmsAnswerMsg[4] == 0x00) //answer data byte1,接收并操作成功
+							if (bmsAnswerMsg[4] == 0x00) // answer data byte1,接收并操作成功
 							{
 								updateStep = MS_UPDATE_STEP_EREASE_APP_FLASH_REQUEST;
 								errorCount = 0;
@@ -1824,19 +1828,19 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
 				updateStep = MS_UPDATE_STEP_SEND_UPDATE_DATA_END_AND_JUMP_TO_APP;
 			}
 			break;
-		case MS_UPDATE_STEP_SEND_UPDATE_DATA_END_AND_JUMP_TO_APP: //0x09
+		case MS_UPDATE_STEP_SEND_UPDATE_DATA_END_AND_JUMP_TO_APP: // 0x09
 			dataLen = 0x00;
 			updateMsgSendLen = 6 + dataLen;
 			updateMsgReadLen = 7;
 
-			pUpdateMsgSend[0] = 0x01;		//node byte
-			pUpdateMsgSend[1] = 0x40;		//func byte
-			pUpdateMsgSend[2] = updateStep; //cmd byte
-			pUpdateMsgSend[3] = dataLen;	//data len
-											//no data type
+			pUpdateMsgSend[0] = 0x01;		// node byte
+			pUpdateMsgSend[1] = 0x40;		// func byte
+			pUpdateMsgSend[2] = updateStep; // cmd byte
+			pUpdateMsgSend[3] = dataLen;	// data len
+											// no data type
 			CRCtemp = MS_BMS_Update_CRC16(pUpdateMsgSend, 4);
 			pUpdateMsgSend[4] = (CRCtemp >> 8) & 0xFF; // CRC High
-			pUpdateMsgSend[5] = CRCtemp & 0xFF;		   //CRC Low
+			pUpdateMsgSend[5] = CRCtemp & 0xFF;		   // CRC Low
 
 			memset((UINT8 *)(bmsAnswerMsg), 0, 8);
 			ret0 = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(bmsAnswerMsg), updateMsgReadLen, 1000);
@@ -1852,12 +1856,12 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
 			{
 				if (bmsAnswerMsg[0] == 0x01 && bmsAnswerMsg[1] == 0x40) // node and func byte
 				{
-					if (bmsAnswerMsg[2] == MS_UPDATE_STEP_JUMP_TO_APP_ANSWER && bmsAnswerMsg[3] == 0x01) //answer cmd byte:0x0A, answer data len:0x01
+					if (bmsAnswerMsg[2] == MS_UPDATE_STEP_JUMP_TO_APP_ANSWER && bmsAnswerMsg[3] == 0x01) // answer cmd byte:0x0A, answer data len:0x01
 					{
-						if (bmsAnswerMsg[4] == 0x00) //answer data byte1, update succeed
+						if (bmsAnswerMsg[4] == 0x00) // answer data byte1, update succeed
 						{
 							errorCount = 0;
-							updateStep = MS_UPDATE_STEP_READ_CURRENT_RUNNING_MODE; //0x0B
+							updateStep = MS_UPDATE_STEP_READ_CURRENT_RUNNING_MODE; // 0x0B
 						}
 						else if (bmsAnswerMsg[4] == 0x01) //升级失败
 						{
@@ -1887,19 +1891,19 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
 			}
 			osDelay(50);
 			break;
-		case MS_UPDATE_STEP_READ_CURRENT_RUNNING_MODE: //0x0B
+		case MS_UPDATE_STEP_READ_CURRENT_RUNNING_MODE: // 0x0B
 			dataLen = 0x00;
 			updateMsgSendLen = 6 + dataLen;
 			updateMsgReadLen = 8;
 
-			pUpdateMsgSend[0] = 0x01;		//node byte
-			pUpdateMsgSend[1] = 0x40;		//func byte
-			pUpdateMsgSend[2] = updateStep; //cmd byte
-			pUpdateMsgSend[3] = dataLen;	//data len
-											//no data type
+			pUpdateMsgSend[0] = 0x01;		// node byte
+			pUpdateMsgSend[1] = 0x40;		// func byte
+			pUpdateMsgSend[2] = updateStep; // cmd byte
+			pUpdateMsgSend[3] = dataLen;	// data len
+											// no data type
 			CRCtemp = MS_BMS_Update_CRC16(pUpdateMsgSend, 4);
 			pUpdateMsgSend[4] = (CRCtemp >> 8) & 0xFF; // CRC High
-			pUpdateMsgSend[5] = CRCtemp & 0xFF;		   //CRC Low
+			pUpdateMsgSend[5] = CRCtemp & 0xFF;		   // CRC Low
 
 			memset((UINT8 *)(bmsAnswerMsg), 0, 8);
 			ret0 = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(bmsAnswerMsg), updateMsgReadLen, 1000);
@@ -1915,14 +1919,14 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
 			{
 				if (bmsAnswerMsg[0] == 0x01 && bmsAnswerMsg[1] == 0x40) // node and func byte
 				{
-					if (bmsAnswerMsg[2] == MS_UPDATE_STEP_CURRENT_RUNNING_MODE_ANSWER && bmsAnswerMsg[3] == 0x02) //answer cmd byte:0x0C, answer data len:0x02
+					if (bmsAnswerMsg[2] == MS_UPDATE_STEP_CURRENT_RUNNING_MODE_ANSWER && bmsAnswerMsg[3] == 0x02) // answer cmd byte:0x0C, answer data len:0x02
 					{
-						if (bmsAnswerMsg[4] == 0x01) //answer data byte1, update succeed, app is running
+						if (bmsAnswerMsg[4] == 0x01) // answer data byte1, update succeed, app is running
 						{
 							errorCount = 0;
 							updateStep = MS_UPDATE_STEP_END;
 						}
-						else if (bmsAnswerMsg[4] == 0x00) //update failed , boot is running,error
+						else if (bmsAnswerMsg[4] == 0x00) // update failed , boot is running,error
 						{
 							errorCount = 10;
 						}
@@ -1949,12 +1953,12 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
 			}
 			osDelay(50);
 			break;
-		case MS_UPDATE_STEP_END: //0x0D
+		case MS_UPDATE_STEP_END: // 0x0D
 			errorCount = 0;
 			bmsUpdateFlag = FALSE;
 			ret = updateOK;
 			break;
-		case MS_UPDATE_STEP_ERROR: //0x0E
+		case MS_UPDATE_STEP_ERROR: // 0x0E
 			errorCount = 0;
 			bmsUpdateFlag = true;
 			Cycle_conut++;

+ 1 - 1
src/EmbeddedCoder_src/BCU.c

@@ -131,7 +131,7 @@ void BCU(void)
                     ihd_st_disChrgMosControl = DisChargeForbiddenControl == 0;
                     ihd_st_relayControl = RelayForbiddenControl == 0;
 
-					ihd_st_heatStat = battHeatEnableState;
+                    ihd_st_heatStat = battHeatEnableState;
                     // ihd_flg_DTCClear = 1;   //////clear
 
                     //调用算法

+ 3 - 4
src/EmbeddedCoder_src/BCUCal.c

@@ -16,7 +16,7 @@ const uint16_T cmnm_R_polar[13] = {4955U, 2073U, 1504U, 1197U, 1098U, 1072U, 114
 const uint16_T cmnm_V_ocv[13] = {3327U, 3453U, 3487U, 3563U, 3617U, 3652U, 3700U, 3791U, 3897U, 4006U, 4129U, 4197U, 4276U};               /* 电池放电参数的OCV数组; */
 const uint16_T cmnm_pct_soc[13] = {0U, 50U, 100U, 200U, 300U, 400U, 500U, 600U, 700U, 800U, 900U, 950U, 1000U};                            /* 电池放电参数的SOC数组; */
 const uint16_T cmnc_V_disChrgLim = 2900U;
-const uint16_T cmnc_V_chrgFul = 4200U; /* 充满电的截至电压; */
+const uint16_T cmnc_V_chrgFul = 4190U; /* 充满电的截至电压; */
 const uint16_T cmnm_R_voloffset[28] = {0, 0, 0, 0, 0,
                                        0, 770, 0, 0, 0,
                                        0, 0, 0, 540, 0,
@@ -115,6 +115,5 @@ const uint16_T cmm_I_ChrgCurr[18] = {0, 100, 100, 100, 100, 50,
 const uint16_T tmsc_T_openThr = 45U;     /* 热管理开启温度; */
 const uint16_T tmsc_T_closeMinThr = 50U; /* 热管理关闭温度(最低模组); */
 const uint16_T tmsc_T_closeMaxThr = 70U; /* 热管理开启温度(最高模组); */
-const uint16_T tmsc_pct_socOpen = 100;/* 热管理开启SOC阈值(非充电)*/
-const uint16_T tmsc_pct_socClos = 50;/* 热管理退出SOC阈值(非充电)*/
-
+const uint16_T tmsc_pct_socOpen = 100;   /* 热管理开启SOC阈值(非充电)*/
+const uint16_T tmsc_pct_socClos = 50;    /* 热管理退出SOC阈值(非充电)*/

+ 66 - 75
src/EmbeddedCoder_src/CDM.c

@@ -11,132 +11,123 @@ void CDM(void)
     real_T cmdn_V_cellUDelt;
     static real_T cdmn_M_P[2][2][cmnc_num_cellUNumMax];
     real_T P[2][2];
-	real_T A[2];
-	real_T K[2];
-	real_T arf;
-	real_T theta[2];
+    real_T A[2];
+    real_T K[2];
+    real_T arf;
+    real_T theta[2];
     static real_T deltaE[cmnc_num_cellUNumMax];
     static real_T deltaR[cmnc_num_cellUNumMax];
-	static int16_T cdmn_I_curr[cdmd_L_rls];
+    static int16_T cdmn_I_curr[cdmd_L_rls];
     uint16_T i;
     static uint8_T cmdn_st_workStat_Delay;
     static uint8_T cdmn_num_Cnt;
 
-
-
-   
     //------模式切换后重置--------------------
     if (cmdn_st_workStat_Delay != 1 && ihd_st_workStat == 1)
     {
         cdmd_flg_firstRun = true;
     }
-	
-   //初值归零---------------------------------
-   if (cdmd_flg_firstRun)
-   {
-	   cdmn_num_Cnt = 0;
-	   for (i = 0; i < cmnc_num_cellUNum; i++)
-	   {
-		   cdmn_M_P[0][0][i] = 10;
-		   cdmn_M_P[0][1][i] = 0;
-		   cdmn_M_P[1][0][i] = 0;
-		   cdmn_M_P[1][1][i] = 10;
-		   deltaE[i] = 0;
-		   deltaR[i] = 0;
-		   cdmv_flg_inval[i] = 1;
-	   }
-   }
-   //记忆区间-----------------------------------
-   	if (pimd_flg_firstRun)
+
+    //初值归零---------------------------------
+    if (cdmd_flg_firstRun)
+    {
+        cdmn_num_Cnt = 0;
+        for (i = 0; i < cmnc_num_cellUNum; i++)
+        {
+            cdmn_M_P[0][0][i] = 10;
+            cdmn_M_P[0][1][i] = 0;
+            cdmn_M_P[1][0][i] = 0;
+            cdmn_M_P[1][1][i] = 10;
+            deltaE[i] = 0;
+            deltaR[i] = 0;
+            cdmv_flg_inval[i] = 1;
+        }
+    }
+    //记忆区间-----------------------------------
+    if (pimd_flg_firstRun)
     {
         for (i = 0; i < cdmd_L_rls; i++)
         {
             cdmn_I_curr[i] = sfmd_I_curr;
         }
-	}
+    }
     else
     {
         for (i = 0; i < cdmd_L_rls - 1; i++)
         {
-            cdmn_I_curr[i] = cdmn_I_curr[i+1];
+            cdmn_I_curr[i] = cdmn_I_curr[i + 1];
         }
         cdmn_I_curr[i] = sfmd_I_curr;
     }
-	
 
     //放电使能----------------------------------------
-    if (ihd_st_workStat == 1 && ihd_st_heatStat == 0) 
-    { 
-        for (i = 1; i < 2; i++)
+    if (ihd_st_workStat == 1 && ihd_st_heatStat == 0)
+    {
+        for (i = 1; i < cmnc_num_cellUNum; i++)
         {
             //新增
-            cmdn_V_cellUDelt =  (real_T)(sfmv_V_cellU[i] - sfmv_V_cellU[0]) * 0.001;   // #0单体为基准
+            cmdn_V_cellUDelt = (real_T)(sfmv_V_cellU[i] - sfmv_V_cellU[0]) * 0.001; // #0单体为基准
             A[0] = 1;
-			A[1] = (real_T)cdmn_I_curr[cdmd_L_rls - 1] * 0.1;
+            A[1] = (real_T)cdmn_I_curr[cdmd_L_rls - 1] * 0.1;
 
             theta[0] = deltaE[i];
-		    theta[1] = deltaR[i];
-            K[0] = (cdmn_M_P[0][0][i] * A[0] + cdmn_M_P[0][1][i] * A[1])/(1 + (A[0] * cdmn_M_P[0][0][i] + A[1] * cdmn_M_P[1][0][i]) * A[0] +  (A[0] * cdmn_M_P[0][1][i] + A[1] * cdmn_M_P[1][1][i]) * A[1] );
-			K[1] = (cdmn_M_P[1][0][i] * A[0] + cdmn_M_P[1][1][i] * A[1])/(1 + (A[0] * cdmn_M_P[0][0][i] + A[1] * cdmn_M_P[1][0][i]) * A[0] +  (A[0] * cdmn_M_P[0][1][i] + A[1] * cdmn_M_P[1][1][i]) * A[1] );	
+            theta[1] = deltaR[i];
+            K[0] = (cdmn_M_P[0][0][i] * A[0] + cdmn_M_P[0][1][i] * A[1]) / (1 + (A[0] * cdmn_M_P[0][0][i] + A[1] * cdmn_M_P[1][0][i]) * A[0] + (A[0] * cdmn_M_P[0][1][i] + A[1] * cdmn_M_P[1][1][i]) * A[1]);
+            K[1] = (cdmn_M_P[1][0][i] * A[0] + cdmn_M_P[1][1][i] * A[1]) / (1 + (A[0] * cdmn_M_P[0][0][i] + A[1] * cdmn_M_P[1][0][i]) * A[0] + (A[0] * cdmn_M_P[0][1][i] + A[1] * cdmn_M_P[1][1][i]) * A[1]);
 
-		
             arf = cmdn_V_cellUDelt - (theta[0] * A[0] + theta[1] * A[1]);
-			theta[0] = theta[0] + K[0] * arf;
-			theta[1] = theta[1] + K[1] * arf;
-
+            theta[0] = theta[0] + K[0] * arf;
+            theta[1] = theta[1] + K[1] * arf;
 
-			P[0][0] = cdmn_M_P[0][0][i] - K[0] * (A[0] * cdmn_M_P[0][0][i] + A[1] * cdmn_M_P[1][0][i]);
-			P[0][1] = cdmn_M_P[0][1][i] - K[0] * (A[0] * cdmn_M_P[0][1][i] + A[1] * cdmn_M_P[1][1][i]);	
-			P[1][0] = cdmn_M_P[1][0][i] - K[1] * (A[0] * cdmn_M_P[0][0][i] + A[1] * cdmn_M_P[1][0][i]);	
-			P[1][1] = cdmn_M_P[1][1][i] - K[1] * (A[0] * cdmn_M_P[0][1][i] + A[1] * cdmn_M_P[1][1][i]);	
+            P[0][0] = cdmn_M_P[0][0][i] - K[0] * (A[0] * cdmn_M_P[0][0][i] + A[1] * cdmn_M_P[1][0][i]);
+            P[0][1] = cdmn_M_P[0][1][i] - K[0] * (A[0] * cdmn_M_P[0][1][i] + A[1] * cdmn_M_P[1][1][i]);
+            P[1][0] = cdmn_M_P[1][0][i] - K[1] * (A[0] * cdmn_M_P[0][0][i] + A[1] * cdmn_M_P[1][0][i]);
+            P[1][1] = cdmn_M_P[1][1][i] - K[1] * (A[0] * cdmn_M_P[0][1][i] + A[1] * cdmn_M_P[1][1][i]);
 
             cdmn_M_P[0][0][i] = P[0][0];
             cdmn_M_P[0][1][i] = P[0][1];
             cdmn_M_P[1][0][i] = P[1][0];
             cdmn_M_P[1][1][i] = P[1][1];
 
-			//删去
-            if(cdmn_num_Cnt > cdmd_L_rls)
+            //删去
+            if (cdmn_num_Cnt > cdmd_L_rls)
             {
-            	A[0] = 1;
-				A[1] = (real_T)cdmn_I_curr[0] * 0.1;
-	         	K[0] = (cdmn_M_P[0][0][i] * A[0] + cdmn_M_P[0][1][i] * A[1])/(1 + (A[0] * cdmn_M_P[0][0][i] + A[1] * cdmn_M_P[1][0][i]) * A[0] +  (A[0] * cdmn_M_P[0][1][i] + A[1] * cdmn_M_P[1][1][i]) * A[1] );
-				K[1] = (cdmn_M_P[1][0][i] * A[0] + cdmn_M_P[1][1][i] * A[1])/(1 + (A[0] * cdmn_M_P[0][0][i] + A[1] * cdmn_M_P[1][0][i]) * A[0] +  (A[0] * cdmn_M_P[0][1][i] + A[1] * cdmn_M_P[1][1][i]) * A[1] );	
-			  
-				P[0][0] = cdmn_M_P[0][0][i] + K[0] * (A[0] * cdmn_M_P[0][0][i] + A[1] * cdmn_M_P[1][0][i]);
-				P[0][1] = cdmn_M_P[0][1][i] + K[0] * (A[0] * cdmn_M_P[0][1][i] + A[1] * cdmn_M_P[1][1][i]);	
-				P[1][0] = cdmn_M_P[1][0][i] + K[1] * (A[0] * cdmn_M_P[0][0][i] + A[1] * cdmn_M_P[1][0][i]);	
-				P[1][1] = cdmn_M_P[1][1][i] + K[1] * (A[0] * cdmn_M_P[0][1][i] + A[1] * cdmn_M_P[1][1][i]);	
-		
-            	cdmn_M_P[0][0][i] = P[0][0];
-            	cdmn_M_P[0][1][i] = P[0][1];
-            	cdmn_M_P[1][0][i] = P[1][0];
-            	cdmn_M_P[1][1][i] = P[1][1];
+                A[0] = 1;
+                A[1] = (real_T)cdmn_I_curr[0] * 0.1;
+                K[0] = (cdmn_M_P[0][0][i] * A[0] + cdmn_M_P[0][1][i] * A[1]) / (1 + (A[0] * cdmn_M_P[0][0][i] + A[1] * cdmn_M_P[1][0][i]) * A[0] + (A[0] * cdmn_M_P[0][1][i] + A[1] * cdmn_M_P[1][1][i]) * A[1]);
+                K[1] = (cdmn_M_P[1][0][i] * A[0] + cdmn_M_P[1][1][i] * A[1]) / (1 + (A[0] * cdmn_M_P[0][0][i] + A[1] * cdmn_M_P[1][0][i]) * A[0] + (A[0] * cdmn_M_P[0][1][i] + A[1] * cdmn_M_P[1][1][i]) * A[1]);
+
+                P[0][0] = cdmn_M_P[0][0][i] + K[0] * (A[0] * cdmn_M_P[0][0][i] + A[1] * cdmn_M_P[1][0][i]);
+                P[0][1] = cdmn_M_P[0][1][i] + K[0] * (A[0] * cdmn_M_P[0][1][i] + A[1] * cdmn_M_P[1][1][i]);
+                P[1][0] = cdmn_M_P[1][0][i] + K[1] * (A[0] * cdmn_M_P[0][0][i] + A[1] * cdmn_M_P[1][0][i]);
+                P[1][1] = cdmn_M_P[1][1][i] + K[1] * (A[0] * cdmn_M_P[0][1][i] + A[1] * cdmn_M_P[1][1][i]);
+
+                cdmn_M_P[0][0][i] = P[0][0];
+                cdmn_M_P[0][1][i] = P[0][1];
+                cdmn_M_P[1][0][i] = P[1][0];
+                cdmn_M_P[1][1][i] = P[1][1];
             }
-            if (arf> 0.04 || arf< -0.04)
+            if (arf > 0.04 || arf < -0.04)
             {
                 cdmv_flg_inval[i] = true;
             }
-			
-			deltaE[i] = theta[0];
+
+            deltaE[i] = theta[0];
             deltaR[i] = theta[1];
-			test_U[i] = arf;
-			cdmv_V_deltOCV[i] = (int16_T)(deltaE[i]  * 1000);
-            cdmv_R_deltOhm[i] = (int16_T)(deltaR[i]  * 1000 * 1000);
+            test_U[i] = arf;
+            cdmv_V_deltOCV[i] = (int16_T)(deltaE[i] * 1000);
+            cdmv_R_deltOhm[i] = (int16_T)(deltaR[i] * 1000 * 1000);
         }
         //
         cdmn_num_Cnt = cdmn_num_Cnt + 1;
     }
     else
     {
-        memset(cdmv_flg_inval,0,sizeof(cdmv_V_deltOCV));
-		memset(cdmv_V_deltOCV,0,sizeof(cdmv_V_deltOCV));
-		memset(cdmv_R_deltOhm,0,sizeof(cdmv_R_deltOhm));
+        memset(cdmv_flg_inval, 0, sizeof(cdmv_V_deltOCV));
+        memset(cdmv_V_deltOCV, 0, sizeof(cdmv_V_deltOCV));
+        memset(cdmv_R_deltOhm, 0, sizeof(cdmv_R_deltOhm));
     }
-	
-	
+
     cdmd_flg_firstRun = false;
-	cmdn_st_workStat_Delay = ihd_st_workStat;
+    cmdn_st_workStat_Delay = ihd_st_workStat;
 }
-
-

+ 2 - 2
src/EmbeddedCoder_src/SFM.c

@@ -249,7 +249,7 @@ void SFM(void)
         sfmd_flg_heatRunFltEi = false;
         sfmd_flg_heatRunFltEo = false;
         sfmd_flg_iscFltEi = false;
-        sfmd_flg_iscFltEi = false;
+        sfmd_flg_iscFltEo = false;
     }
 
     //=======================================================================================
@@ -279,7 +279,7 @@ void SFM(void)
         sfmn_flg_HVILFlt = false;
     }
     // 16
-    sfmd_flg_iscFltEo = iscd_flg_flt[0] ||iscd_flg_flt[1] ||iscd_flg_flt[2]|| sfmd_flg_iscFltEi || sfmd_flg_iscFltEo;
+    sfmd_flg_iscFltEo = iscd_flg_flt[0] || iscd_flg_flt[1] || iscd_flg_flt[2] || sfmd_flg_iscFltEi || sfmd_flg_iscFltEo;
 
     // 22 充电Mos失效故障
     sfmn_flg_chrgMosClosFlt = JudgeTimeSystem(!sfmn_flg_interComFlt, ihd_flg_chrgMosClosFlt, &DiagTime.N22, 2);