|
@@ -2,7 +2,7 @@
|
|
* @Author : ChenJie
|
|
* @Author : ChenJie
|
|
* @Date : 2021-10-14 09:27:15
|
|
* @Date : 2021-10-14 09:27:15
|
|
* @LastEditors : ChenJie
|
|
* @LastEditors : ChenJie
|
|
- * @LastEditTime : 2021-11-16 21:38:19
|
|
|
|
|
|
+ * @LastEditTime : 2022-01-04 18:36:45
|
|
* @Description : file content
|
|
* @Description : file content
|
|
* @FilePath : \PLAT\project\ec616_0h00\apps\qx_app\src\AppTaskUart.c
|
|
* @FilePath : \PLAT\project\ec616_0h00\apps\qx_app\src\AppTaskUart.c
|
|
*/
|
|
*/
|
|
@@ -38,7 +38,7 @@ static void UartTask(void *arg)
|
|
UINT8 ret = 0x00;
|
|
UINT8 ret = 0x00;
|
|
UINT8 EncryptFlag = 0x00;
|
|
UINT8 EncryptFlag = 0x00;
|
|
UINT8 EncryptCount = 0;
|
|
UINT8 EncryptCount = 0;
|
|
- if (UartWriteCmdHandle == NULL) //Uart控制命令传输指针
|
|
|
|
|
|
+ if (UartWriteCmdHandle == NULL) // Uart控制命令传输指针
|
|
{
|
|
{
|
|
UartWriteCmdHandle = osMessageQueueNew(1, sizeof(UartWriteData_S), NULL);
|
|
UartWriteCmdHandle = osMessageQueueNew(1, sizeof(UartWriteData_S), NULL);
|
|
}
|
|
}
|
|
@@ -92,7 +92,7 @@ static void UartTask(void *arg)
|
|
|
|
|
|
if (TimeCounter % 10 == 0 && gProcess_app == WORK)
|
|
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));
|
|
memset(&(UartWriteDataHandleRecv), 0x00, sizeof(UartWriteDataHandleRecv));
|
|
if (osMessageQueueGet(UartWriteCmdHandle, &UartWriteDataHandleRecv, 0, 10) == osOK && UartRecvFlag == 1)
|
|
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)
|
|
void Uart_Cmd_Control(QueueHandle_t UartWriteCmdHandle, UartBuffer UartAnswerData)
|
|
{
|
|
{
|
|
UartWriteData_S UartWriteData;
|
|
UartWriteData_S UartWriteData;
|
|
- memset(&(UartWriteData), 0x00, sizeof(UartWriteData_S)); //Uart控制命令初始化
|
|
|
|
|
|
+ memset(&(UartWriteData), 0x00, sizeof(UartWriteData_S)); // Uart控制命令初始化
|
|
UINT8 HeatSwitch = 0;
|
|
UINT8 HeatSwitch = 0;
|
|
UINT8 ChargePermitState = 1;
|
|
UINT8 ChargePermitState = 1;
|
|
UINT8 DischargePermitState = 1;
|
|
UINT8 DischargePermitState = 1;
|
|
@@ -295,7 +295,7 @@ void Uart_Cmd_Control(QueueHandle_t UartWriteCmdHandle, UartBuffer UartAnswerDat
|
|
//控制充电禁止
|
|
//控制充电禁止
|
|
if (getbit(BcuFltAct, 6) == 0)
|
|
if (getbit(BcuFltAct, 6) == 0)
|
|
{
|
|
{
|
|
- if ((maxCellVol > 4190 && maxCellVol < 5000) && battSOC >= 99)
|
|
|
|
|
|
+ if (maxCellVol > 4190 && maxCellVol < 5000 && BattWorkStateDelay == BATT_CHARGE_SYM)
|
|
{
|
|
{
|
|
ChargeForbiddenControl = 1;
|
|
ChargeForbiddenControl = 1;
|
|
}
|
|
}
|
|
@@ -303,6 +303,10 @@ void Uart_Cmd_Control(QueueHandle_t UartWriteCmdHandle, UartBuffer UartAnswerDat
|
|
{
|
|
{
|
|
ChargeForbiddenControl = 0;
|
|
ChargeForbiddenControl = 0;
|
|
}
|
|
}
|
|
|
|
+ else if (maxCellVol > 4150 && maxCellVol < 5000 && BattWorkStateDelay == BATT_IDLE_SYM)
|
|
|
|
+ {
|
|
|
|
+ ChargeForbiddenControl = 1;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
else if (getbit(BcuFltAct, 6) == 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;
|
|
RelayForbiddenControl = 0;
|
|
AppDataInfo.appDataModify = TRUE;
|
|
AppDataInfo.appDataModify = TRUE;
|
|
AppDataInfo.RelayControl = FALSE;
|
|
AppDataInfo.RelayControl = FALSE;
|
|
}
|
|
}
|
|
- else if (RelayForceControl == 2) //open
|
|
|
|
|
|
+ else if (RelayForceControl == 2) // open
|
|
{
|
|
{
|
|
RelayForbiddenControl = 1;
|
|
RelayForbiddenControl = 1;
|
|
AppDataInfo.appDataModify = TRUE;
|
|
AppDataInfo.appDataModify = TRUE;
|
|
@@ -363,7 +367,7 @@ void Uart_Cmd_Control(QueueHandle_t UartWriteCmdHandle, UartBuffer UartAnswerDat
|
|
UartWriteData.Data[1] = HeatSwitch & 0xFF;
|
|
UartWriteData.Data[1] = HeatSwitch & 0xFF;
|
|
osMessageQueuePut(UartWriteCmdHandle, &UartWriteData, 0, 10);
|
|
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
|
|
#ifdef USING_PRINTF1
|
|
printf("[%d]try to lock charge \n", __LINE__);
|
|
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;
|
|
UartWriteData.Data[1] = 0x00 | DischargePermitState;
|
|
osMessageQueuePut(UartWriteCmdHandle, &UartWriteData, 0, 10);
|
|
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
|
|
#ifdef USING_PRINTF1
|
|
printf("[%d]try to unlock charge \n", __LINE__);
|
|
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;
|
|
UartWriteData.Data[1] = 0x02 | DischargePermitState;
|
|
osMessageQueuePut(UartWriteCmdHandle, &UartWriteData, 0, 10);
|
|
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.WriteCmd = 0x01;
|
|
UartWriteData.Data[0] = (RelayControlState << 7) | 0x00;
|
|
UartWriteData.Data[0] = (RelayControlState << 7) | 0x00;
|
|
@@ -574,8 +578,8 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
|
|
UINT32 currentPackageStartAddr = 0;
|
|
UINT32 currentPackageStartAddr = 0;
|
|
BMS_Update_Recv_Msg_Type pUpdateMsgRecv;
|
|
BMS_Update_Recv_Msg_Type pUpdateMsgRecv;
|
|
UINT8 bmsUpdateFlag = 1;
|
|
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;
|
|
UINT8 Cycle_conut = 0;
|
|
while (bmsUpdateFlag && Cycle_conut < 2)
|
|
while (bmsUpdateFlag && Cycle_conut < 2)
|
|
{
|
|
{
|
|
@@ -585,17 +589,17 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
|
|
|
|
|
|
dataLen = 0;
|
|
dataLen = 0;
|
|
updateMsgSendLen = 7;
|
|
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));
|
|
memset((UINT8 *)(&pUpdateMsgRecv), 0, sizeof(BMS_Update_Recv_Msg_Type));
|
|
ret = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), sizeof(BMS_Update_Recv_Msg_Type), 500);
|
|
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 (ret != 0)
|
|
{
|
|
{
|
|
if (pUpdateMsgRecv.startFlag == 0xEB && pUpdateMsgRecv.endFlag == 0xF5)
|
|
if (pUpdateMsgRecv.startFlag == 0xEB && pUpdateMsgRecv.endFlag == 0xF5)
|
|
@@ -628,7 +632,7 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
|
|
errorCount++;
|
|
errorCount++;
|
|
}
|
|
}
|
|
#ifdef USING_PRINTF1
|
|
#ifdef USING_PRINTF1
|
|
- //printf("update step:%d\n",updateStep);
|
|
|
|
|
|
+ // printf("update step:%d\n",updateStep);
|
|
printf("query:");
|
|
printf("query:");
|
|
|
|
|
|
for (j = 0; j < updateMsgSendLen; j++)
|
|
for (j = 0; j < updateMsgSendLen; j++)
|
|
@@ -655,14 +659,14 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
|
|
case UPDATE_STEP_REQUEST_UPDATE:
|
|
case UPDATE_STEP_REQUEST_UPDATE:
|
|
dataLen = 1;
|
|
dataLen = 1;
|
|
updateMsgSendLen = 8;
|
|
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));
|
|
memset((UINT8 *)(&pUpdateMsgRecv), 0, sizeof(BMS_Update_Recv_Msg_Type));
|
|
ret = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), sizeof(BMS_Update_Recv_Msg_Type), 500);
|
|
ret = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), sizeof(BMS_Update_Recv_Msg_Type), 500);
|
|
if (ret != 0)
|
|
if (ret != 0)
|
|
@@ -723,18 +727,18 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
|
|
case UPDATE_STEP_START_UPDATE:
|
|
case UPDATE_STEP_START_UPDATE:
|
|
dataLen = 1;
|
|
dataLen = 1;
|
|
updateMsgSendLen = 8;
|
|
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));
|
|
memset((UINT8 *)(&pUpdateMsgRecv), 0, sizeof(BMS_Update_Recv_Msg_Type));
|
|
ret = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), 0, 500);
|
|
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
|
|
#ifdef USING_PRINTF1
|
|
|
|
|
|
printf("query:");
|
|
printf("query:");
|
|
@@ -755,17 +759,17 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
|
|
case UPDATE_STEP_CHECK_VERSION_AGAIN:
|
|
case UPDATE_STEP_CHECK_VERSION_AGAIN:
|
|
dataLen = 0;
|
|
dataLen = 0;
|
|
updateMsgSendLen = 7;
|
|
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));
|
|
memset((UINT8 *)(&pUpdateMsgRecv), 0, sizeof(BMS_Update_Recv_Msg_Type));
|
|
ret = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), sizeof(BMS_Update_Recv_Msg_Type), 100);
|
|
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 (ret != 0)
|
|
{
|
|
{
|
|
if (pUpdateMsgRecv.startFlag == 0xEB && pUpdateMsgRecv.endFlag == 0xF5)
|
|
if (pUpdateMsgRecv.startFlag == 0xEB && pUpdateMsgRecv.endFlag == 0xF5)
|
|
@@ -798,7 +802,7 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
|
|
errorCount++;
|
|
errorCount++;
|
|
}
|
|
}
|
|
#ifdef USING_PRINTF1
|
|
#ifdef USING_PRINTF1
|
|
- //printf("update step:%d\n",updateStep);
|
|
|
|
|
|
+ // printf("update step:%d\n",updateStep);
|
|
printf("query:");
|
|
printf("query:");
|
|
|
|
|
|
for (j = 0; j < updateMsgSendLen; j++)
|
|
for (j = 0; j < updateMsgSendLen; j++)
|
|
@@ -825,18 +829,18 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
|
|
printf("start step %d\n", updateStep);
|
|
printf("start step %d\n", updateStep);
|
|
dataLen = 4;
|
|
dataLen = 4;
|
|
updateMsgSendLen = 12;
|
|
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[7] = 0x00;
|
|
pUpdateMsgSend[8] = 0x25;
|
|
pUpdateMsgSend[8] = 0x25;
|
|
pUpdateMsgSend[9] = 0x80;
|
|
pUpdateMsgSend[9] = 0x80;
|
|
- pUpdateMsgSend[10] = 0x61; //check
|
|
|
|
- pUpdateMsgSend[11] = 0xF5; //end flag
|
|
|
|
|
|
+ pUpdateMsgSend[10] = 0x61; // check
|
|
|
|
+ pUpdateMsgSend[11] = 0xF5; // end flag
|
|
#ifdef USING_PRINTF1
|
|
#ifdef USING_PRINTF1
|
|
printf("query:");
|
|
printf("query:");
|
|
for (j = 0; j < updateMsgSendLen; j++)
|
|
for (j = 0; j < updateMsgSendLen; j++)
|
|
@@ -886,7 +890,7 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
|
|
}
|
|
}
|
|
|
|
|
|
#ifdef USING_PRINTF1
|
|
#ifdef USING_PRINTF1
|
|
- //printf("update step:%d\n",updateStep);
|
|
|
|
|
|
+ // printf("update step:%d\n",updateStep);
|
|
printf("query:");
|
|
printf("query:");
|
|
for (j = 0; j < updateMsgSendLen; j++)
|
|
for (j = 0; j < updateMsgSendLen; j++)
|
|
{
|
|
{
|
|
@@ -907,14 +911,14 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
|
|
printf("start step %d\n", updateStep);
|
|
printf("start step %d\n", updateStep);
|
|
dataLen = 1;
|
|
dataLen = 1;
|
|
updateMsgSendLen = 8;
|
|
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));
|
|
memset((UINT8 *)(&pUpdateMsgRecv), 0, sizeof(BMS_Update_Recv_Msg_Type));
|
|
ret = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), sizeof(BMS_Update_Recv_Msg_Type), 500);
|
|
ret = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), sizeof(BMS_Update_Recv_Msg_Type), 500);
|
|
if (ret != 0)
|
|
if (ret != 0)
|
|
@@ -955,7 +959,7 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
|
|
}
|
|
}
|
|
|
|
|
|
#ifdef USING_PRINTF1
|
|
#ifdef USING_PRINTF1
|
|
- //printf("update step:%d\n",updateStep);
|
|
|
|
|
|
+ // printf("update step:%d\n",updateStep);
|
|
printf("query:");
|
|
printf("query:");
|
|
for (j = 0; j < updateMsgSendLen; j++)
|
|
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);
|
|
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));
|
|
updateDataTotalByteLen = (((updateDataTotalByteLen)&0xFF) << 24) | (((updateDataTotalByteLen >> 8) & 0xFF) << 16) | (((updateDataTotalByteLen >> 16) & 0xFF) << 8) | (((updateDataTotalByteLen >> 24) & 0xFF));
|
|
updateMsgSendLen = 11;
|
|
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[6] = (updateDataTotalByteLen >> 16) & 0xFF;
|
|
pUpdateMsgSend[7] = (updateDataTotalByteLen >> 8) & 0xFF;
|
|
pUpdateMsgSend[7] = (updateDataTotalByteLen >> 8) & 0xFF;
|
|
pUpdateMsgSend[8] = (updateDataTotalByteLen)&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));
|
|
memset((UINT8 *)(&pUpdateMsgRecv), 0, sizeof(BMS_Update_Recv_Msg_Type));
|
|
ret = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), sizeof(BMS_Update_Recv_Msg_Type), 500);
|
|
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
|
|
#ifdef USING_PRINTF1
|
|
- //printf("update step:%d\n",updateStep);
|
|
|
|
|
|
+ // printf("update step:%d\n",updateStep);
|
|
printf("query:");
|
|
printf("query:");
|
|
for (j = 0; j < updateMsgSendLen; j++)
|
|
for (j = 0; j < updateMsgSendLen; j++)
|
|
{
|
|
{
|
|
@@ -1049,14 +1053,14 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
|
|
case UPDATE_STEP_PREPARE_SEND_UPDATE_DATA:
|
|
case UPDATE_STEP_PREPARE_SEND_UPDATE_DATA:
|
|
dataLen = 1;
|
|
dataLen = 1;
|
|
updateMsgSendLen = 8;
|
|
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));
|
|
memset((UINT8 *)(&pUpdateMsgRecv), 0, sizeof(BMS_Update_Recv_Msg_Type));
|
|
ret = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), sizeof(BMS_Update_Recv_Msg_Type), 500);
|
|
ret = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), sizeof(BMS_Update_Recv_Msg_Type), 500);
|
|
if (ret != 0)
|
|
if (ret != 0)
|
|
@@ -1097,7 +1101,7 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
|
|
}
|
|
}
|
|
|
|
|
|
#ifdef USING_PRINTF1
|
|
#ifdef USING_PRINTF1
|
|
- //printf("update step:%d\n",updateStep);
|
|
|
|
|
|
+ // printf("update step:%d\n",updateStep);
|
|
printf("query:");
|
|
printf("query:");
|
|
for (j = 0; j < updateMsgSendLen; j++)
|
|
for (j = 0; j < updateMsgSendLen; j++)
|
|
{
|
|
{
|
|
@@ -1121,18 +1125,18 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
|
|
{
|
|
{
|
|
currentPackageStartAddr = currentPackage * 64;
|
|
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[5] = (currentPackageStartAddr >> 24) & 0xFF;
|
|
pUpdateMsgSend[6] = (currentPackageStartAddr >> 16) & 0xFF;
|
|
pUpdateMsgSend[6] = (currentPackageStartAddr >> 16) & 0xFF;
|
|
pUpdateMsgSend[7] = (currentPackageStartAddr >> 8) & 0xFF;
|
|
pUpdateMsgSend[7] = (currentPackageStartAddr >> 8) & 0xFF;
|
|
pUpdateMsgSend[8] = currentPackageStartAddr & 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));
|
|
memset((UINT8 *)(&pUpdateMsgRecv), 0, sizeof(BMS_Update_Recv_Msg_Type));
|
|
ret = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), sizeof(BMS_Update_Recv_Msg_Type), 500);
|
|
ret = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), sizeof(BMS_Update_Recv_Msg_Type), 500);
|
|
if (ret != 0)
|
|
if (ret != 0)
|
|
@@ -1176,7 +1180,7 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
#ifdef USING_PRINTF1
|
|
#ifdef USING_PRINTF1
|
|
- //printf("update step:%d\n",updateStep);
|
|
|
|
|
|
+ // printf("update step:%d\n",updateStep);
|
|
printf("query:");
|
|
printf("query:");
|
|
for (j = 0; j < updateMsgSendLen; j++)
|
|
for (j = 0; j < updateMsgSendLen; j++)
|
|
{
|
|
{
|
|
@@ -1197,14 +1201,14 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
|
|
case UPDATE_STEP_SEND_DATA_END:
|
|
case UPDATE_STEP_SEND_DATA_END:
|
|
dataLen = 1;
|
|
dataLen = 1;
|
|
updateMsgSendLen = 8;
|
|
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));
|
|
memset((UINT8 *)(&pUpdateMsgRecv), 0, sizeof(BMS_Update_Recv_Msg_Type));
|
|
ret = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), sizeof(BMS_Update_Recv_Msg_Type), 500);
|
|
ret = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), sizeof(BMS_Update_Recv_Msg_Type), 500);
|
|
if (ret != 0)
|
|
if (ret != 0)
|
|
@@ -1245,7 +1249,7 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
|
|
}
|
|
}
|
|
|
|
|
|
#ifdef USING_PRINTF1
|
|
#ifdef USING_PRINTF1
|
|
- //printf("update step:%d\n",updateStep);
|
|
|
|
|
|
+ // printf("update step:%d\n",updateStep);
|
|
printf("query:");
|
|
printf("query:");
|
|
for (j = 0; j < updateMsgSendLen; j++)
|
|
for (j = 0; j < updateMsgSendLen; j++)
|
|
{
|
|
{
|
|
@@ -1265,21 +1269,21 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
|
|
case UPDATE_STEP_START_INSTALL:
|
|
case UPDATE_STEP_START_INSTALL:
|
|
dataLen = 1;
|
|
dataLen = 1;
|
|
updateMsgSendLen = 8;
|
|
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));
|
|
memset((UINT8 *)(&pUpdateMsgRecv), 0, sizeof(BMS_Update_Recv_Msg_Type));
|
|
UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), 0, 500);
|
|
UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), 0, 500);
|
|
|
|
|
|
updateStep = UPDATE_STEP_END;
|
|
updateStep = UPDATE_STEP_END;
|
|
|
|
|
|
#ifdef USING_PRINTF1
|
|
#ifdef USING_PRINTF1
|
|
- //printf("update step:%d\n",updateStep);
|
|
|
|
|
|
+ // printf("update step:%d\n",updateStep);
|
|
printf("query:");
|
|
printf("query:");
|
|
for (j = 0; j < updateMsgSendLen; j++)
|
|
for (j = 0; j < updateMsgSendLen; j++)
|
|
{
|
|
{
|
|
@@ -1303,14 +1307,14 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
|
|
case UPDATE_STEP_RESET:
|
|
case UPDATE_STEP_RESET:
|
|
dataLen = 1;
|
|
dataLen = 1;
|
|
updateMsgSendLen = 8;
|
|
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));
|
|
memset((UINT8 *)(&pUpdateMsgRecv), 0, sizeof(BMS_Update_Recv_Msg_Type));
|
|
UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), 0, 500);
|
|
UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), 0, 500);
|
|
osDelay(50);
|
|
osDelay(50);
|
|
@@ -1332,14 +1336,14 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
|
|
case UPDATE_STEP_DOWNLOAD_BREAK_OFF:
|
|
case UPDATE_STEP_DOWNLOAD_BREAK_OFF:
|
|
dataLen = 1;
|
|
dataLen = 1;
|
|
updateMsgSendLen = 8;
|
|
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));
|
|
memset((UINT8 *)(&pUpdateMsgRecv), 0, sizeof(BMS_Update_Recv_Msg_Type));
|
|
UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), 0, 500);
|
|
UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(&pUpdateMsgRecv), 0, 500);
|
|
osDelay(50);
|
|
osDelay(50);
|
|
@@ -1396,7 +1400,7 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
|
|
BOOL bmsUpdateFlag = TRUE;
|
|
BOOL bmsUpdateFlag = TRUE;
|
|
UINT8 bmsAnswerMsg[8];
|
|
UINT8 bmsAnswerMsg[8];
|
|
|
|
|
|
- //static UpdateStep step = UPDATE_STEP_CHECK_VERSION;
|
|
|
|
|
|
+ // static UpdateStep step = UPDATE_STEP_CHECK_VERSION;
|
|
UINT8 Cycle_conut = 0;
|
|
UINT8 Cycle_conut = 0;
|
|
UINT16 CRCtemp = 0;
|
|
UINT16 CRCtemp = 0;
|
|
UINT8 headerLen = 5;
|
|
UINT8 headerLen = 5;
|
|
@@ -1408,7 +1412,7 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
|
|
BSP_QSPI_Read_Safe(&checkSum, FLASH_BMS_FOTA_START_ADDR, 1);
|
|
BSP_QSPI_Read_Safe(&checkSum, FLASH_BMS_FOTA_START_ADDR, 1);
|
|
|
|
|
|
memset(ReadNVMTemp, 0, 64);
|
|
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);
|
|
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
|
|
updateDataPackageCount = (updateDataTotalByteLen + (64 - 1)) / 64; //进一法 e = (a+(b-1))/b
|
|
@@ -1459,19 +1463,19 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
|
|
switch (updateStep)
|
|
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;
|
|
dataLen = 0x00;
|
|
updateMsgSendLen = 6 + dataLen;
|
|
updateMsgSendLen = 6 + dataLen;
|
|
updateMsgReadLen = 8;
|
|
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);
|
|
CRCtemp = MS_BMS_Update_CRC16(pUpdateMsgSend, 4);
|
|
pUpdateMsgSend[4] = (CRCtemp >> 8) & 0xFF; // CRC High
|
|
pUpdateMsgSend[4] = (CRCtemp >> 8) & 0xFF; // CRC High
|
|
- pUpdateMsgSend[5] = CRCtemp & 0xFF; //CRC Low
|
|
|
|
|
|
+ pUpdateMsgSend[5] = CRCtemp & 0xFF; // CRC Low
|
|
|
|
|
|
memset((UINT8 *)(bmsAnswerMsg), 0, 8);
|
|
memset((UINT8 *)(bmsAnswerMsg), 0, 8);
|
|
ret0 = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(bmsAnswerMsg), updateMsgReadLen, 1000);
|
|
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[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;
|
|
updateStep = MS_UPDATE_STEP_SEND_FIRMWARE_INFO;
|
|
errorCount = 0;
|
|
errorCount = 0;
|
|
@@ -1549,17 +1553,17 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
|
|
osDelay(50);
|
|
osDelay(50);
|
|
printf(" step 1 ret = %d\n", ret);
|
|
printf(" step 1 ret = %d\n", ret);
|
|
break;
|
|
break;
|
|
- case MS_UPDATE_STEP_SEND_FIRMWARE_INFO: //0x03
|
|
|
|
|
|
+ case MS_UPDATE_STEP_SEND_FIRMWARE_INFO: // 0x03
|
|
dataLen = 52;
|
|
dataLen = 52;
|
|
updateMsgSendLen = 6 + dataLen;
|
|
updateMsgSendLen = 6 + dataLen;
|
|
updateMsgReadLen = 7;
|
|
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);
|
|
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], ReadNVMTemp, 16); //厂家信息,未开启校验
|
|
MEMCPY(&pUpdateMsgSend[4 + 16], ReadNVMTemp, 16); //保护板硬件序列号,未开启校验
|
|
MEMCPY(&pUpdateMsgSend[4 + 16], ReadNVMTemp, 16); //保护板硬件序列号,未开启校验
|
|
pUpdateMsgSend[4 + 16 * 2 + 0] = (updateDataTotalByteLen >> 24) & 0xFF; //固件包大小
|
|
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);
|
|
CRCtemp = MS_BMS_Update_CRC16(pUpdateMsgSend, 4 + dataLen);
|
|
|
|
|
|
pUpdateMsgSend[4 + dataLen] = (CRCtemp >> 8) & 0xFF; // CRC High
|
|
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);
|
|
memset((UINT8 *)(bmsAnswerMsg), 0, 8);
|
|
ret0 = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(bmsAnswerMsg), updateMsgReadLen, 1000);
|
|
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[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;
|
|
updateStep = MS_UPDATE_STEP_EREASE_APP_FLASH_REQUEST;
|
|
errorCount = 0;
|
|
errorCount = 0;
|
|
@@ -1642,19 +1646,19 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
|
|
printf(" step 3 ret = %d\n", ret);
|
|
printf(" step 3 ret = %d\n", ret);
|
|
osDelay(50);
|
|
osDelay(50);
|
|
break;
|
|
break;
|
|
- case MS_UPDATE_STEP_EREASE_APP_FLASH_REQUEST: //0x05
|
|
|
|
|
|
+ case MS_UPDATE_STEP_EREASE_APP_FLASH_REQUEST: // 0x05
|
|
dataLen = 0;
|
|
dataLen = 0;
|
|
updateMsgSendLen = 6 + dataLen;
|
|
updateMsgSendLen = 6 + dataLen;
|
|
updateMsgReadLen = 8;
|
|
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);
|
|
CRCtemp = MS_BMS_Update_CRC16(pUpdateMsgSend, 4 + dataLen);
|
|
|
|
|
|
pUpdateMsgSend[4 + dataLen] = (CRCtemp >> 8) & 0xFF; // CRC High
|
|
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);
|
|
memset((UINT8 *)(bmsAnswerMsg), 0, 8);
|
|
ret0 = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(bmsAnswerMsg), updateMsgReadLen, 1000);
|
|
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[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;
|
|
errorCount = 0;
|
|
}
|
|
}
|
|
else if (bmsAnswerMsg[4] == 0x01) //擦除失败
|
|
else if (bmsAnswerMsg[4] == 0x01) //擦除失败
|
|
@@ -1709,12 +1713,12 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
|
|
}
|
|
}
|
|
osDelay(50);
|
|
osDelay(50);
|
|
break;
|
|
break;
|
|
- case MS_UPDATE_STEP_SEND_UPDATE_DATA: //0x07
|
|
|
|
|
|
+ case MS_UPDATE_STEP_SEND_UPDATE_DATA: // 0x07
|
|
|
|
|
|
updateMsgReadLen = 7;
|
|
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++)
|
|
for (i = 0; i < updateDataPackageCount; i++)
|
|
{
|
|
{
|
|
@@ -1734,10 +1738,10 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
|
|
|
|
|
|
CRCtemp = MS_BMS_Update_CRC16(ReadNVMTemp, tempLen);
|
|
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)
|
|
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[4] = ((i + 1) >> 8) & 0xFF; //当前包序号,大端模式
|
|
pUpdateMsgSend[5] = (i + 1) & 0xFF;
|
|
pUpdateMsgSend[5] = (i + 1) & 0xFF;
|
|
@@ -1745,14 +1749,14 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
|
|
pUpdateMsgSend[6] = (updateDataPackageCount >> 8) & 0xFF;
|
|
pUpdateMsgSend[6] = (updateDataPackageCount >> 8) & 0xFF;
|
|
pUpdateMsgSend[7] = updateDataPackageCount & 0xFF;
|
|
pUpdateMsgSend[7] = updateDataPackageCount & 0xFF;
|
|
pUpdateMsgSend[8] = (CRCtemp >> 8) & 0xFF; // data CRC High
|
|
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字节
|
|
MEMCPY(&pUpdateMsgSend[4 + 6], ReadNVMTemp, 64); //升级数据,64字节
|
|
|
|
|
|
CRCtemp = MS_BMS_Update_CRC16(pUpdateMsgSend, 4 + dataLen);
|
|
CRCtemp = MS_BMS_Update_CRC16(pUpdateMsgSend, 4 + dataLen);
|
|
|
|
|
|
pUpdateMsgSend[4 + dataLen] = (CRCtemp >> 8) & 0xFF; // CRC High
|
|
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);
|
|
memset((UINT8 *)(bmsAnswerMsg), 0, 8);
|
|
ret0 = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(bmsAnswerMsg), updateMsgReadLen, 1000);
|
|
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[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;
|
|
updateStep = MS_UPDATE_STEP_EREASE_APP_FLASH_REQUEST;
|
|
errorCount = 0;
|
|
errorCount = 0;
|
|
@@ -1824,19 +1828,19 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
|
|
updateStep = MS_UPDATE_STEP_SEND_UPDATE_DATA_END_AND_JUMP_TO_APP;
|
|
updateStep = MS_UPDATE_STEP_SEND_UPDATE_DATA_END_AND_JUMP_TO_APP;
|
|
}
|
|
}
|
|
break;
|
|
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;
|
|
dataLen = 0x00;
|
|
updateMsgSendLen = 6 + dataLen;
|
|
updateMsgSendLen = 6 + dataLen;
|
|
updateMsgReadLen = 7;
|
|
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);
|
|
CRCtemp = MS_BMS_Update_CRC16(pUpdateMsgSend, 4);
|
|
pUpdateMsgSend[4] = (CRCtemp >> 8) & 0xFF; // CRC High
|
|
pUpdateMsgSend[4] = (CRCtemp >> 8) & 0xFF; // CRC High
|
|
- pUpdateMsgSend[5] = CRCtemp & 0xFF; //CRC Low
|
|
|
|
|
|
+ pUpdateMsgSend[5] = CRCtemp & 0xFF; // CRC Low
|
|
|
|
|
|
memset((UINT8 *)(bmsAnswerMsg), 0, 8);
|
|
memset((UINT8 *)(bmsAnswerMsg), 0, 8);
|
|
ret0 = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(bmsAnswerMsg), updateMsgReadLen, 1000);
|
|
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[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;
|
|
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) //升级失败
|
|
else if (bmsAnswerMsg[4] == 0x01) //升级失败
|
|
{
|
|
{
|
|
@@ -1887,19 +1891,19 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
|
|
}
|
|
}
|
|
osDelay(50);
|
|
osDelay(50);
|
|
break;
|
|
break;
|
|
- case MS_UPDATE_STEP_READ_CURRENT_RUNNING_MODE: //0x0B
|
|
|
|
|
|
+ case MS_UPDATE_STEP_READ_CURRENT_RUNNING_MODE: // 0x0B
|
|
dataLen = 0x00;
|
|
dataLen = 0x00;
|
|
updateMsgSendLen = 6 + dataLen;
|
|
updateMsgSendLen = 6 + dataLen;
|
|
updateMsgReadLen = 8;
|
|
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);
|
|
CRCtemp = MS_BMS_Update_CRC16(pUpdateMsgSend, 4);
|
|
pUpdateMsgSend[4] = (CRCtemp >> 8) & 0xFF; // CRC High
|
|
pUpdateMsgSend[4] = (CRCtemp >> 8) & 0xFF; // CRC High
|
|
- pUpdateMsgSend[5] = CRCtemp & 0xFF; //CRC Low
|
|
|
|
|
|
+ pUpdateMsgSend[5] = CRCtemp & 0xFF; // CRC Low
|
|
|
|
|
|
memset((UINT8 *)(bmsAnswerMsg), 0, 8);
|
|
memset((UINT8 *)(bmsAnswerMsg), 0, 8);
|
|
ret0 = UartAppTrasmit(pUpdateMsgSend, updateMsgSendLen, (UINT8 *)(bmsAnswerMsg), updateMsgReadLen, 1000);
|
|
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[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;
|
|
errorCount = 0;
|
|
updateStep = MS_UPDATE_STEP_END;
|
|
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;
|
|
errorCount = 10;
|
|
}
|
|
}
|
|
@@ -1949,12 +1953,12 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
|
|
}
|
|
}
|
|
osDelay(50);
|
|
osDelay(50);
|
|
break;
|
|
break;
|
|
- case MS_UPDATE_STEP_END: //0x0D
|
|
|
|
|
|
+ case MS_UPDATE_STEP_END: // 0x0D
|
|
errorCount = 0;
|
|
errorCount = 0;
|
|
bmsUpdateFlag = FALSE;
|
|
bmsUpdateFlag = FALSE;
|
|
ret = updateOK;
|
|
ret = updateOK;
|
|
break;
|
|
break;
|
|
- case MS_UPDATE_STEP_ERROR: //0x0E
|
|
|
|
|
|
+ case MS_UPDATE_STEP_ERROR: // 0x0E
|
|
errorCount = 0;
|
|
errorCount = 0;
|
|
bmsUpdateFlag = true;
|
|
bmsUpdateFlag = true;
|
|
Cycle_conut++;
|
|
Cycle_conut++;
|