|
@@ -153,20 +153,20 @@ static void UartTask(void* arg)
|
|
|
{
|
|
|
PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_READ);
|
|
|
}
|
|
|
- // if(battHeatEnableState==0x00 && slpManGetWakeupPinValue() & (0x1<<2) == 0)
|
|
|
- // {
|
|
|
- // UartWriteData.WriteCmd = 0x02;
|
|
|
- // UartWriteData.Data[0] = 0x00;
|
|
|
- // UartWriteData.Data[1] = 0x01;
|
|
|
- // osMessageQueuePut(UartWriteCmdHandle,&UartWriteData,0,1000);
|
|
|
- // }
|
|
|
- // else if(battHeatEnableState==0x01 && slpManGetWakeupPinValue() & (0x1<<2) == 1)
|
|
|
- // {
|
|
|
- // UartWriteData.WriteCmd = 0x02;
|
|
|
- // UartWriteData.Data[0] = 0x00;
|
|
|
- // UartWriteData.Data[1] = 0x00;
|
|
|
- // osMessageQueuePut(UartWriteCmdHandle,&UartWriteData,0,1000);
|
|
|
- // }
|
|
|
+ #ifdef USING_PRINTF
|
|
|
+ printf("[%d]PinValue:%X,RelayControl:%x,Relaystate:%x\n",__LINE__,slpManGetWakeupPinValue()&(0x01<<2),(UartReadMsg.data[(0x1B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2])&0x80,(UartReadMsg.data[(0x09+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2]+1)&0x80);
|
|
|
+ #endif
|
|
|
+ if((slpManGetWakeupPinValue()&(0x01<<2))==0)
|
|
|
+ {
|
|
|
+ AppDataInfo.RelayControl=TRUE;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ AppDataInfo.RelayControl=FALSE;
|
|
|
+ }
|
|
|
+ #ifdef USING_PRINTF
|
|
|
+ printf("[%d]RelayControl:%x\n",__LINE__,AppDataInfo.RelayControl);
|
|
|
+ #endif
|
|
|
}
|
|
|
if(UartReadMsg.Header[2]>0)
|
|
|
{
|
|
@@ -202,24 +202,24 @@ static void UartTask(void* arg)
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- if(battWorkState ==0x00 && AppNVMData.isBattLocked==TRUE && (UartReadMsg.data[(0x1B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2+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)!=0x00 && Timer_count%10==0)//try to lock
|
|
|
{
|
|
|
#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[0] = 0x00|(UartReadMsg.data[(0x1B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2]);
|
|
|
UartWriteData.Data[1] = 0x00;
|
|
|
osMessageQueuePut(UartWriteCmdHandle,&UartWriteData,0,1000);
|
|
|
PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_READ);
|
|
|
}
|
|
|
- else if (battWorkState ==0x00 && AppNVMData.isBattLocked==FALSE && (UartReadMsg.data[(0x1B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2+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)==0x00 && Timer_count%10==0 ) // 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);
|
|
@@ -234,6 +234,26 @@ static void UartTask(void* arg)
|
|
|
relayControlFunc(2);
|
|
|
ret = 0x00;
|
|
|
}
|
|
|
+ else if(AppDataInfo.RelayControl==TRUE)
|
|
|
+ {
|
|
|
+ relayControlFunc(1);
|
|
|
+ }
|
|
|
+ if(AppDataInfo.RelayControl==TRUE && ((UartReadMsg.data[(0x1B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2])&0x80)==0x00)
|
|
|
+ {
|
|
|
+ UartWriteData.WriteCmd = 0x03;
|
|
|
+ UartWriteData.Data[0] = 0x80;
|
|
|
+ UartWriteData.Data[1] = 0x00|(UartReadMsg.data[(0x1B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2+1]);
|
|
|
+ osMessageQueuePut(UartWriteCmdHandle,&UartWriteData,0,1000);
|
|
|
+ PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_READ);
|
|
|
+ }
|
|
|
+ else if(AppDataInfo.RelayControl==FALSE && ((UartReadMsg.data[(0x1B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2])&0x80)==0x80)
|
|
|
+ {
|
|
|
+ UartWriteData.WriteCmd = 0x03;
|
|
|
+ UartWriteData.Data[0] = 0x00;
|
|
|
+ UartWriteData.Data[1] = 0x00|(UartReadMsg.data[(0x1B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2+1]);
|
|
|
+ osMessageQueuePut(UartWriteCmdHandle,&UartWriteData,0,1000);
|
|
|
+ PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_READ);
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
case PROCESS_UART_STATE_READ:
|
|
@@ -374,7 +394,7 @@ 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])&0x04;//充电器连接状态,0表示未连接,1表示已连接
|
|
|
+ // chargerConnectState = (dataPtr[(0x03+BATT_CELL_VOL_NUM)*2+1])&0x04;//充电器连接状态,0表示未连接,1表示已连接
|
|
|
bmsHwVersion = dataPtr[(0x08+BATT_CELL_VOL_NUM+TEMP_NUM)*2+1];
|
|
|
bmsSwVersion = dataPtr[(0x08+BATT_CELL_VOL_NUM+TEMP_NUM)*2];
|
|
|
|
|
@@ -398,6 +418,7 @@ static BOOL uartBattInfoDecode(UINT8* dataPtr)
|
|
|
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;
|
|
|
|
|
|
maxCellTemp = 0x00;
|
|
@@ -515,6 +536,22 @@ UINT8 Uart_WriteCmd_func(Uart_Write_Data_Type UartWriteData)
|
|
|
CRC_chk_buffer = crc_chk((UINT8 *)&Uart_Write_Msg,sizeof(Uart_Write_Msg)-2);
|
|
|
Uart_Write_Msg.CRC_L = CRC_chk_buffer;
|
|
|
Uart_Write_Msg.CRC_H = CRC_chk_buffer>>8;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 0x03://是否继电器控制
|
|
|
+ {
|
|
|
+ RegAddress = 0x1B + BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM;
|
|
|
+ Uart_Write_Msg.Bms_Address = BMS_ADDRESS_CODE;
|
|
|
+ Uart_Write_Msg.Bms_Funcode = UART_WRITE_CODE;
|
|
|
+ Uart_Write_Msg.Reg_Begin_H = RegAddress>>8;
|
|
|
+ Uart_Write_Msg.Reg_Begin_L = RegAddress;
|
|
|
+ Uart_Write_Msg.Reg_Num_H = 0x00;
|
|
|
+ Uart_Write_Msg.Reg_Num_L = 0x01;
|
|
|
+ Uart_Write_Msg.Data_Count = 0x02;//要写入的字节数
|
|
|
+ memcpy(Uart_Write_Msg.Data,UartWriteData.Data,2);
|
|
|
+ CRC_chk_buffer = crc_chk((UINT8 *)&Uart_Write_Msg,sizeof(Uart_Write_Msg)-2);
|
|
|
+ Uart_Write_Msg.CRC_L = CRC_chk_buffer;
|
|
|
+ Uart_Write_Msg.CRC_H = CRC_chk_buffer>>8;
|
|
|
break;
|
|
|
}
|
|
|
default:
|