|
@@ -37,15 +37,9 @@
|
|
|
extern UINT32 Timer_count;
|
|
|
extern volatile BOOL Sleep_flag;
|
|
|
extern AppNVMDataType AppNVMData;
|
|
|
+extern AppDataBody AppDataInfo;
|
|
|
//全局变量输出区
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
BOOL UartBattInfoRecvFlag = false;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-osMutexId_t UartMutex = NULL;//Uart数据锁
|
|
|
QueueHandle_t UartWriteCmdHandle = NULL;
|
|
|
UINT8 BattChrgEndFlag;
|
|
|
//
|
|
@@ -108,10 +102,6 @@ static void UartTask(void* arg)
|
|
|
{
|
|
|
UartWriteCmdHandle = osMessageQueueNew(3,sizeof(Uart_Write_Data_Type), NULL);
|
|
|
}
|
|
|
- if(UartMutex == NULL)
|
|
|
- {
|
|
|
- UartMutex = osMutexNew(NULL);
|
|
|
- }
|
|
|
//上电起始控制区域
|
|
|
while (1)
|
|
|
{
|
|
@@ -277,7 +267,6 @@ static void UartTask(void* arg)
|
|
|
//Uart 接收的数据解码
|
|
|
static BOOL uartBattInfoDecode(UINT8* dataPtr)
|
|
|
{
|
|
|
- OsaUtcTimeTValue TimeStracture;
|
|
|
//BattInfoType battInfo;
|
|
|
UINT8 i,temp=0;
|
|
|
UINT8 TEMP_NUM = BATT_TEMP_NUM + BATT_OTHER_TEMP_NUM;
|
|
@@ -301,17 +290,25 @@ static BOOL uartBattInfoDecode(UINT8* dataPtr)
|
|
|
printf("Batt_current = %x\n",Batt_current);
|
|
|
#endif
|
|
|
//原始数据:充电为负,放电为正
|
|
|
+ if(battWorkState==0x02&&Batt_current>0x8000)
|
|
|
+ {
|
|
|
+ AppDataInfo.BattCurrentNegFlag = 1;
|
|
|
+ }
|
|
|
+ if(battWorkState==0x02&&Batt_current<0x8000)
|
|
|
+ {
|
|
|
+ AppDataInfo.BattCurrentNegFlag = -1;
|
|
|
+ }
|
|
|
if (Batt_current>0x8000) //为负,充电数据
|
|
|
{
|
|
|
Batt_current = (UINT16)((UINT16)(~(Batt_current))+1);
|
|
|
Batt_current = Batt_current/10;
|
|
|
- Batt_current = -Batt_current + 0x2710;//平台数据:充电为负
|
|
|
+ Batt_current = -Batt_current*AppDataInfo.BattCurrentNegFlag + 0x2710;//平台数据:充电为负
|
|
|
//Batt_current = Batt_current;
|
|
|
}
|
|
|
else //为正,数据
|
|
|
{
|
|
|
Batt_current = Batt_current/10;
|
|
|
- Batt_current = Batt_current + 0x2710;//平台数据:充电为负
|
|
|
+ Batt_current = Batt_current*AppDataInfo.BattCurrentNegFlag + 0x2710;//平台数据:充电为负
|
|
|
//Batt_current = Batt_current;
|
|
|
}
|
|
|
battI = Batt_current;
|
|
@@ -509,7 +506,7 @@ UINT8 Uart_DataRecv_func(UINT8* Uart_Read_Msg,UINT8* Uart_Recv_Buffer)
|
|
|
*(Uart_Read_Msg+6) = CRC_chk_buffer;
|
|
|
*(Uart_Read_Msg+7) = CRC_chk_buffer>>8;
|
|
|
USARTdrv->Send(Uart_Read_Msg,8);
|
|
|
- #ifdef USING_PRINTF
|
|
|
+ #ifdef USING_PRINTF1
|
|
|
printf("Uart_Send_buffer: ");
|
|
|
for(int i=0;i<8;i++)
|
|
|
{
|
|
@@ -520,9 +517,7 @@ UINT8 Uart_DataRecv_func(UINT8* Uart_Read_Msg,UINT8* Uart_Recv_Buffer)
|
|
|
USARTdrv->Receive(Uart_Recv_Buffer,Data_Len);
|
|
|
while(true)
|
|
|
{
|
|
|
-
|
|
|
timeout++;
|
|
|
-
|
|
|
if((isRecvTimeout == true) || (isRecvComplete == true))
|
|
|
{
|
|
|
break;
|
|
@@ -537,7 +532,7 @@ UINT8 Uart_DataRecv_func(UINT8* Uart_Read_Msg,UINT8* Uart_Recv_Buffer)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- #ifdef USING_PRINTF
|
|
|
+ #ifdef USING_PRINTF1
|
|
|
printf("Uart_Rece_buffer1: ");
|
|
|
for(int i=0;i<Data_Len;i++)
|
|
|
{
|
|
@@ -549,7 +544,7 @@ UINT8 Uart_DataRecv_func(UINT8* Uart_Read_Msg,UINT8* Uart_Recv_Buffer)
|
|
|
isRecvComplete = false;
|
|
|
CRC_Rece_buffer =*(Uart_Recv_Buffer+Data_Len-1)<<8|*(Uart_Recv_Buffer+Data_Len-2);
|
|
|
CRC_chk_buffer = crc_chk(Uart_Recv_Buffer,Data_Len-2);
|
|
|
- #ifdef USING_PRINTF
|
|
|
+ #ifdef USING_PRINTF1
|
|
|
printf("Uart_Rece_buffer after Crc: ");
|
|
|
for(int i=0;i<Data_Len;i++)
|
|
|
{
|
|
@@ -598,12 +593,8 @@ BOOL BattHeaterSwitch(UINT8* heaterSwitch)
|
|
|
|
|
|
UINT8 i =0;
|
|
|
UINT8 currentSwitchState = 0;
|
|
|
-
|
|
|
//get the current switch state and the cell temp
|
|
|
currentSwitchState = battMOSSwitchState & 0x01;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
if(currentSwitchState==0) //当前状态为关闭,判断是否应该开启
|
|
|
{
|
|
|
if(minCellTemp<=5+40 && maxCellTemp<25+40 && battSOC>=12)//温度偏移为40
|
|
@@ -636,7 +627,6 @@ void battSOCDisplay()
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
if(UartBattInfoRecvFlag == true)
|
|
|
{
|
|
|
lightTimer++;
|