|
@@ -11,7 +11,8 @@
|
|
|
#ifdef APP_UART0_ENABLE
|
|
|
static process_Uart0 gProcess_Uart0_Task = PROCESS_UART_STATE_IDLE;
|
|
|
#define PROC_UART0_STATE_SWITCH(a) (gProcess_Uart0_Task = a)
|
|
|
-bool bmsCellInfoDecode(uint8 *dataPtr);
|
|
|
+bool bmsCellInfoDecode1(uint8 *dataPtr);
|
|
|
+bool bmsCellInfoDecode2(uint8 *dataPtr);
|
|
|
bool bmsTempInfoDecode(uint8 *dataPtr);
|
|
|
bool bmsOtherInfoDecode(uint8 *dataPtr);
|
|
|
void UartBusReadDataFunc(uint16 RegAddrBegin, uint16 Reg_Num, bool (*decodeFunc)(uint8 *dataPtr));
|
|
@@ -43,20 +44,22 @@ void Uart0Task(void *pvParameters)
|
|
|
case PROCESS_UART_STATE_READ:
|
|
|
{
|
|
|
/*01 04 00 01 00 38 A0 18
|
|
|
- 01 04 00 64 00 78 B1 F7
|
|
|
+ 01 04 00 64 00 3C B1 C4
|
|
|
01 04 01 90 00 28 F1 C5 */
|
|
|
Dio_FlipChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2);
|
|
|
//其他参数读取
|
|
|
UartBusReadDataFunc(0x01, 0x38, bmsOtherInfoDecode);
|
|
|
//电压读取
|
|
|
- UartBusReadDataFunc(0x64, 120, bmsCellInfoDecode);
|
|
|
+ UartBusReadDataFunc(0x64, 60, bmsCellInfoDecode1);
|
|
|
+ UartBusReadDataFunc(0x64 + 60, 60, bmsCellInfoDecode2);
|
|
|
//温度读取
|
|
|
UartBusReadDataFunc(0x190, 40, bmsTempInfoDecode);
|
|
|
//没有读到数据时的默认值
|
|
|
if (UartNoDataReadCounter > 10)
|
|
|
{
|
|
|
memset((uint8 *)&UartAnsData, 0x00, sizeof(UartAnsData));
|
|
|
- bmsCellInfoDecode(UartAnsData.Data);
|
|
|
+ bmsCellInfoDecode1(UartAnsData.Data);
|
|
|
+ bmsCellInfoDecode2(UartAnsData.Data);
|
|
|
bmsTempInfoDecode(UartAnsData.Data);
|
|
|
bmsOtherInfoDecode(UartAnsData.Data);
|
|
|
PutErrorNum(ErrorArray, sizeof(ErrorArray) / 2, 1);
|
|
@@ -122,9 +125,17 @@ void Uart0Task(void *pvParameters)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-bool bmsCellInfoDecode(uint8 *dataPtr) //电压数据解码
|
|
|
+bool bmsCellInfoDecode1(uint8 *dataPtr) //电压数据解码1
|
|
|
{
|
|
|
- for (uint8 i = 0; i < BMS_CELLNUM; i++)
|
|
|
+ for (uint8 i = 0; i < 60; i++)
|
|
|
+ {
|
|
|
+ battCellU[i] = ((dataPtr[(0x00 + i) * 2] << 8) | dataPtr[(0x00 + i) * 2 + 1]);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+}
|
|
|
+bool bmsCellInfoDecode2(uint8 *dataPtr) //电压数据解码2
|
|
|
+{
|
|
|
+ for (uint8 i = 60; i < BMS_CELLNUM; i++)
|
|
|
{
|
|
|
battCellU[i] = ((dataPtr[(0x00 + i) * 2] << 8) | dataPtr[(0x00 + i) * 2 + 1]);
|
|
|
}
|
|
@@ -182,10 +193,10 @@ void UartBusReadDataFunc(uint16 RegAddrBegin, uint16 Reg_Num, bool (*decodeFunc)
|
|
|
uint16 ReadLenTar = 0;
|
|
|
uint8 ReadDelayCounter = 0;
|
|
|
uint16 CRC_chk_buffer = 0;
|
|
|
- uint16 pReadLen;
|
|
|
+ uint16 pReadLen = 0;
|
|
|
UartAnsType UartAnsData;
|
|
|
uint8 UartDataRecv[256];
|
|
|
- pReadLen = 0;
|
|
|
+
|
|
|
Uart0AskMsg.Bms_Address = BMS_ADDRESS_CODE;
|
|
|
Uart0AskMsg.Bms_Funcode = UART_READ_CODE;
|
|
|
Uart0AskMsg.Reg_Begin_H = RegAddrBegin >> 8;
|
|
@@ -195,7 +206,7 @@ void UartBusReadDataFunc(uint16 RegAddrBegin, uint16 Reg_Num, bool (*decodeFunc)
|
|
|
CRC_chk_buffer = crc_chk((uint8 *)&Uart0AskMsg, 6);
|
|
|
Uart0AskMsg.CRC_L = CRC_chk_buffer;
|
|
|
Uart0AskMsg.CRC_H = CRC_chk_buffer >> 8;
|
|
|
- UART_Send_Data(UART_LPUART0, (uint8 *)&Uart0AskMsg, sizeof(Uart0AskMsg), 1000);
|
|
|
+ UART_Send_Data(UART_LPUART0, (uint8 *)&Uart0AskMsg, sizeof(Uart0AskMsg), 100);
|
|
|
ReadLenTar = (Reg_Num)*2 + 5;
|
|
|
memset((uint8 *)&UartAnsData, 0x00, sizeof(UartAnsData));
|
|
|
while (1)
|