|
@@ -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;
|
|
|
-
|
|
|
+
|
|
|
if (battProtectState == 0x00)
|
|
|
{
|
|
|
*DischargeProtect = 0;
|
|
@@ -31,91 +31,91 @@ void BmsProtectStateDecode(UINT8 *DischargeProtect, UINT8 *ChargeProtect)
|
|
|
if (ret)
|
|
|
{
|
|
|
*DischargeProtect = (*DischargeProtect) + 1;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
ret = getbit(battProtectState, 1);
|
|
|
if (ret)
|
|
|
{
|
|
|
*DischargeProtect = (*DischargeProtect) + 1;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
ret = getbit(battProtectState, 2);
|
|
|
if (ret)
|
|
|
{
|
|
|
*ChargeProtect = (*ChargeProtect) + 1;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
ret = getbit(battProtectState, 8);
|
|
|
if (ret)
|
|
|
{
|
|
|
*DischargeProtect = (*DischargeProtect) + 1;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
ret = getbit(battProtectState, 9);
|
|
|
if (ret)
|
|
|
{
|
|
|
*DischargeProtect = (*DischargeProtect) + 1;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
ret = getbit(battProtectState, 16);
|
|
|
if (ret)
|
|
|
{
|
|
|
*ChargeProtect = (*ChargeProtect) + 1;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
ret = getbit(battProtectState, 17);
|
|
|
if (ret)
|
|
|
{
|
|
|
*ChargeProtect = (*ChargeProtect) + 1;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
ret = getbit(battProtectState, 18);
|
|
|
- if (ret)
|
|
|
+ if (ret)
|
|
|
{
|
|
|
*ChargeProtect = (*ChargeProtect) + 1;
|
|
|
*DischargeProtect = (*DischargeProtect) + 1;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
ret = getbit(battProtectState, 20);
|
|
|
if (ret)
|
|
|
{
|
|
|
*DischargeProtect = (*DischargeProtect) + 1;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
ret = getbit(battProtectState, 21);
|
|
|
if (ret)
|
|
|
{
|
|
|
*DischargeProtect = (*DischargeProtect) + 1;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
ret = getbit(battProtectState, 24);
|
|
|
if (ret)
|
|
|
{
|
|
|
*ChargeProtect = (*ChargeProtect) + 1;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
ret = getbit(battProtectState, 25);
|
|
|
if (ret)
|
|
|
{
|
|
|
*ChargeProtect = (*ChargeProtect) + 1;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
ret = getbit(battProtectState, 28);
|
|
|
if (ret)
|
|
|
{
|
|
|
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -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)
|
|
|
+ if (battWorkCurrentState == BATT_IDLE_SYM && BattWorkStateDelay == BATT_DISCHARGE_SYM)
|
|
|
{
|
|
|
workDelayCounter++;
|
|
|
- if (workDelayCounter >= 10)
|
|
|
+ if (workDelayCounter >= 60)
|
|
|
{
|
|
|
workDelayCounter = 0;
|
|
|
BattWorkStateDelay = battWorkCurrentState;
|
|
@@ -461,7 +461,7 @@ UINT8 LookUpRTtable(UINT32 R_value)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
if (R_value <= R_Table2[216])
|
|
@@ -486,7 +486,7 @@ UINT8 LookUpRTtable(UINT32 R_value)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
* @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;
|
|
|
+ UINT16 LEDFlashPeriod = 1000;
|
|
|
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;
|
|
|
|
|
|
-
|
|
|
+
|
|
|
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;
|
|
|
+ battPackVol = ((dataPtr[(0x18 + BATT_CELL_VOL_NUM + TEMP_NUM) * 2]) << 8 | (dataPtr[(0x18 + BATT_CELL_VOL_NUM + TEMP_NUM) * 2 + 1])) / 10;
|
|
|
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");
|
|
|
+ fp = OsaFopen(APP_DATAINFO_FILE_NAME, "wb");
|
|
|
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");
|
|
|
+ fp = OsaFopen(BCU_DATAINFO_FILE_NAME, "wb");
|
|
|
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");
|
|
|
+ fp = OsaFopen(APP_DATAINFO_FILE_NAME, "rb");
|
|
|
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);
|
|
|
-
|
|
|
+
|
|
|
readtimes = 0;
|
|
|
while (readtimes <= 5 && readCount != 1)
|
|
|
{
|
|
|
readtimes++;
|
|
|
readCount = OsaFread(pReadAppConfig, AppDataHr.fileBodySize, 1, fp);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
setDefaultAppDataInfo();
|
|
|
readCount = OsaFread(pReadAppConfig, AppDataHr.fileBodySize, 1, fp);
|
|
|
-
|
|
|
+
|
|
|
readtimes = 0;
|
|
|
while (readtimes <= 5 && readCount != 1)
|
|
|
{
|
|
|
readtimes++;
|
|
|
readCount = OsaFread(pReadAppConfig, AppDataHr.fileBodySize, 1, fp);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
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");
|
|
|
+ fp = OsaFopen(BCU_DATAINFO_FILE_NAME, "rb");
|
|
|
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);
|
|
|
-
|
|
|
+
|
|
|
readtimes = 0;
|
|
|
while (readtimes <= 5 && readCount != 1)
|
|
|
{
|
|
|
readtimes++;
|
|
|
readCount = OsaFread(pReadAppConfig, BcuDataHr.fileBodySize, 1, fp);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
setDefaultBcuDataInfo();
|
|
|
readCount = OsaFread(pReadAppConfig, BcuDataHr.fileBodySize, 1, fp);
|
|
|
-
|
|
|
+
|
|
|
readtimes = 0;
|
|
|
while (readtimes <= 5 && readCount != 1)
|
|
|
{
|
|
|
readtimes++;
|
|
|
readCount = OsaFread(pReadAppConfig, BcuDataHr.fileBodySize, 1, fp);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
SaveBcuData();
|
|
|
#ifdef USING_PRINTF
|
|
@@ -1213,12 +1213,12 @@ void SaveAppConfig(void)
|
|
|
{
|
|
|
OSAFILE fp = PNULL;
|
|
|
UINT32 writeCount = 0;
|
|
|
- AppConfigDataHeader AppConfigHr;
|
|
|
+ AppConfigDataHeader AppConfigHr;
|
|
|
|
|
|
- * open the NVM file
|
|
|
- */
|
|
|
+ * open the NVM file
|
|
|
+ */
|
|
|
AppNVMData.appDataModify = FALSE;
|
|
|
- fp = OsaFopen(APP_CONFIG_FILE_NAME, "wb");
|
|
|
+ fp = OsaFopen(APP_CONFIG_FILE_NAME, "wb");
|
|
|
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");
|
|
|
+ * open the NVM file
|
|
|
+ */
|
|
|
+ fp = OsaFopen(APP_CONFIG_FILE_NAME, "rb");
|
|
|
|
|
|
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))
|
|
|
+ if (AppConfigHr.fileBodySize != sizeof(AppNVMData))
|
|
|
{
|
|
|
#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 && 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));
|
|
|
+ BSP_QSPI_Erase_Safe(Fota_S.Fota_Flash_Addres, (FLASH_BMS_FOTA_START_ADDR - FLASH_FOTA_REGION_START));
|
|
|
}
|
|
|
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)
|
|
|
+ else if (*(DataPtr + 30) == 0x88)
|
|
|
{
|
|
|
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));
|
|
|
+ BSP_QSPI_Erase_Safe(Fota_S.Fota_Flash_Addres, (FLASH_BMS_FOTA_END_ADDR - FLASH_BMS_FOTA_START_ADDR));
|
|
|
}
|
|
|
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:
|
|
|
+ case 0:
|
|
|
canMsg.DLC = 8;
|
|
|
canMsg.Id = COMOutTable[count * 2];
|
|
|
CANEncodeFunction(COMOutTable[count * 2], canMsg.Data);
|
|
@@ -1805,7 +1805,7 @@ void CanMsgTx1000ms()
|
|
|
|
|
|
break;
|
|
|
|
|
|
- case 1:
|
|
|
+ case 1:
|
|
|
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:
|
|
|
+ case 2:
|
|
|
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:
|
|
|
+ case 3:
|
|
|
canMsg.DLC = 8;
|
|
|
canMsg.Id = COMOutTable[count * 2];
|
|
|
CANEncodeFunction(COMOutTable[count * 2], canMsg.Data);
|
|
@@ -1842,7 +1842,7 @@ void CanMsgTx1000ms()
|
|
|
|
|
|
break;
|
|
|
|
|
|
- case 4:
|
|
|
+ case 4:
|
|
|
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:
|
|
|
+ case 5:
|
|
|
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:
|
|
|
+ case 6:
|
|
|
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)
|
|
|
+ else if (UDSSubService[i] == 0x11)
|
|
|
{
|
|
|
if (UDSDialogMode == 2)
|
|
|
{
|
|
|
UDSPositiveAnswer(0x04, i, 0x00);
|
|
|
osDelay(100);
|
|
|
-
|
|
|
+
|
|
|
appSetCFUN(0);
|
|
|
osDelay(1000);
|
|
|
EC_SystemReset();
|
|
@@ -2271,7 +2271,7 @@ void UDS_Service(CAN_Msg_Type *CanRxMsg)
|
|
|
UDSNegtiveAnswer(0x05, i, 0xEE);
|
|
|
}
|
|
|
break;
|
|
|
- case 0x14:
|
|
|
+ case 0x14:
|
|
|
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)
|
|
|
+ if (UDSSubService[i] == 0x01)
|
|
|
{
|
|
|
UDSPositiveAnswer(0x08, i, APPSWVERSION);
|
|
|
}
|
|
|
- else if (UDSSubService[i] == 0x02)
|
|
|
+ else if (UDSSubService[i] == 0x02)
|
|
|
{
|
|
|
UDSPositiveAnswer(0x06, i, HWVERSION);
|
|
|
}
|
|
|
- else if (UDSSubService[i] == 0x03)
|
|
|
+ else if (UDSSubService[i] == 0x03)
|
|
|
{
|
|
|
switch (UDSSubServiceActionCode[i])
|
|
|
{
|
|
@@ -2347,27 +2347,27 @@ void UDS_Service(CAN_Msg_Type *CanRxMsg)
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- else if (UDSSubService[i] == 0x04)
|
|
|
+ else if (UDSSubService[i] == 0x04)
|
|
|
{
|
|
|
UDSAnswer.Id = 0x7C0 + UDSSubServiceActionCode[i];
|
|
|
CANEncodeFunction(UDSAnswer.Id, UDSAnswer.Data);
|
|
|
ret = HAL_Can_Transmit(UDSAnswer);
|
|
|
}
|
|
|
- else if (UDSSubService[i] == 0x05)
|
|
|
+ else if (UDSSubService[i] == 0x05)
|
|
|
{
|
|
|
UINT32 temp = ((fastChargeTemp << 24) & 0xFF000000) | ((normalChargeTemp << 16) & 0xFF0000) | ((heatTemp1 << 8) & 0xFF00) | (heatTemp2 & 0xFF);
|
|
|
- UDSPositiveAnswer(0x08, i, temp);
|
|
|
+ UDSPositiveAnswer(0x08, i, temp);
|
|
|
}
|
|
|
- else if (UDSSubService[i] == 0x06)
|
|
|
+ else if (UDSSubService[i] == 0x06)
|
|
|
{
|
|
|
- UDSPositiveAnswer(0x06, i, TcpSendLen);
|
|
|
+ UDSPositiveAnswer(0x06, i, TcpSendLen);
|
|
|
}
|
|
|
- else if (UDSSubService[i] == 0x07)
|
|
|
+ else if (UDSSubService[i] == 0x07)
|
|
|
{
|
|
|
posCode = GpsFlag;
|
|
|
- UDSPositiveAnswer(0x05, i, posCode);
|
|
|
+ UDSPositiveAnswer(0x05, i, posCode);
|
|
|
}
|
|
|
- else if (UDSSubService[i] == 0x0E)
|
|
|
+ else if (UDSSubService[i] == 0x0E)
|
|
|
{
|
|
|
|
|
|
|
|
@@ -2412,12 +2412,12 @@ void UDS_Service(CAN_Msg_Type *CanRxMsg)
|
|
|
UDSNegtiveAnswer(0x05, i, 0xEE);
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
+ else
|
|
|
{
|
|
|
UDSNegtiveAnswer(0x05, i, 0xFF);
|
|
|
}
|
|
|
break;
|
|
|
- case 0x2E:
|
|
|
+ case 0x2E:
|
|
|
if (UDSDialogMode == 2)
|
|
|
{
|
|
|
if (UDSSubService[i] == 0x03)
|
|
@@ -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;
|
|
|
+ AppNVMData.EOLState = 1;
|
|
|
SaveAppConfig();
|
|
|
}
|
|
|
else
|
|
@@ -2475,12 +2475,12 @@ void UDS_Service(CAN_Msg_Type *CanRxMsg)
|
|
|
ret = HAL_Can_Transmit(UDSAnswer);
|
|
|
}
|
|
|
}
|
|
|
- else if (UDSSubService[i] == 0x0F)
|
|
|
+ else if (UDSSubService[i] == 0x0F)
|
|
|
{
|
|
|
updateDifferDataByteLen = (CanRxMsg[i].Data[2] << 16) | (CanRxMsg[i].Data[3] << 8) | CanRxMsg[i].Data[4];
|
|
|
UDSPositiveAnswer(0x04, i, 00);
|
|
|
}
|
|
|
- else if (UDSSubService[i] == 0x0E)
|
|
|
+ else if (UDSSubService[i] == 0x0E)
|
|
|
{
|
|
|
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:
|
|
|
+ case 0x31:
|
|
|
if (UDSDialogMode == 3)
|
|
|
{
|
|
|
- if (UDSSubService[i] == 0x0F)
|
|
|
+ if (UDSSubService[i] == 0x0F)
|
|
|
{
|
|
|
if (UDSSubServiceActionCode[i] != 0x00 && UDSSubServiceActionCode[i] != 0xFF)
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
controllerFlag = UDSSubServiceActionCode[i];
|
|
|
boolRet = UDSClearFotaDownloadRegion(controllerFlag);
|
|
|
-
|
|
|
+
|
|
|
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)
|
|
|
+ else if (UDSSubService[i] == 0x11)
|
|
|
{
|
|
|
- if (UDSSubServiceActionCode[i] <= 0x02)
|
|
|
+ if (UDSSubServiceActionCode[i] <= 0x02)
|
|
|
{
|
|
|
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)
|
|
|
+ else if (UDSSubService[i] == 0x10)
|
|
|
{
|
|
|
- if (UDSSubServiceActionCode[i] <= 0x02)
|
|
|
+ if (UDSSubServiceActionCode[i] <= 0x02)
|
|
|
{
|
|
|
RelayForceControl = UDSSubServiceActionCode[i];
|
|
|
UDSPositiveAnswer(0x05, i, RelayForceControl);
|
|
@@ -2543,21 +2543,21 @@ void UDS_Service(CAN_Msg_Type *CanRxMsg)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- UDSNegtiveAnswer(0x05, i, 0xEE);
|
|
|
+ UDSNegtiveAnswer(0x05, i, 0xEE);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- UDSNegtiveAnswer(0x05, i, 0xFF);
|
|
|
+ UDSNegtiveAnswer(0x05, i, 0xFF);
|
|
|
}
|
|
|
break;
|
|
|
- case 0x34:
|
|
|
+ case 0x34:
|
|
|
if (UDSDialogMode == 3)
|
|
|
{
|
|
|
- if (UDSSubService[i] == 0x0F)
|
|
|
+ if (UDSSubService[i] == 0x0F)
|
|
|
{
|
|
|
boolRet = UDSAskforDownLoadData();
|
|
|
-
|
|
|
+
|
|
|
UDSPositiveAnswer(0x05, i, (UINT32)boolRet);
|
|
|
}
|
|
|
else
|
|
@@ -2570,7 +2570,7 @@ void UDS_Service(CAN_Msg_Type *CanRxMsg)
|
|
|
UDSNegtiveAnswer(0x05, i, 0xFF);
|
|
|
}
|
|
|
break;
|
|
|
- case 0x36:
|
|
|
+ case 0x36:
|
|
|
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)
|
|
|
+ if (sliceCounterFlag == 0x1FFFFFF)
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
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)
|
|
|
+ while (ret != QSPI_OK && errorCount < 3)
|
|
|
{
|
|
|
errorCount++;
|
|
|
BSP_QSPI_Erase_Safe(flashStartAddr + (updateDifferDataPackageCounter)*100, 100);
|
|
@@ -2645,38 +2645,38 @@ void UDS_Service(CAN_Msg_Type *CanRxMsg)
|
|
|
sliceCounterFlag = 0x0;
|
|
|
updateDifferDataPackageCounter++;
|
|
|
}
|
|
|
- else
|
|
|
+ else
|
|
|
{
|
|
|
- UDSNegtiveAnswer(0x08, i, 0xFFFFFFFF);
|
|
|
+ UDSNegtiveAnswer(0x08, i, 0xFFFFFFFF);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
UDSNegtiveAnswer(0x08, i, sliceCounterFlag);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- UDSNegtiveAnswer(0x05, i, 0xEF);
|
|
|
+ UDSNegtiveAnswer(0x05, i, 0xEF);
|
|
|
counter = 0;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- UDSNegtiveAnswer(0x05, i, 0xFF);
|
|
|
+ UDSNegtiveAnswer(0x05, i, 0xFF);
|
|
|
}
|
|
|
break;
|
|
|
- case 0x37:
|
|
|
+ case 0x37:
|
|
|
if (UDSDialogMode == 3)
|
|
|
{
|
|
|
if (UDSSubService[i] == 0x0F)
|
|
|
{
|
|
|
if (UDSSubServiceActionCode[i] == controllerFlag)
|
|
|
{
|
|
|
- if (controllerFlag == 0x02 || controllerFlag == 0x03)
|
|
|
+ if (controllerFlag == 0x02 || controllerFlag == 0x03)
|
|
|
{
|
|
|
BMS_Fota_update_flag = true;
|
|
|
}
|
|
@@ -2699,7 +2699,7 @@ void UDS_Service(CAN_Msg_Type *CanRxMsg)
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
|
- UDSNegtiveAnswer(0x04, i, 0xFF);
|
|
|
+ UDSNegtiveAnswer(0x04, i, 0xFF);
|
|
|
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);
|
|
|
+ ret = BSP_QSPI_Erase_Safe(FLASH_FOTA_REGION_START, 0x46000);
|
|
|
}
|
|
|
else if (controllerFlag == 0x02 || controllerFlag == 0x03)
|
|
|
{
|