|
@@ -39,6 +39,7 @@ extern volatile BOOL Sleep_flag;
|
|
|
extern AppNVMDataType AppNVMData;
|
|
|
extern AppDataBody AppDataInfo;
|
|
|
extern UINT8 WorkFlag;
|
|
|
+extern UINT8 UDSSwitch;
|
|
|
//全局变量输出区
|
|
|
BOOL UartBattInfoRecvFlag = false;
|
|
|
QueueHandle_t UartWriteCmdHandle = NULL;
|
|
@@ -77,6 +78,11 @@ UINT16 encryptionAlgorithm (UINT16 plainText);
|
|
|
UINT8 decryptionAlgorithm (UINT16 cipherText);
|
|
|
UINT8 Uart_Encrypt_Send(void);
|
|
|
UINT8 BmsErrorDecode(UINT32 battWarningState);
|
|
|
+
|
|
|
+#ifdef SOC_TEST
|
|
|
+void Uart_Data_recv_SOC_test(void);
|
|
|
+#endif
|
|
|
+
|
|
|
//BMS升级函数声明
|
|
|
UINT8 SP_BMS_Update_CheckSUM(UINT8* pSendData,UINT8 len);
|
|
|
void SP_BMS_Update_Service();
|
|
@@ -109,9 +115,12 @@ static void UartTask(void* arg)
|
|
|
memset(&(UartReadMsg.UartFlag),0x00,sizeof(UartReadMsgType));
|
|
|
if(UartWriteCmdHandle == NULL)//Uart控制命令传输指针
|
|
|
{
|
|
|
- UartWriteCmdHandle = osMessageQueueNew(3,sizeof(Uart_Write_Data_Type), NULL);
|
|
|
+ UartWriteCmdHandle = osMessageQueueNew(1,sizeof(Uart_Write_Data_Type), NULL);
|
|
|
}
|
|
|
//上电起始控制区域
|
|
|
+ UINT8 ret = 0x00;
|
|
|
+ UINT8 HeatSwitch = 0;
|
|
|
+
|
|
|
while (1)
|
|
|
{
|
|
|
switch (gProcess_Uart_Task)
|
|
@@ -134,22 +143,28 @@ static void UartTask(void* arg)
|
|
|
if(Sleep_flag)
|
|
|
{
|
|
|
PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_SLEEP);
|
|
|
+ break;
|
|
|
}
|
|
|
else if(Timer_count%10==0)
|
|
|
{
|
|
|
#ifdef USING_PRINTF1
|
|
|
printf("[%d]Uart Timer 1s:%d,uartReadSuccessFlag:%d\n",__LINE__,Timer_count,uartReadSuccessFlag);
|
|
|
#endif
|
|
|
- if(osMessageQueueGet(UartWriteCmdHandle,&UartWriteData,0,0)==osOK)
|
|
|
+ if(osMessageQueueGet(UartWriteCmdHandle,&UartWriteData,0,0)==osOK && uartReadSuccessFlag==TRUE)
|
|
|
{
|
|
|
- #ifdef USING_PRINTF1
|
|
|
- printf("[%d]UartWriteCmdHandle :%x\n",__LINE__,UartWriteData.WriteCmd);
|
|
|
+ #ifdef USING_PRINTF
|
|
|
+ printf("[%d]UartWriteCmdHandle :%x-%X%X\n",__LINE__,UartWriteData.WriteCmd,UartWriteData.Data[0],UartWriteData.Data[1]);
|
|
|
#endif
|
|
|
PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_WRITE);
|
|
|
+ break;
|
|
|
}
|
|
|
else
|
|
|
- PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_READ);
|
|
|
+ {
|
|
|
+ PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_READ);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
if(UartReadMsg.Header[2]>0)
|
|
|
{
|
|
|
uartReadSuccessFlag = true;
|
|
@@ -180,31 +195,43 @@ static void UartTask(void* arg)
|
|
|
if(WorkFlag==0x00)
|
|
|
{
|
|
|
PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_UPDATE);
|
|
|
+ break;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
- if(AppNVMData.isBattLocked==TRUE && ((UartReadMsg.data[(0x09+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+2)*2+1])>>1)&0x03!=0x00 && Timer_count%10==0)//try to lock
|
|
|
+ if(battWorkState ==0x00 && AppNVMData.isBattLocked==TRUE && ((UartReadMsg.data[(0x1B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2+1])&0x03)!=0x02)//try to lock lock the discharge
|
|
|
{
|
|
|
+ #ifdef USING_PRINTF
|
|
|
+ printf("[%d]try to lock:%X-%X\n",__LINE__,AppNVMData.isBattLocked,(UartReadMsg.data[(0x1B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2+1])&0x03);
|
|
|
+ #endif
|
|
|
UartWriteData.WriteCmd = 0x01;
|
|
|
- UartWriteData.Data[0] = 0x00;
|
|
|
- UartWriteData.Data[1] = 0x00;
|
|
|
- osMessageQueuePut(UartWriteCmdHandle,&UartWriteData,0,1000);
|
|
|
- PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_READ);
|
|
|
+ UartWriteData.Data[0] = 0x00|(UartReadMsg.data[(0x1B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2]);
|
|
|
+ UartWriteData.Data[1] = 0x02;
|
|
|
+ osMessageQueuePut(UartWriteCmdHandle,&UartWriteData,0,0);
|
|
|
}
|
|
|
- else if (AppNVMData.isBattLocked==FALSE && ((UartReadMsg.data[(0x09+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+2)*2+1])>>1)&0x03==0x00 && Timer_count%10==0 ) // try to unlock
|
|
|
+ else if (battWorkState ==0x00 && AppNVMData.isBattLocked==FALSE && ((UartReadMsg.data[(0x1B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2+1])&0x03)!=0x03) // try to unlock
|
|
|
{
|
|
|
+ #ifdef USING_PRINTF
|
|
|
+ printf("[%d]try to unlock:%X-%X\n",__LINE__,AppNVMData.isBattLocked,(UartReadMsg.data[(0x1B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2+1])&0x03);
|
|
|
+ #endif
|
|
|
UartWriteData.WriteCmd = 0x01;
|
|
|
- UartWriteData.Data[0] = 0x00;
|
|
|
+ UartWriteData.Data[0] = 0x00|(UartReadMsg.data[(0x1B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2]);
|
|
|
UartWriteData.Data[1] = 0x03;
|
|
|
- osMessageQueuePut(UartWriteCmdHandle,&UartWriteData,0,1000);
|
|
|
- PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_READ);
|
|
|
+ osMessageQueuePut(UartWriteCmdHandle,&UartWriteData,0,0);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(BattHeaterSwitch(&HeatSwitch)==TRUE)
|
|
|
+ {
|
|
|
+ UartWriteData.WriteCmd = 0x02;
|
|
|
+ UartWriteData.Data[0] = 0x00;
|
|
|
+ UartWriteData.Data[1] = HeatSwitch&0xFF;
|
|
|
+ osMessageQueuePut(UartWriteCmdHandle,&UartWriteData,0,0);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
case PROCESS_UART_STATE_READ:
|
|
|
{
|
|
|
UINT16 CRC_chk_buffer;
|
|
|
- Reg_Num = 0x21+BATT_CELL_VOL_NUM+BATT_TEMP_NUM + 2;//按照协议里面的0x21+X+N的结束地址
|
|
|
+ Reg_Num = 0x21+BATT_CELL_VOL_NUM+BATT_TEMP_NUM + BATT_OTHER_TEMP_NUM;//按照协议里面的0x21+X+N的结束地址
|
|
|
Uart_Read_Msg.Bms_Address = BMS_ADDRESS_CODE;
|
|
|
Uart_Read_Msg.Bms_Funcode = UART_READ_CODE;
|
|
|
Uart_Read_Msg.Reg_Begin_H = 0x00;
|
|
@@ -238,19 +265,22 @@ static void UartTask(void* arg)
|
|
|
BattChrgEndFlag=FALSE;
|
|
|
}
|
|
|
#ifdef USING_PRINTF1
|
|
|
- printf("\nUart_Recv_buffer: ");
|
|
|
- for(int i=0;i<Uart_Recv_LEN;i++)
|
|
|
- {
|
|
|
- printf("%x ",*((UINT8 *)&UartReadMsg.Header+i));
|
|
|
+ printf("[%d]lock:%X,permit:%X,Mos:%x\n",__LINE__,AppNVMData.isBattLocked,(UartReadMsg.data[(0x1B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2+1])&0x03,((UartReadMsg.data[(0x09+BATT_CELL_VOL_NUM+BATT_OTHER_TEMP_NUM)*2+1])>>1)&0x03);
|
|
|
+ #endif
|
|
|
+ //SOC问题测试
|
|
|
+ #ifdef SOC_TEST
|
|
|
+ if(bmsSwVersion==8)
|
|
|
+ {
|
|
|
+ Uart_Data_recv_SOC_test();
|
|
|
}
|
|
|
- printf("\n");
|
|
|
#endif
|
|
|
break;
|
|
|
}
|
|
|
case PROCESS_UART_STATE_WRITE:
|
|
|
{
|
|
|
- Uart_WriteCmd_func(UartWriteData);
|
|
|
- PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_IDLE);
|
|
|
+ ret = Uart_WriteCmd_func(UartWriteData);
|
|
|
+ osDelay(500);
|
|
|
+ PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_READ);
|
|
|
break;
|
|
|
}
|
|
|
case PROCESS_UART_STATE_UPDATE:
|
|
@@ -343,12 +373,15 @@ static BOOL uartBattInfoDecode(UINT8* dataPtr)
|
|
|
battI = Batt_current*AppDataInfo.BattCurrentNegFlag + 0x2710;
|
|
|
//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);
|
|
|
-
|
|
|
+ chargerConnectState = (dataPtr[(0x03+BATT_CELL_VOL_NUM)*2+1]>>2)&0x01;//充电器连接状态,0表示未连接,1表示已连接
|
|
|
bmsHwVersion = dataPtr[(0x08+BATT_CELL_VOL_NUM+TEMP_NUM)*2+1];
|
|
|
bmsSwVersion = dataPtr[(0x08+BATT_CELL_VOL_NUM+TEMP_NUM)*2];
|
|
|
|
|
|
temp = ((dataPtr[(0x09+BATT_CELL_VOL_NUM+TEMP_NUM)*2+1])>>1)&0x03;
|
|
|
battMOSSwitchState = ((temp&0x01)<<1)|((temp&0x02)>>1);
|
|
|
+ #ifdef USING_PRINTF1
|
|
|
+ printf("[%d]battMOSSwitchState :%x\n",__LINE__,battMOSSwitchState);
|
|
|
+ #endif
|
|
|
if(AppNVMData.isBattLocked==TRUE)
|
|
|
{
|
|
|
battMOSSwitchState = battMOSSwitchState |(0x01<<2);
|
|
@@ -358,14 +391,61 @@ static BOOL uartBattInfoDecode(UINT8* dataPtr)
|
|
|
battMOSSwitchState = battMOSSwitchState |(0x00<<2);
|
|
|
}
|
|
|
battWarningState = (dataPtr[(0x09+BATT_CELL_VOL_NUM+TEMP_NUM)*2+0]<<16) | (dataPtr[(0x0A+BATT_CELL_VOL_NUM+TEMP_NUM)*2+0] << 8) |(dataPtr[(0x0A+BATT_CELL_VOL_NUM+TEMP_NUM)*2+1]);
|
|
|
- battSOC = dataPtr[(0x0B+BATT_CELL_VOL_NUM+TEMP_NUM)*2+1];
|
|
|
+ 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]);
|
|
|
+ BattRemainCap = (dataPtr[(0x12+BATT_CELL_VOL_NUM+TEMP_NUM)*2])<<24|(dataPtr[(0x12+BATT_CELL_VOL_NUM+TEMP_NUM)*2+1])<<16|(dataPtr[(0x13+BATT_CELL_VOL_NUM+TEMP_NUM)*2])<<8|(dataPtr[(0x13+BATT_CELL_VOL_NUM+TEMP_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]);
|
|
|
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];
|
|
|
+ // RelayControlState = (dataPtr[(0x1B+BATT_CELL_VOL_NUM+TEMP_NUM)*2])&0x80;
|
|
|
battHeatEnableState = dataPtr[(0x1C+BATT_CELL_VOL_NUM+TEMP_NUM)*2+1]&0x01;
|
|
|
|
|
|
+ //SOC问题紧急修复
|
|
|
+ #ifdef SOC_TEST
|
|
|
+ Data_Current = (dataPtr[(0x02+BATT_CELL_VOL_NUM)*2]<<8)|(dataPtr[(0x02+BATT_CELL_VOL_NUM)*2+1]);
|
|
|
+ static UINT8 Soc_change_flag = 0;//0-BMS原始值,1-计算值
|
|
|
+ if((battI>10200U)||(battWorkState==2))//放电电流超过20A,使用上一时刻值,//如果有充电,使用计算值,最大不超过100
|
|
|
+ {
|
|
|
+ SOC1 = max((battPackVol*45-27000)/100,SOC1);
|
|
|
+ SOC1 = min(100,SOC1);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SOC1 = min((battPackVol*45-27000)/100,SOC1);
|
|
|
+ }
|
|
|
+ SOC2 = battSOC;
|
|
|
+ if(Soc_change_flag == 0)//使用原始值
|
|
|
+ {
|
|
|
+ if((SOC2 - SOC1>=10)&&(battPackVol>500)&&(battPackVol<900))
|
|
|
+ {
|
|
|
+ Soc_change_flag = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if((SOC2 - SOC1<5)||(battPackVol<500)||(battPackVol>900))
|
|
|
+ {
|
|
|
+ Soc_change_flag = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(Soc_change_flag==0)
|
|
|
+ {
|
|
|
+ battSOC = SOC2;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ battSOC = SOC1;
|
|
|
+ if(osOK==osMutexAcquire(Error_Mutex, 100))
|
|
|
+ {
|
|
|
+ UINT8 ErrorNumTemp = 238;
|
|
|
+ PutErrorNum((UINT16 *)ErrorNum,sizeof(ErrorNum),ErrorNumTemp);
|
|
|
+ }
|
|
|
+ osMutexRelease(Error_Mutex);
|
|
|
+ }
|
|
|
+ #endif
|
|
|
+ //SOC紧急修复
|
|
|
maxCellTemp = 0x00;
|
|
|
minCellTemp = 0xFF;
|
|
|
for(i=0;i<BATT_TEMP_NUM;i++)
|
|
@@ -378,9 +458,50 @@ static BOOL uartBattInfoDecode(UINT8* dataPtr)
|
|
|
BmsErrorDecode(battWarningState);
|
|
|
return true;
|
|
|
}
|
|
|
+#ifdef SOC_TEST
|
|
|
+void Uart_Data_recv_SOC_test(void)
|
|
|
+{
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+ UINT16 CRC_chk_buffer;
|
|
|
+ Uart_Read_Msg_Type Uart_Read_Msg;
|
|
|
+ memset(&(Uart_Read_Msg),0x00,sizeof(Uart_Read_Msg_Type));
|
|
|
+ UartReadMsgType UartReadMsg;
|
|
|
+ memset(&(UartReadMsg.UartFlag),0x00,sizeof(UartReadMsgType));
|
|
|
+ UINT8 Reg = 0,Uart_Uds_LEN = 0,Uart_Recv_LEN;
|
|
|
+ Reg = 0x33+BATT_CELL_VOL_NUM+BATT_TEMP_NUM + BATT_OTHER_TEMP_NUM;
|
|
|
+ Uart_Read_Msg.Bms_Address = BMS_ADDRESS_CODE;
|
|
|
+ Uart_Read_Msg.Bms_Funcode = UART_READ_CODE;
|
|
|
+ Uart_Read_Msg.Reg_Begin_H = Reg>>8;
|
|
|
+ Uart_Read_Msg.Reg_Begin_L= Reg;
|
|
|
+ Uart_Read_Msg.Reg_Num_H = 0;
|
|
|
+ Uart_Read_Msg.Reg_Num_L = 16;
|
|
|
+ Uart_Uds_LEN = 17*2;
|
|
|
+ memset(UartReadMsg.Header,0x00,Uart_Uds_LEN);
|
|
|
+ CRC_chk_buffer = crc_chk((UINT8 *)&Uart_Read_Msg,6);
|
|
|
+ Uart_Read_Msg.CRC_L = CRC_chk_buffer;
|
|
|
+ Uart_Read_Msg.CRC_H = CRC_chk_buffer>>8;
|
|
|
+ Uart_Recv_LEN = Uart_DataRecv_func(Uart_Read_Msg,(UINT8*)(UartReadMsg.Header));
|
|
|
+ if(Uart_Recv_LEN>0)
|
|
|
+ {
|
|
|
+ Data_33 = (UartReadMsg.data[0]<<8|UartReadMsg.data[1]);
|
|
|
+ Data_34 = (UartReadMsg.data[2]<<8|UartReadMsg.data[3]);
|
|
|
+ Data_35 = (UartReadMsg.data[4]<<24|UartReadMsg.data[5]<<16|UartReadMsg.data[6]<<8|UartReadMsg.data[7]);
|
|
|
+ Data_37 = (UartReadMsg.data[8]<<8|UartReadMsg.data[9]);
|
|
|
+ Data_38 = (UartReadMsg.data[10]<<8|UartReadMsg.data[11]);
|
|
|
+ Data_39 = (UartReadMsg.data[12]<<8|UartReadMsg.data[13]);
|
|
|
+ Data_3A = (UartReadMsg.data[14]<<8|UartReadMsg.data[15]);
|
|
|
+ Data_3B = (UartReadMsg.data[16]<<8|UartReadMsg.data[17]);
|
|
|
+ Data_3C = (UartReadMsg.data[18]<<8|UartReadMsg.data[19]);
|
|
|
+ Data_3D = (UartReadMsg.data[20]<<8|UartReadMsg.data[21]);
|
|
|
+ Data_3E = (UartReadMsg.data[22]<<8|UartReadMsg.data[23]);
|
|
|
+ Data_3F = (UartReadMsg.data[24]<<8|UartReadMsg.data[25]);
|
|
|
+ Data_40 = (UartReadMsg.data[26]<<8|UartReadMsg.data[27]);
|
|
|
+ Data_41 = (UartReadMsg.data[28]<<8|UartReadMsg.data[29]);
|
|
|
+ Data_42 = (UartReadMsg.data[30]<<8|UartReadMsg.data[31]);
|
|
|
+ Data_43 = (UartReadMsg.data[32]<<8|UartReadMsg.data[33]);
|
|
|
+ }
|
|
|
+}
|
|
|
+#endif
|
|
|
|
|
|
|
|
|
|
|
@@ -446,6 +567,9 @@ UINT8 Uart_WriteCmd_func(Uart_Write_Data_Type UartWriteData)
|
|
|
UINT16 CRC_chk_buffer;
|
|
|
UINT8 timeout = 0x00;
|
|
|
UINT8 Uart_Recv_Buffer[8];
|
|
|
+ #ifdef USING_PRINTF
|
|
|
+ printf("\nUart_WriteCmd_func: %x ",UartWriteData.WriteCmd);
|
|
|
+ #endif
|
|
|
switch (UartWriteData.WriteCmd)
|
|
|
{
|
|
|
case 0x01://是否锁定
|
|
@@ -636,29 +760,31 @@ UINT8 Uart_DataRecv_func(Uart_Read_Msg_Type Uart_Read_Msg_Fun,UINT8* Uart_Recv_B
|
|
|
*/
|
|
|
BOOL BattHeaterSwitch(UINT8* heaterSwitch)
|
|
|
{
|
|
|
- BOOL isNeedtoSwitch = FALSE;
|
|
|
-
|
|
|
- UINT8 i =0;
|
|
|
- UINT8 currentSwitchState = 0;
|
|
|
- //get the current switch state and the cell temp
|
|
|
- currentSwitchState = battMOSSwitchState & 0x01;
|
|
|
- if(currentSwitchState==0) //当前状态为关闭,判断是否应该开启
|
|
|
+ BOOL isNeedtoSwitch = FALSE;
|
|
|
+
|
|
|
+ UINT8 i =0;
|
|
|
+ UINT8 currentSwitchState = 0;
|
|
|
+
|
|
|
+ //get the current switch state and the cell temp
|
|
|
+ currentSwitchState = battHeatEnableState & 0x01;
|
|
|
+
|
|
|
+ if(currentSwitchState==0) //当前状态为关闭,判断是否应该开启
|
|
|
{
|
|
|
- if(minCellTemp<=5+40 && maxCellTemp<25+40 && battSOC>=12)//温度偏移为40
|
|
|
+ if((chargerConnectState == 1 && minCellTemp<5+40 && minCellTemp>=-29+40 && maxCellTemp<25+40)||(chargerConnectState==0 && minCellTemp<5+40 && minCellTemp>=-29+40 && battSOC>=10 && (((battProtectState>> 21)&0x01) == 0)))//温度偏移为40
|
|
|
{
|
|
|
*heaterSwitch = 1;
|
|
|
isNeedtoSwitch = true;
|
|
|
}
|
|
|
}
|
|
|
- else //当前状态为开启,判断是否应该关闭
|
|
|
+ else //当前状态为开启,判断是否应该关闭
|
|
|
{
|
|
|
- if(minCellTemp>10+40 || maxCellTemp>30+40 || battSOC<10)
|
|
|
+ if((minCellTemp>=10+40 || maxCellTemp>=30+40)||(chargerConnectState == 0 && minCellTemp<5+40 && minCellTemp>=-29+40 && battSOC<5))
|
|
|
{
|
|
|
*heaterSwitch = 0;
|
|
|
isNeedtoSwitch= true;
|
|
|
}
|
|
|
}
|
|
|
- return isNeedtoSwitch;
|
|
|
+ return isNeedtoSwitch;
|
|
|
}
|
|
|
|
|
|
void battSOCDisplay()
|
|
@@ -870,8 +996,12 @@ void battErrorStateDisplay()
|
|
|
{
|
|
|
|
|
|
errorLightTimer++;
|
|
|
-
|
|
|
- if(battWarningState != 0)
|
|
|
+ if(battWorkState == 0x02) //充电模式下,如果只有“SOC低故障”,那么就不显示故障灯 zhengchao20210713 add
|
|
|
+ {
|
|
|
+ if((((battWarningState >> 10) & 0x01) == 0x01) && ((battWarningState & 0xFFFFFBFF) == 0x00))
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(battWarningState != 0 )
|
|
|
{
|
|
|
if(errorLightTimer<(UINT8)(errorLEDFlashPeriod*errorDutyRatio))
|
|
|
{
|