|
@@ -102,14 +102,12 @@ static void UartTask(void* arg)
|
|
|
ARM_USART_FLOW_CONTROL_NONE, 9600);
|
|
|
PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_ENCRYPT);
|
|
|
UINT16 Reg_Num = 0;
|
|
|
- UINT16 Uart_Uds_LEN;
|
|
|
UINT32 currentTimerCount=0;
|
|
|
Uart_Read_Msg_Type Uart_Read_Msg;
|
|
|
memset(&(Uart_Read_Msg),0x00,sizeof(Uart_Read_Msg_Type));
|
|
|
Uart_Write_Data_Type UartWriteData; //Uart控制命令
|
|
|
memset(&(UartWriteData),0x00,sizeof(Uart_Write_Data_Type));
|
|
|
UartReadMsgType UartReadMsg;
|
|
|
- memset(&(UartReadMsg.UartFlag),0x00,sizeof(UartReadMsgType));
|
|
|
if(UartWriteCmdHandle == NULL)//Uart控制命令传输指针
|
|
|
{
|
|
|
UartWriteCmdHandle = osMessageQueueNew(1,sizeof(Uart_Write_Data_Type), NULL);
|
|
@@ -321,13 +319,12 @@ static void UartTask(void* arg)
|
|
|
Uart_Read_Msg.Reg_Begin_L= 0x00;
|
|
|
Uart_Read_Msg.Reg_Num_H = Reg_Num>>8;
|
|
|
Uart_Read_Msg.Reg_Num_L = Reg_Num;
|
|
|
- Uart_Uds_LEN = Reg_Num*2;
|
|
|
- memset(UartReadMsg.Header,0x00,Uart_Uds_LEN);
|
|
|
+ memset((UINT8 *)&UartReadMsg,0x00,sizeof(UartReadMsgType));
|
|
|
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((UINT8 *)&Uart_Read_Msg,(UINT8*)UartReadMsg.Header);
|
|
|
- Uart_Recv_LEN = Uart_DataRecv_func(Uart_Read_Msg,(UINT8*)(UartReadMsg.Header));
|
|
|
+ Uart_Recv_LEN = Uart_DataRecv_func(Uart_Read_Msg,(UINT8 *)&UartReadMsg);
|
|
|
if(Uart_Recv_LEN>0)
|
|
|
{
|
|
|
UartBattInfoRecvFlag = TRUE;
|
|
@@ -337,7 +334,6 @@ static void UartTask(void* arg)
|
|
|
{
|
|
|
UartBattInfoRecvFlag = FALSE;
|
|
|
}
|
|
|
- UartReadMsg.len = Uart_Recv_LEN;
|
|
|
PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_IDLE);
|
|
|
#ifdef USING_PRINTF1
|
|
|
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);
|
|
@@ -396,6 +392,7 @@ static BOOL uartBattInfoDecode(UINT8* dataPtr)
|
|
|
UINT8 i,temp=0;
|
|
|
UINT8 TEMP_NUM = BATT_TEMP_NUM + BATT_OTHER_TEMP_NUM;
|
|
|
UINT16 Batt_current;
|
|
|
+ INT8 BattCurrentNegFlag = 1;
|
|
|
for(i=0;i<BATT_CELL_VOL_NUM;i++)
|
|
|
{
|
|
|
battCellU[i] = (dataPtr[(0x02+i)*2] << 8) | dataPtr[(0x02+i)*2 + 1];
|
|
@@ -419,13 +416,13 @@ static BOOL uartBattInfoDecode(UINT8* dataPtr)
|
|
|
//求补码,结果为负
|
|
|
Batt_current = (UINT16)((UINT16)(~(Batt_current))+1);
|
|
|
Batt_current = Batt_current/10;
|
|
|
- AppDataInfo.BattCurrentNegFlag = -1;
|
|
|
+ BattCurrentNegFlag = -1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//源码,结果为负
|
|
|
Batt_current = Batt_current/10;
|
|
|
- AppDataInfo.BattCurrentNegFlag = -1;
|
|
|
+ BattCurrentNegFlag = -1;
|
|
|
}
|
|
|
}
|
|
|
else //放电过程
|
|
@@ -435,17 +432,17 @@ static BOOL uartBattInfoDecode(UINT8* dataPtr)
|
|
|
//求补码,结果为正
|
|
|
Batt_current = (UINT16)((UINT16)(~(Batt_current))+1);
|
|
|
Batt_current = Batt_current/10;
|
|
|
- AppDataInfo.BattCurrentNegFlag = 1;
|
|
|
+ BattCurrentNegFlag = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//源码,结果为正
|
|
|
Batt_current = Batt_current/10;
|
|
|
- AppDataInfo.BattCurrentNegFlag = 1;
|
|
|
+ BattCurrentNegFlag = 1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- battI = Batt_current*AppDataInfo.BattCurrentNegFlag + 0x2710;
|
|
|
+ battI = Batt_current*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表示已连接
|
|
@@ -544,7 +541,7 @@ void Uart_Data_recv_SOC_test(void)
|
|
|
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));
|
|
|
+ memset(&(UartReadMsg),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;
|
|
@@ -761,10 +758,7 @@ UINT8 Uart_DataRecv_func(Uart_Read_Msg_Type Uart_Read_Msg_Fun,UINT8* Uart_Recv_B
|
|
|
UINT8 timeout = 0x00;
|
|
|
UINT8 pSendCmd[8];
|
|
|
memcpy(pSendCmd,(UINT8*)(&Uart_Read_Msg_Fun),8);
|
|
|
- //Data_Len = (*(Uart_Read_Msg_Fun+4)|*(Uart_Read_Msg_Fun+5))*2+5;
|
|
|
Data_Len = ((Uart_Read_Msg_Fun.Reg_Num_H<<8)|(Uart_Read_Msg_Fun.Reg_Num_L))*2+5;
|
|
|
-
|
|
|
- //USARTdrv->Send(Uart_Read_Msg_Fun,8);
|
|
|
USARTdrv->Send(pSendCmd,8);
|
|
|
#ifdef USING_PRINTF1
|
|
|
|
|
@@ -790,7 +784,6 @@ UINT8 Uart_DataRecv_func(Uart_Read_Msg_Type Uart_Read_Msg_Fun,UINT8* Uart_Recv_B
|
|
|
osDelay(100);
|
|
|
if (timeout>=10)
|
|
|
{
|
|
|
- // Data_Len = 0;
|
|
|
timeout =0;
|
|
|
isRecvTimeout = true;
|
|
|
}
|