Selaa lähdekoodia

静置时间更改

CHENJIE-PC\QiXiang_CHENJIE 3 vuotta sitten
vanhempi
commit
1e087125b4
1 muutettua tiedostoa jossa 115 lisäystä ja 115 poistoa
  1. 115 115
      src/AppFunc.c

+ 115 - 115
src/AppFunc.c

@@ -3,7 +3,7 @@
  * @Date         : 2021-11-09 12:08:17
  * @Version      : V3.0
  * @LastEditors  : ChenJie
- * @LastEditTime : 2021-11-26 14:44:06
+ * @LastEditTime : 2021-12-06 16:15:03
  * @Description  : file content
  * @FilePath     : \PLAT\project\ec616_0h00\apps\qx_app\src\AppFunc.c
  */
@@ -19,7 +19,7 @@
 void BmsProtectStateDecode(UINT8 *DischargeProtect, UINT8 *ChargeProtect)
 {
 	UINT8 ret = 0;
-	//battProtectState = (dataPtr[(0x03 + BATT_CELL_VOL_NUM) * 2 + 0] << 24) | (dataPtr[(0x04 + BATT_CELL_VOL_NUM) * 2 + 0] << 16) | (dataPtr[(0x04 + BATT_CELL_VOL_NUM) * 2 + 1] << 8) | (dataPtr[(0x05 + BATT_CELL_VOL_NUM) * 2 + 1]);
+	// battProtectState = (dataPtr[(0x03 + BATT_CELL_VOL_NUM) * 2 + 0] << 24) | (dataPtr[(0x04 + BATT_CELL_VOL_NUM) * 2 + 0] << 16) | (dataPtr[(0x04 + BATT_CELL_VOL_NUM) * 2 + 1] << 8) | (dataPtr[(0x05 + BATT_CELL_VOL_NUM) * 2 + 1]);
 	if (battProtectState == 0x00)
 	{
 		*DischargeProtect = 0;
@@ -31,91 +31,91 @@ void BmsProtectStateDecode(UINT8 *DischargeProtect, UINT8 *ChargeProtect)
 	if (ret) //放电短路保护--0
 	{
 		*DischargeProtect = (*DischargeProtect) + 1;
-		//printf("protect[%d]\n", __LINE__);
+		// printf("protect[%d]\n", __LINE__);
 	}
 	ret = getbit(battProtectState, 1);
 	if (ret) //放电过流保护--1
 	{
 		*DischargeProtect = (*DischargeProtect) + 1;
-		//printf("protect[%d]\n", __LINE__);
+		// printf("protect[%d]\n", __LINE__);
 	}
 
 	ret = getbit(battProtectState, 2);
 	if (ret) //充电过流保护--2
 	{
 		*ChargeProtect = (*ChargeProtect) + 1;
-		//printf("protect[%d]\n", __LINE__);
+		// printf("protect[%d]\n", __LINE__);
 	}
 
 	ret = getbit(battProtectState, 8);
 	if (ret) //电芯欠压--8
 	{
 		*DischargeProtect = (*DischargeProtect) + 1;
-		//printf("protect[%d]\n", __LINE__);
+		// printf("protect[%d]\n", __LINE__);
 	}
 
 	ret = getbit(battProtectState, 9);
 	if (ret) //总压欠压--9
 	{
 		*DischargeProtect = (*DischargeProtect) + 1;
-		//printf("protect[%d]\n", __LINE__);
+		// printf("protect[%d]\n", __LINE__);
 	}
 
 	ret = getbit(battProtectState, 16);
 	if (ret) //充电高温--16
 	{
 		*ChargeProtect = (*ChargeProtect) + 1;
-		//printf("protect[%d]\n", __LINE__);
+		// printf("protect[%d]\n", __LINE__);
 	}
 
 	ret = getbit(battProtectState, 17);
 	if (ret) //充电低温--17
 	{
 		*ChargeProtect = (*ChargeProtect) + 1;
-		//printf("protect[%d]\n", __LINE__);
+		// printf("protect[%d]\n", __LINE__);
 	}
 
 	ret = getbit(battProtectState, 18);
-	if (ret) //mos高温--18
+	if (ret) // mos高温--18
 	{
 		*ChargeProtect = (*ChargeProtect) + 1;
 		*DischargeProtect = (*DischargeProtect) + 1;
-		//printf("protect[%d]\n", __LINE__);
+		// printf("protect[%d]\n", __LINE__);
 	}
 
 	ret = getbit(battProtectState, 20);
 	if (ret) //放电高温--20
 	{
 		*DischargeProtect = (*DischargeProtect) + 1;
-		//printf("protect[%d]\n", __LINE__);
+		// printf("protect[%d]\n", __LINE__);
 	}
 
 	ret = getbit(battProtectState, 21);
 	if (ret) //放电低温--21
 	{
 		*DischargeProtect = (*DischargeProtect) + 1;
-		//printf("protect[%d]\n", __LINE__);
+		// printf("protect[%d]\n", __LINE__);
 	}
 
 	ret = getbit(battProtectState, 24);
 	if (ret) //电芯过压--24
 	{
 		*ChargeProtect = (*ChargeProtect) + 1;
-		//printf("protect[%d]\n", __LINE__);
+		// printf("protect[%d]\n", __LINE__);
 	}
 
 	ret = getbit(battProtectState, 25);
 	if (ret) //总压过压--25
 	{
 		*ChargeProtect = (*ChargeProtect) + 1;
-		//printf("protect[%d]\n", __LINE__);
+		// printf("protect[%d]\n", __LINE__);
 	}
 
 	ret = getbit(battProtectState, 28);
 	if (ret) //充满保护--28
 	{
 		//*ChargeProtect = (*ChargeProtect) + 1;
-		//printf("protect[%d]\n", __LINE__);
+		// printf("protect[%d]\n", __LINE__);
 	}
 }
 /**
@@ -222,7 +222,7 @@ void ExpiryTimeCal(UINT8 *StartTimeArray, UINT16 rentalDays, UINT8 *ExpiryTimeAr
 	return;
 }
 /**
- * @brief :租期到期判断函数 
+ * @brief :租期到期判断函数
  * @param {*}
  * @return {*}
  */
@@ -294,7 +294,7 @@ INT8 rentalEndDetectFunc(void)
 	}
 }
 /**
- * @brief :电池是否业务锁定判断函数(锁定放电) 
+ * @brief :电池是否业务锁定判断函数(锁定放电)
  * @param {*}
  * @return {*}
  */
@@ -364,10 +364,10 @@ void BattWorkDelayFunc(UINT8 battWorkCurrentState)
 {
 	static UINT16 workDelayCounter = 0;
 
-	if (battWorkCurrentState == BATT_IDLE_SYM && BattWorkStateDelay == BATT_DISCHARGE_SYM) //从放电转静置 10s延时
+	if (battWorkCurrentState == BATT_IDLE_SYM && BattWorkStateDelay == BATT_DISCHARGE_SYM) //从放电转静置 60s延时
 	{
 		workDelayCounter++;
-		if (workDelayCounter >= 10)
+		if (workDelayCounter >= 60) //
 		{
 			workDelayCounter = 0;
 			BattWorkStateDelay = battWorkCurrentState;
@@ -461,7 +461,7 @@ UINT8 LookUpRTtable(UINT32 R_value)
 				}
 			}
 		}
-	} //R-1
+	} // R-1
 	else
 	{
 		if (R_value <= R_Table2[216]) //判断是否超出表尾
@@ -486,7 +486,7 @@ UINT8 LookUpRTtable(UINT32 R_value)
 				}
 			}
 		}
-	} //R-2
+	} // R-2
 }
 /**
  * @brief : tcp校验函数
@@ -535,11 +535,11 @@ BOOL BattHeaterSwitch(UINT8 *heaterSwitch, UINT8 HeatForceControl)
 	return isNeedtoSwitch;
 }
 /**
-  * @brief : 蜂鸣器控制函数
-  * @param {UINT8} BuzzerPeriod
-  * @param {float} DutyRatio
-  * @return {*}
-  */
+ * @brief : 蜂鸣器控制函数
+ * @param {UINT8} BuzzerPeriod
+ * @param {float} DutyRatio
+ * @return {*}
+ */
 void relayControlFunc(UINT16 BuzzerPeriod, float DutyRatio)
 {
 
@@ -573,7 +573,7 @@ void LEDDisplay(void)
 	static UINT16 LightTimer = 0;
 	static UINT16 ErrorLightTimer = 0;
 
-	UINT16 LEDFlashPeriod = 1000; //1000ms
+	UINT16 LEDFlashPeriod = 1000; // 1000ms
 	float DutyRatio = 0.5;
 	if (battWorkState == 2)
 	{
@@ -884,7 +884,7 @@ BOOL uartBattInfoDecode(UINT8 *dataPtr)
 	packTemp = dataPtr[(0x06 + BATT_CELL_VOL_NUM + BATT_TEMP_NUM + 1) * 2 + 1];
 	chargerConnectState = (dataPtr[(0x03 + BATT_CELL_VOL_NUM) * 2 + 1] >> 2) & 0x01; //充电器连接状态,0表示未连接,1表示已连接
 
-	//bit0 ~ bit31 represent cell0 ~ cell31
+	// bit0 ~ bit31 represent cell0 ~ cell31
 	battBalanceoInfo = dataPtr[(0x06 + BATT_CELL_VOL_NUM + TEMP_NUM) * 2 + 1] | (dataPtr[(0x06 + BATT_CELL_VOL_NUM + TEMP_NUM) * 2] << 8) + (dataPtr[(0x07 + BATT_CELL_VOL_NUM + TEMP_NUM) * 2 + 1] << 16) | (dataPtr[(0x07 + BATT_CELL_VOL_NUM + TEMP_NUM) * 2] << 24);
 
 	bmsHwVersion = dataPtr[(0x08 + BATT_CELL_VOL_NUM + TEMP_NUM) * 2 + 1];
@@ -909,7 +909,7 @@ BOOL uartBattInfoDecode(UINT8 *dataPtr)
 	battSOC = dataPtr[(0x0B + BATT_CELL_VOL_NUM + TEMP_NUM) * 2 + 1];
 	battSOH = dataPtr[(0x0C + BATT_CELL_VOL_NUM + TEMP_NUM) * 2 + 1];
 	Battdesigncap = (dataPtr[(0x0E + BATT_CELL_VOL_NUM + TEMP_NUM) * 2]) << 24 | (dataPtr[(0x0E + BATT_CELL_VOL_NUM + TEMP_NUM) * 2 + 1]) << 16 | (dataPtr[(0x0F + BATT_CELL_VOL_NUM + TEMP_NUM) * 2]) << 8 | (dataPtr[(0x0F + BATT_CELL_VOL_NUM + TEMP_NUM) * 2 + 1]);
-	battPackVol = ((dataPtr[(0x18 + BATT_CELL_VOL_NUM + TEMP_NUM) * 2]) << 8 | (dataPtr[(0x18 + BATT_CELL_VOL_NUM + TEMP_NUM) * 2 + 1])) / 10; //uint 100mV
+	battPackVol = ((dataPtr[(0x18 + BATT_CELL_VOL_NUM + TEMP_NUM) * 2]) << 8 | (dataPtr[(0x18 + BATT_CELL_VOL_NUM + TEMP_NUM) * 2 + 1])) / 10; // uint 100mV
 	maxCellVol = (dataPtr[(0x19 + BATT_CELL_VOL_NUM + TEMP_NUM) * 2] << 8) | dataPtr[(0x19 + BATT_CELL_VOL_NUM + TEMP_NUM) * 2 + 1];
 	minCellVol = (dataPtr[(0x1A + BATT_CELL_VOL_NUM + TEMP_NUM) * 2] << 8) | dataPtr[(0x1A + BATT_CELL_VOL_NUM + TEMP_NUM) * 2 + 1];
 	battHeatEnableState = dataPtr[(0x1C + BATT_CELL_VOL_NUM + TEMP_NUM) * 2 + 1] & 0x01;
@@ -987,7 +987,7 @@ void SaveAppData(void)
 	OSAFILE fp = PNULL;
 	UINT32 writeCount = 0;
 	AppDataHeader AppDataHr;
-	fp = OsaFopen(APP_DATAINFO_FILE_NAME, "wb"); //read & write
+	fp = OsaFopen(APP_DATAINFO_FILE_NAME, "wb"); // read & write
 	if (OsaFseek(fp, 0, SEEK_SET) != 0)
 	{
 #ifdef USING_PRINTF
@@ -1037,7 +1037,7 @@ void SaveBcuData(void)
 	OSAFILE fp = PNULL;
 	UINT32 writeCount = 0;
 	BcuDataHeader BcuDataHr;
-	fp = OsaFopen(BCU_DATAINFO_FILE_NAME, "wb"); //read & write
+	fp = OsaFopen(BCU_DATAINFO_FILE_NAME, "wb"); // read & write
 	if (OsaFseek(fp, 0, SEEK_SET) != 0)
 	{
 		OsaFclose(fp);
@@ -1077,7 +1077,7 @@ void LoadAppData(void)
 	UINT8 crcCheck = 0;
 	void *pReadAppConfig = (void *)&AppDataInfo;
 	AppDataHeader AppDataHr;
-	fp = OsaFopen(APP_DATAINFO_FILE_NAME, "rb"); //read only
+	fp = OsaFopen(APP_DATAINFO_FILE_NAME, "rb"); // read only
 	if (fp == PNULL)
 	{
 #ifdef USING_PRINTF
@@ -1106,26 +1106,26 @@ void LoadAppData(void)
 	if (AppDataHr.fileBodySize == sizeof(AppDataInfo)) //结构体数据没变动,可直接读出
 	{
 		readCount = OsaFread(pReadAppConfig, AppDataHr.fileBodySize, 1, fp);
-		//crcCheck = OsaCalcCrcValue((UINT8 *)pReadAppConfig, sizeof(AppNVMData));
+		// crcCheck = OsaCalcCrcValue((UINT8 *)pReadAppConfig, sizeof(AppNVMData));
 		readtimes = 0;
 		while (readtimes <= 5 && readCount != 1)
 		{
 			readtimes++;
 			readCount = OsaFread(pReadAppConfig, AppDataHr.fileBodySize, 1, fp);
-			//crcCheck = OsaCalcCrcValue((UINT8 *)pReadAppConfig, sizeof(AppNVMData));
+			// crcCheck = OsaCalcCrcValue((UINT8 *)pReadAppConfig, sizeof(AppNVMData));
 		}
 	}
 	else
 	{
 		setDefaultAppDataInfo();
 		readCount = OsaFread(pReadAppConfig, AppDataHr.fileBodySize, 1, fp);
-		//crcCheck = OsaCalcCrcValue((UINT8 *)pReadAppConfig, sizeof(AppNVMData));
+		// crcCheck = OsaCalcCrcValue((UINT8 *)pReadAppConfig, sizeof(AppNVMData));
 		readtimes = 0;
 		while (readtimes <= 5 && readCount != 1)
 		{
 			readtimes++;
 			readCount = OsaFread(pReadAppConfig, AppDataHr.fileBodySize, 1, fp);
-			//crcCheck = OsaCalcCrcValue((UINT8 *)pReadAppConfig, sizeof(AppNVMData));
+			// crcCheck = OsaCalcCrcValue((UINT8 *)pReadAppConfig, sizeof(AppNVMData));
 		}
 		SaveAppData();
 #ifdef USING_PRINTF
@@ -1147,7 +1147,7 @@ void LoadBcuData(void)
 	UINT8 crcCheck = 0;
 	void *pReadAppConfig = (void *)&BcuDataInfo;
 	BcuDataHeader BcuDataHr;
-	fp = OsaFopen(BCU_DATAINFO_FILE_NAME, "rb"); //read only
+	fp = OsaFopen(BCU_DATAINFO_FILE_NAME, "rb"); // read only
 	if (fp == PNULL)
 	{
 #ifdef USING_PRINTF
@@ -1175,26 +1175,26 @@ void LoadBcuData(void)
 	if (BcuDataHr.fileBodySize == sizeof(BcuDataInfo)) //结构体数据没变动,可直接读出
 	{
 		readCount = OsaFread(pReadAppConfig, BcuDataHr.fileBodySize, 1, fp);
-		//crcCheck = OsaCalcCrcValue((UINT8 *)pReadAppConfig, sizeof(AppNVMData));
+		// crcCheck = OsaCalcCrcValue((UINT8 *)pReadAppConfig, sizeof(AppNVMData));
 		readtimes = 0;
 		while (readtimes <= 5 && readCount != 1)
 		{
 			readtimes++;
 			readCount = OsaFread(pReadAppConfig, BcuDataHr.fileBodySize, 1, fp);
-			//crcCheck = OsaCalcCrcValue((UINT8 *)pReadAppConfig, sizeof(AppNVMData));
+			// crcCheck = OsaCalcCrcValue((UINT8 *)pReadAppConfig, sizeof(AppNVMData));
 		}
 	}
 	else
 	{
 		setDefaultBcuDataInfo();
 		readCount = OsaFread(pReadAppConfig, BcuDataHr.fileBodySize, 1, fp);
-		//crcCheck = OsaCalcCrcValue((UINT8 *)pReadAppConfig, sizeof(AppNVMData));
+		// crcCheck = OsaCalcCrcValue((UINT8 *)pReadAppConfig, sizeof(AppNVMData));
 		readtimes = 0;
 		while (readtimes <= 5 && readCount != 1)
 		{
 			readtimes++;
 			readCount = OsaFread(pReadAppConfig, BcuDataHr.fileBodySize, 1, fp);
-			//crcCheck = OsaCalcCrcValue((UINT8 *)pReadAppConfig, sizeof(AppNVMData));
+			// crcCheck = OsaCalcCrcValue((UINT8 *)pReadAppConfig, sizeof(AppNVMData));
 		}
 		SaveBcuData();
 #ifdef USING_PRINTF
@@ -1213,12 +1213,12 @@ void SaveAppConfig(void)
 {
 	OSAFILE fp = PNULL;
 	UINT32 writeCount = 0;
-	AppConfigDataHeader AppConfigHr; //4 bytes
+	AppConfigDataHeader AppConfigHr; // 4 bytes
 	/*
-     * open the NVM file
-    */
+	 * open the NVM file
+	 */
 	AppNVMData.appDataModify = FALSE;
-	fp = OsaFopen(APP_CONFIG_FILE_NAME, "wb"); //read & write
+	fp = OsaFopen(APP_CONFIG_FILE_NAME, "wb"); // read & write
 	if (OsaFseek(fp, 0, SEEK_SET) != 0)
 	{
 #ifdef USING_PRINTF
@@ -1235,8 +1235,8 @@ void SaveAppConfig(void)
 		return;
 	}
 	/*
-     * write the header
-    */
+	 * write the header
+	 */
 	AppConfigHr.fileBodySize = sizeof(AppNVMData);
 	AppConfigHr.checkSum = OsaCalcCrcValue((UINT8 *)&AppNVMData, sizeof(AppNVMData));
 	writeCount = OsaFwrite(&AppConfigHr, sizeof(AppConfigHr), 1, fp);
@@ -1249,8 +1249,8 @@ void SaveAppConfig(void)
 		return;
 	}
 	/*
-     * write the file body
-    */
+	 * write the file body
+	 */
 	writeCount = OsaFwrite(&AppNVMData, sizeof(AppNVMData), 1, fp);
 	if (writeCount != 1)
 	{
@@ -1274,9 +1274,9 @@ void LoadAppConfig(void)
 	UINT8 crcCheck = 0;
 	void *pReadAppConfig = (void *)&AppNVMData;
 	/*
-     * open the NVM file
-    */
-	fp = OsaFopen(APP_CONFIG_FILE_NAME, "rb"); //read only
+	 * open the NVM file
+	 */
+	fp = OsaFopen(APP_CONFIG_FILE_NAME, "rb"); // read only
 
 	if (fp == PNULL)
 	{
@@ -1288,8 +1288,8 @@ void LoadAppConfig(void)
 		return;
 	}
 	/*
-     * read the file header
-    */
+	 * read the file header
+	 */
 	readCount = OsaFread(&AppConfigHr, sizeof(AppConfigHr), 1, fp);
 	UINT8 readtimes = 0;
 	while (readCount != 1 && readtimes <= 5)
@@ -1308,7 +1308,7 @@ void LoadAppConfig(void)
 		SaveAppConfig();
 		return;
 	}
-	if (AppConfigHr.fileBodySize != sizeof(AppNVMData)) //file version is the same, but NVM file size not right
+	if (AppConfigHr.fileBodySize != sizeof(AppNVMData)) // file version is the same, but NVM file size not right
 	{
 #ifdef USING_PRINTF
 		printf("MW NVM: 'midwareconfig.nvm', file body size not right: (%u/%u), use the defult value",
@@ -1320,12 +1320,12 @@ void LoadAppConfig(void)
 		return;
 	}
 	/*
-     * read the file body
-    */
+	 * read the file body
+	 */
 	readCount = OsaFread(pReadAppConfig, AppConfigHr.fileBodySize, 1, fp);
 	crcCheck = OsaCalcCrcValue((UINT8 *)pReadAppConfig, sizeof(AppNVMData));
 	readtimes = 0;
-	//while (readtimes<=5 && crcCheck != AppConfigHr.checkSum)
+	// while (readtimes<=5 && crcCheck != AppConfigHr.checkSum)
 	while (readtimes <= 5 && readCount != 1 && crcCheck != AppConfigHr.checkSum)
 	{
 		readtimes++;
@@ -1506,7 +1506,7 @@ void Fota_Func(UINT8 *DataPtr, INT32 connectId)
 			else
 			{
 				Fota_Answer[3] = 0x01;
-				BSP_QSPI_Erase_Safe(Fota_S.Fota_Flash_Addres, (FLASH_BMS_FOTA_START_ADDR - FLASH_FOTA_REGION_START)); //512k-32k = 480k -> 0x75300  0x78000
+				BSP_QSPI_Erase_Safe(Fota_S.Fota_Flash_Addres, (FLASH_BMS_FOTA_START_ADDR - FLASH_FOTA_REGION_START)); // 512k-32k = 480k -> 0x75300  0x78000
 			}
 			memcpy(&Fota_Answer[4], (DataPtr + 4), BATT_SN_LEN);
 			Fota_Answer[21] = TCP_ENCPT_DISABLE;
@@ -1611,7 +1611,7 @@ void Fota_Func(UINT8 *DataPtr, INT32 connectId)
 		}
 		}
 	}
-	else if (*(DataPtr + 30) == 0x88) //BMS升级文件存放
+	else if (*(DataPtr + 30) == 0x88) // BMS升级文件存放
 	{
 		Fota_S.Fota_Flash_Addres = FLASH_BMS_FOTA_START_ADDR;
 		Fota_Cmd = *(DataPtr + 31);
@@ -1631,7 +1631,7 @@ void Fota_Func(UINT8 *DataPtr, INT32 connectId)
 			else
 			{
 				Fota_Answer[3] = 0x01;
-				BSP_QSPI_Erase_Safe(Fota_S.Fota_Flash_Addres, (FLASH_BMS_FOTA_END_ADDR - FLASH_BMS_FOTA_START_ADDR)); //512k-32k = 480k -> 0x75300  0x78000
+				BSP_QSPI_Erase_Safe(Fota_S.Fota_Flash_Addres, (FLASH_BMS_FOTA_END_ADDR - FLASH_BMS_FOTA_START_ADDR)); // 512k-32k = 480k -> 0x75300  0x78000
 			}
 			memcpy(&Fota_Answer[4], (DataPtr + 4), BATT_SN_LEN);
 			Fota_Answer[21] = TCP_ENCPT_DISABLE;
@@ -1792,7 +1792,7 @@ void CanMsgTx1000ms()
 		count = TimeCounter % 10;
 		switch (count)
 		{
-		case 0: //send cell batt info 0x6A0、0x6A1
+		case 0: // send cell batt info 0x6A0、0x6A1
 			canMsg.DLC = 8;
 			canMsg.Id = COMOutTable[count * 2];
 			CANEncodeFunction(COMOutTable[count * 2], canMsg.Data);
@@ -1805,7 +1805,7 @@ void CanMsgTx1000ms()
 
 			break;
 
-		case 1: //send cell batt info 0x6A2、0x6A3
+		case 1: // send cell batt info 0x6A2、0x6A3
 			canMsg.DLC = 8;
 			canMsg.Id = COMOutTable[count * 2];
 			CANEncodeFunction(COMOutTable[count * 2], canMsg.Data);
@@ -1817,7 +1817,7 @@ void CanMsgTx1000ms()
 			HAL_Can_Transmit(canMsg);
 			break;
 
-		case 2: //send cell batt info 0x6A4、 0x6A5
+		case 2: // send cell batt info 0x6A4、 0x6A5
 			canMsg.DLC = 8;
 			canMsg.Id = COMOutTable[count * 2];
 			CANEncodeFunction(COMOutTable[count * 2], canMsg.Data);
@@ -1829,7 +1829,7 @@ void CanMsgTx1000ms()
 			HAL_Can_Transmit(canMsg);
 			break;
 
-		case 3: //send cell batt info 0x6A6、0x6B0
+		case 3: // send cell batt info 0x6A6、0x6B0
 			canMsg.DLC = 8;
 			canMsg.Id = COMOutTable[count * 2];
 			CANEncodeFunction(COMOutTable[count * 2], canMsg.Data);
@@ -1842,7 +1842,7 @@ void CanMsgTx1000ms()
 
 			break;
 
-		case 4: //send batt temp info 0x6BA、0x6C0
+		case 4: // send batt temp info 0x6BA、0x6C0
 			canMsg.DLC = 8;
 			canMsg.Id = COMOutTable[count * 2];
 			CANEncodeFunction(COMOutTable[count * 2], canMsg.Data);
@@ -1854,7 +1854,7 @@ void CanMsgTx1000ms()
 			HAL_Can_Transmit(canMsg);
 			break;
 
-		case 5: //send batt other info 0x6C1、0x6C2
+		case 5: // send batt other info 0x6C1、0x6C2
 			canMsg.DLC = 8;
 			canMsg.Id = COMOutTable[count * 2];
 			CANEncodeFunction(COMOutTable[count * 2], canMsg.Data);
@@ -1866,7 +1866,7 @@ void CanMsgTx1000ms()
 			HAL_Can_Transmit(canMsg);
 			break;
 
-		case 6: //send batt other info 0x6C3、0x6C4
+		case 6: // send batt other info 0x6C3、0x6C4
 			canMsg.DLC = 8;
 			canMsg.Id = COMOutTable[count * 2];
 			CANEncodeFunction(COMOutTable[count * 2], canMsg.Data);
@@ -2250,13 +2250,13 @@ void UDS_Service(CAN_Msg_Type *CanRxMsg)
 						UDSNegtiveAnswer(0x05, i, 0xFF);
 					}
 				}
-				else if (UDSSubService[i] == 0x11) //make NB software reset
+				else if (UDSSubService[i] == 0x11) // make NB software reset
 				{
 					if (UDSDialogMode == 2)
 					{
 						UDSPositiveAnswer(0x04, i, 0x00);
 						osDelay(100);
-						//SaveAppConfig();
+						// SaveAppConfig();
 						appSetCFUN(0);
 						osDelay(1000);
 						EC_SystemReset();
@@ -2271,7 +2271,7 @@ void UDS_Service(CAN_Msg_Type *CanRxMsg)
 					UDSNegtiveAnswer(0x05, i, 0xEE);
 				}
 				break;
-			case 0x14: //clear the DTC information 14 FF FF FF 00 00 00 00
+			case 0x14: // clear the DTC information 14 FF FF FF 00 00 00 00
 				if (UDSDialogMode == 2)
 				{
 					if (UDSSubService[i] == 0xFF)
@@ -2310,15 +2310,15 @@ void UDS_Service(CAN_Msg_Type *CanRxMsg)
 			case 0x22:
 				if (UDSDialogMode == 2)
 				{
-					if (UDSSubService[i] == 0x01) //check the sw of NB
+					if (UDSSubService[i] == 0x01) // check the sw of NB
 					{
 						UDSPositiveAnswer(0x08, i, APPSWVERSION);
 					}
-					else if (UDSSubService[i] == 0x02) //check the hw of NB
+					else if (UDSSubService[i] == 0x02) // check the hw of NB
 					{
 						UDSPositiveAnswer(0x06, i, HWVERSION);
 					}
-					else if (UDSSubService[i] == 0x03) //check the SN number
+					else if (UDSSubService[i] == 0x03) // check the SN number
 					{
 						switch (UDSSubServiceActionCode[i])
 						{
@@ -2347,27 +2347,27 @@ void UDS_Service(CAN_Msg_Type *CanRxMsg)
 							break;
 						}
 					}
-					else if (UDSSubService[i] == 0x04) //check the batt message
+					else if (UDSSubService[i] == 0x04) // check the batt message
 					{
 						UDSAnswer.Id = 0x7C0 + UDSSubServiceActionCode[i];
 						CANEncodeFunction(UDSAnswer.Id, UDSAnswer.Data);
 						ret = HAL_Can_Transmit(UDSAnswer);
 					}
-					else if (UDSSubService[i] == 0x05) //check the enviroment temp of NB
+					else if (UDSSubService[i] == 0x05) // check the enviroment temp of NB
 					{
 						UINT32 temp = ((fastChargeTemp << 24) & 0xFF000000) | ((normalChargeTemp << 16) & 0xFF0000) | ((heatTemp1 << 8) & 0xFF00) | (heatTemp2 & 0xFF);
-						UDSPositiveAnswer(0x08, i, temp); //ntcvalue
+						UDSPositiveAnswer(0x08, i, temp); // ntcvalue
 					}
-					else if (UDSSubService[i] == 0x06) //check the tcp link of NB
+					else if (UDSSubService[i] == 0x06) // check the tcp link of NB
 					{
-						UDSPositiveAnswer(0x06, i, TcpSendLen); //TcpconnectStatus
+						UDSPositiveAnswer(0x06, i, TcpSendLen); // TcpconnectStatus
 					}
-					else if (UDSSubService[i] == 0x07) //check the GPS link of NB
+					else if (UDSSubService[i] == 0x07) // check the GPS link of NB
 					{
 						posCode = GpsFlag;
-						UDSPositiveAnswer(0x05, i, posCode); //gps satellite num(uint8), should be modified
+						UDSPositiveAnswer(0x05, i, posCode); // gps satellite num(uint8), should be modified
 					}
-					else if (UDSSubService[i] == 0x0E) //read ram data  22 0E xx xx xx xx XX XX
+					else if (UDSSubService[i] == 0x0E) // read ram data  22 0E xx xx xx xx XX XX
 					{
 						// UINT16 size = CanRxMsg[i].Data[7] | (CanRxMsg[i].Data[6] << 8);
 						// UINT32 retData = 0xFFFFFFFF;
@@ -2412,12 +2412,12 @@ void UDS_Service(CAN_Msg_Type *CanRxMsg)
 						UDSNegtiveAnswer(0x05, i, 0xEE);
 					}
 				}
-				else //the service is not surpported in current dialog mode
+				else // the service is not surpported in current dialog mode
 				{
 					UDSNegtiveAnswer(0x05, i, 0xFF);
 				}
 				break;
-			case 0x2E: //write service
+			case 0x2E: // write service
 				if (UDSDialogMode == 2)
 				{
 					if (UDSSubService[i] == 0x03) // write the battSN
@@ -2460,7 +2460,7 @@ void UDS_Service(CAN_Msg_Type *CanRxMsg)
 							snFlag = 0;
 							UDSPositiveAnswer(0x04, i, 00);
 							MEMCPY(AppNVMData.battSN, UDSBattSN, BATT_SN_LEN);
-							AppNVMData.EOLState = 1; //SN号写入完成,表明已经进行过下线配置
+							AppNVMData.EOLState = 1; // SN号写入完成,表明已经进行过下线配置
 							SaveAppConfig();
 						}
 						else
@@ -2475,12 +2475,12 @@ void UDS_Service(CAN_Msg_Type *CanRxMsg)
 							ret = HAL_Can_Transmit(UDSAnswer);
 						}
 					}
-					else if (UDSSubService[i] == 0x0F) //write the update config:updateDifferDataByteLen
+					else if (UDSSubService[i] == 0x0F) // write the update config:updateDifferDataByteLen
 					{
 						updateDifferDataByteLen = (CanRxMsg[i].Data[2] << 16) | (CanRxMsg[i].Data[3] << 8) | CanRxMsg[i].Data[4];
 						UDSPositiveAnswer(0x04, i, 00);
 					}
-					else if (UDSSubService[i] == 0x0E) //write ram data  2E 0E xx xx xx xx XX XX
+					else if (UDSSubService[i] == 0x0E) // write ram data  2E 0E xx xx xx xx XX XX
 					{
 						UINT8 *addr = (UINT8 *)(CanRxMsg[i].Data[5] | (CanRxMsg[i].Data[4] << 8) | (CanRxMsg[i].Data[3] << 16) | (CanRxMsg[i].Data[2] << 24));
 						UINT8 data = CanRxMsg[i].Data[7];
@@ -2499,17 +2499,17 @@ void UDS_Service(CAN_Msg_Type *CanRxMsg)
 					UDSNegtiveAnswer(0x05, i, 0xFF);
 				}
 				break;
-			case 0x31: //clear the flash service and control heat or relay
+			case 0x31: // clear the flash service and control heat or relay
 				if (UDSDialogMode == 3)
 				{
-					if (UDSSubService[i] == 0x0F) //clear the fota flash
+					if (UDSSubService[i] == 0x0F) // clear the fota flash
 					{
 						if (UDSSubServiceActionCode[i] != 0x00 && UDSSubServiceActionCode[i] != 0xFF)
 						{
-							//Clear the Flash
+							// Clear the Flash
 							controllerFlag = UDSSubServiceActionCode[i];
 							boolRet = UDSClearFotaDownloadRegion(controllerFlag);
-							//if ok
+							// if ok
 							UDSPositiveAnswer(0x05, i, (UINT32)boolRet);
 						}
 						else
@@ -2517,9 +2517,9 @@ void UDS_Service(CAN_Msg_Type *CanRxMsg)
 							UDSNegtiveAnswer(0x06, i, UDSSubServiceActionCode[i] << 8 | 0xFF); //重点测试
 						}
 					}
-					else if (UDSSubService[i] == 0x11) //control the heater 31 10 00/01/02
+					else if (UDSSubService[i] == 0x11) // control the heater 31 10 00/01/02
 					{
-						if (UDSSubServiceActionCode[i] <= 0x02) //case 00/01/02
+						if (UDSSubServiceActionCode[i] <= 0x02) // case 00/01/02
 						{
 							HeatForceControl = UDSSubServiceActionCode[i];
 							UDSPositiveAnswer(0x05, i, HeatForceControl);
@@ -2529,9 +2529,9 @@ void UDS_Service(CAN_Msg_Type *CanRxMsg)
 							UDSNegtiveAnswer(0x05, i, UDSSubServiceActionCode[i]);
 						}
 					}
-					else if (UDSSubService[i] == 0x10) //control the main relay  31 11 00/01/02
+					else if (UDSSubService[i] == 0x10) // control the main relay  31 11 00/01/02
 					{
-						if (UDSSubServiceActionCode[i] <= 0x02) //case 00/01/02
+						if (UDSSubServiceActionCode[i] <= 0x02) // case 00/01/02
 						{
 							RelayForceControl = UDSSubServiceActionCode[i];
 							UDSPositiveAnswer(0x05, i, RelayForceControl);
@@ -2543,21 +2543,21 @@ void UDS_Service(CAN_Msg_Type *CanRxMsg)
 					}
 					else
 					{
-						UDSNegtiveAnswer(0x05, i, 0xEE); //the subservice is not surpported
+						UDSNegtiveAnswer(0x05, i, 0xEE); // the subservice is not surpported
 					}
 				}
 				else
 				{
-					UDSNegtiveAnswer(0x05, i, 0xFF); //the survie is not surpported in current dialog mode
+					UDSNegtiveAnswer(0x05, i, 0xFF); // the survie is not surpported in current dialog mode
 				}
 				break;
-			case 0x34: //prepare for some one process
+			case 0x34: // prepare for some one process
 				if (UDSDialogMode == 3)
 				{
-					if (UDSSubService[i] == 0x0F) //ask for download update data
+					if (UDSSubService[i] == 0x0F) // ask for download update data
 					{
 						boolRet = UDSAskforDownLoadData();
-						//if ok
+						// if ok
 						UDSPositiveAnswer(0x05, i, (UINT32)boolRet);
 					}
 					else
@@ -2570,7 +2570,7 @@ void UDS_Service(CAN_Msg_Type *CanRxMsg)
 					UDSNegtiveAnswer(0x05, i, 0xFF);
 				}
 				break;
-			case 0x36: //download the update data
+			case 0x36: // download the update data
 				if (UDSDialogMode == 3)
 				{
 					if (downloadReady == TRUE)
@@ -2612,9 +2612,9 @@ void UDS_Service(CAN_Msg_Type *CanRxMsg)
 						if (counter == 25)
 						{
 							counter = 0;
-							if (sliceCounterFlag == 0x1FFFFFF) //received all the 25 message of current package
+							if (sliceCounterFlag == 0x1FFFFFF) // received all the 25 message of current package
 							{
-								//write the buffer(100 byte) to flash
+								// write the buffer(100 byte) to flash
 								if (controllerFlag == 0x01)
 								{
 									flashStartAddr = FLASH_FOTA_REGION_START;
@@ -2631,7 +2631,7 @@ void UDS_Service(CAN_Msg_Type *CanRxMsg)
 
 								ret = (uint8_t)BSP_QSPI_Write_Safe(updateDataBuffer, flashStartAddr + (updateDifferDataPackageCounter)*100, 100);
 								errorCount = 0;
-								while (ret != QSPI_OK && errorCount < 3) //try to write most 3 times
+								while (ret != QSPI_OK && errorCount < 3) // try to write most 3 times
 								{
 									errorCount++;
 									BSP_QSPI_Erase_Safe(flashStartAddr + (updateDifferDataPackageCounter)*100, 100);
@@ -2645,38 +2645,38 @@ void UDS_Service(CAN_Msg_Type *CanRxMsg)
 									sliceCounterFlag = 0x0;
 									updateDifferDataPackageCounter++;
 								}
-								else //write fail
+								else // write fail
 								{
-									UDSNegtiveAnswer(0x08, i, 0xFFFFFFFF); //failed to write this package to flash
+									UDSNegtiveAnswer(0x08, i, 0xFFFFFFFF); // failed to write this package to flash
 								}
 							}
 							else
 							{
-								//received 25 messages, but lose one or more messages
-								//in this case, updater will try to send the package again(most 4 times)
+								// received 25 messages, but lose one or more messages
+								// in this case, updater will try to send the package again(most 4 times)
 								UDSNegtiveAnswer(0x08, i, sliceCounterFlag);
 							}
 						}
 					}
 					else
 					{
-						UDSNegtiveAnswer(0x05, i, 0xEF); //the download process is not ready
+						UDSNegtiveAnswer(0x05, i, 0xEF); // the download process is not ready
 						counter = 0;
 					}
 				}
 				else
 				{
-					UDSNegtiveAnswer(0x05, i, 0xFF); //the service is not surpported in current dialog mode
+					UDSNegtiveAnswer(0x05, i, 0xFF); // the service is not surpported in current dialog mode
 				}
 				break;
-			case 0x37: //exit some one process
+			case 0x37: // exit some one process
 				if (UDSDialogMode == 3)
 				{
 					if (UDSSubService[i] == 0x0F) // exit the download
 					{
 						if (UDSSubServiceActionCode[i] == controllerFlag)
 						{
-							if (controllerFlag == 0x02 || controllerFlag == 0x03) //update bms
+							if (controllerFlag == 0x02 || controllerFlag == 0x03) // update bms
 							{
 								BMS_Fota_update_flag = true;
 							}
@@ -2699,7 +2699,7 @@ void UDS_Service(CAN_Msg_Type *CanRxMsg)
 				}
 				break;
 			default:
-				UDSNegtiveAnswer(0x04, i, 0xFF); //the service is not surpported
+				UDSNegtiveAnswer(0x04, i, 0xFF); // the service is not surpported
 				break;
 			}
 		}
@@ -2845,7 +2845,7 @@ BOOL UDSClearFotaDownloadRegion(UINT8 controllerFlag)
 	UINT8 ret = FALSE;
 	if (controllerFlag == 0x01)
 	{
-		ret = BSP_QSPI_Erase_Safe(FLASH_FOTA_REGION_START, 0x46000); //512k-32k -200k = 280k -> 0x46000
+		ret = BSP_QSPI_Erase_Safe(FLASH_FOTA_REGION_START, 0x46000); // 512k-32k -200k = 280k -> 0x46000
 	}
 	else if (controllerFlag == 0x02 || controllerFlag == 0x03)
 	{