|
@@ -70,49 +70,49 @@ void Uart0Task(void *pvParameters)
|
|
|
}
|
|
|
case PROCESS_UART_STATE_WRITE:
|
|
|
{
|
|
|
- if (battSeparateEnable) //最多重新写5次
|
|
|
- {
|
|
|
- uint16 RegAddress = 0;
|
|
|
- uint16 CRC_chk_buffer = 0;
|
|
|
- uint8 WriteData[2] = {0x00, 0x00};
|
|
|
- uint8 UartRecvBuffer[10];
|
|
|
- if (!battSeparateCtlState)
|
|
|
- {
|
|
|
- WriteData[1] = 0x55;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- WriteData[1] = 0xAA;
|
|
|
- }
|
|
|
- RegAddress = 100;
|
|
|
- UartWriteMsgType Uart_Write_Msg;
|
|
|
- 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, WriteData, 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;
|
|
|
- UART_Query_Data(UART_LPUART0, UART_LPUART0, (uint8 *)&Uart_Write_Msg, sizeof(Uart_Write_Msg), UartRecvBuffer, &pReadLen, 500);
|
|
|
- if (pReadLen > 3 && *(UartRecvBuffer + 1) == 0x10)
|
|
|
- {
|
|
|
- writecounter = 0;
|
|
|
- battSeparateEnable = 0;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- writecounter++;
|
|
|
- }
|
|
|
- }
|
|
|
- if (writecounter >= 5)
|
|
|
- {
|
|
|
- battSeparateEnable = 0;
|
|
|
- writecounter = 0;
|
|
|
- }
|
|
|
+// if (battSeparateEnable) //最多重新写5次
|
|
|
+// {
|
|
|
+// uint16 RegAddress = 0;
|
|
|
+// uint16 CRC_chk_buffer = 0;
|
|
|
+// uint8 WriteData[2] = {0x00, 0x00};
|
|
|
+// uint8 UartRecvBuffer[10];
|
|
|
+// if (!battSeparateCtlState)
|
|
|
+// {
|
|
|
+// WriteData[1] = 0x55;
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// WriteData[1] = 0xAA;
|
|
|
+// }
|
|
|
+// RegAddress = 100;
|
|
|
+// UartWriteMsgType Uart_Write_Msg;
|
|
|
+// 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, WriteData, 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;
|
|
|
+// UART_Query_Data(UART_LPUART0, UART_LPUART0, (uint8 *)&Uart_Write_Msg, sizeof(Uart_Write_Msg), UartRecvBuffer, &pReadLen, 500);
|
|
|
+// if (pReadLen > 3 && *(UartRecvBuffer + 1) == 0x10)
|
|
|
+// {
|
|
|
+// writecounter = 0;
|
|
|
+// battSeparateEnable = 0;
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// writecounter++;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if (writecounter >= 5)
|
|
|
+// {
|
|
|
+// battSeparateEnable = 0;
|
|
|
+// writecounter = 0;
|
|
|
+// }
|
|
|
PROC_UART0_STATE_SWITCH(PROCESS_UART_STATE_IDLE);
|
|
|
break;
|
|
|
}
|