|
@@ -82,6 +82,7 @@ void DataProcess(uint16_t ID, uint8_t Mode, uint16_t Cmd, uint8_t* Data)
|
|
|
{
|
|
|
//更新电池运行信息
|
|
|
memcpy(&BMS_RunInfo.Voltage, Data, DataLength);
|
|
|
+ MC_RunInfo.SOC = BMS_RunInfo.SOC;
|
|
|
//电池通信正常标志置位,用于续航计算
|
|
|
RemainDis.IsBMS_ComOK_Flag = TRUE;
|
|
|
RemainDis.BMS_Com_DelayTimeCnt = HAL_GetTick();
|
|
@@ -92,7 +93,7 @@ void DataProcess(uint16_t ID, uint8_t Mode, uint16_t Cmd, uint8_t* Data)
|
|
|
}
|
|
|
case 0x1308://关机指令
|
|
|
{
|
|
|
- PowerOff_Process();
|
|
|
+ PowerOff_Process(FALSE);
|
|
|
break;
|
|
|
}
|
|
|
case 0x1410://电池设计信息
|
|
@@ -132,7 +133,7 @@ void DataProcess(uint16_t ID, uint8_t Mode, uint16_t Cmd, uint8_t* Data)
|
|
|
//PBU广播的指令
|
|
|
case 0x1008://PBU关机指令
|
|
|
{
|
|
|
- PowerOff_Process();
|
|
|
+ PowerOff_Process(FALSE);
|
|
|
break;
|
|
|
}
|
|
|
case 0x120C://PBU物理ID
|
|
@@ -189,6 +190,14 @@ void DataProcess(uint16_t ID, uint8_t Mode, uint16_t Cmd, uint8_t* Data)
|
|
|
case 0x3408://OBC设置用户参数
|
|
|
{
|
|
|
MC_ConfigParam1.WheelSizeAdj = (int8_t)Data[0];
|
|
|
+ if(MC_ConfigParam1.WheelSizeAdj > 10)
|
|
|
+ {
|
|
|
+ MC_ConfigParam1.WheelSizeAdj = 10;
|
|
|
+ }
|
|
|
+ if(MC_ConfigParam1.WheelSizeAdj < -10)
|
|
|
+ {
|
|
|
+ MC_ConfigParam1.WheelSizeAdj = -10;
|
|
|
+ }
|
|
|
MC_ConfigParam1.StarModel = (MC_StarMode_Struct_t)Data[1];
|
|
|
SaveParamToEEprom_24C02(&I2C_Handle_EEPROM, EEPROM_24C02_ADDR_CONFIG_PARAM1, sizeof(MC_ConfigParam1), (uint8_t*)&MC_ConfigParam1.GasCtrlMode_Flag);
|
|
|
SendData(ID_MC_TO_PBU, MODE_REPORT, 0x5303, (uint8_t*)"ACK");
|
|
@@ -248,7 +257,23 @@ void DataProcess(uint16_t ID, uint8_t Mode, uint16_t Cmd, uint8_t* Data)
|
|
|
case 0x3810://ECU设置用户参数
|
|
|
{
|
|
|
MC_ConfigParam1.WheelSize = Data[0];
|
|
|
+ if(MC_ConfigParam1.WheelSize > 250)
|
|
|
+ {
|
|
|
+ MC_ConfigParam1.WheelSize = 250;
|
|
|
+ }
|
|
|
+ if(MC_ConfigParam1.WheelSize < 120)
|
|
|
+ {
|
|
|
+ MC_ConfigParam1.WheelSize = 120;
|
|
|
+ }
|
|
|
MC_ConfigParam1.SpeedLimit = Data[1];
|
|
|
+ if(MC_ConfigParam1.SpeedLimit > 99)
|
|
|
+ {
|
|
|
+ MC_ConfigParam1.SpeedLimit = 99;
|
|
|
+ }
|
|
|
+ if(MC_ConfigParam1.SpeedLimit < 5)
|
|
|
+ {
|
|
|
+ MC_ConfigParam1.SpeedLimit = 5;
|
|
|
+ }
|
|
|
//Data[2]和Data[3]低压保护值暂不处理
|
|
|
SaveParamToEEprom_24C02(&I2C_Handle_EEPROM, EEPROM_24C02_ADDR_CONFIG_PARAM1, sizeof(MC_ConfigParam1), (uint8_t*)&MC_ConfigParam1.GasCtrlMode_Flag);
|
|
|
SendData(ID_MC_TO_PBU, MODE_REPORT, 0x5303, (uint8_t*)"ACK");
|
|
@@ -314,6 +339,14 @@ void DataProcess(uint16_t ID, uint8_t Mode, uint16_t Cmd, uint8_t* Data)
|
|
|
case 0x3208://设置电机配置参数
|
|
|
{
|
|
|
MC_ConfigParam1.WheelSizeAdj = (int8_t)Data[0];
|
|
|
+ if(MC_ConfigParam1.WheelSizeAdj > 10)
|
|
|
+ {
|
|
|
+ MC_ConfigParam1.WheelSizeAdj = 10;
|
|
|
+ }
|
|
|
+ if(MC_ConfigParam1.WheelSizeAdj < -10)
|
|
|
+ {
|
|
|
+ MC_ConfigParam1.WheelSizeAdj = -10;
|
|
|
+ }
|
|
|
MC_ConfigParam1.StarModel = (MC_StarMode_Struct_t)Data[1];
|
|
|
SaveParamToEEprom_24C02(&I2C_Handle_EEPROM, EEPROM_24C02_ADDR_CONFIG_PARAM1, sizeof(MC_ConfigParam1), (uint8_t*)&MC_ConfigParam1.GasCtrlMode_Flag);
|
|
|
SendData(ID_MC_TO_HMI, MODE_REPORT, 0x7403, (uint8_t*)"ACK");
|
|
@@ -510,7 +543,7 @@ void DataProcess(uint16_t ID, uint8_t Mode, uint16_t Cmd, uint8_t* Data)
|
|
|
if(strncmp("RESET", (char*)Data, DataLength) == 0)
|
|
|
{
|
|
|
SendData(ID_MC_TO_CDL, MODE_REPORT, 0xA903, (uint8_t*)"ACK");
|
|
|
- PowerOff_Process();
|
|
|
+ PowerOff_Process(TRUE);
|
|
|
HAL_Delay(100);
|
|
|
__set_FAULTMASK(1);//关闭所有中断
|
|
|
HAL_NVIC_SystemReset();
|