|
@@ -112,6 +112,7 @@ static void UartTask(void* arg)
|
|
|
UartWriteCmdHandle = osMessageQueueNew(3,sizeof(Uart_Write_Data_Type), NULL);
|
|
|
}
|
|
|
//上电起始控制区域
|
|
|
+ UINT8 ret = 0x00;
|
|
|
while (1)
|
|
|
{
|
|
|
switch (gProcess_Uart_Task)
|
|
@@ -146,11 +147,26 @@ static void UartTask(void* arg)
|
|
|
printf("[%d]UartWriteCmdHandle :%x-%X%X\n",__LINE__,UartWriteData.WriteCmd,UartWriteData.Data[0],UartWriteData.Data[1]);
|
|
|
#endif
|
|
|
PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_WRITE);
|
|
|
+ break;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
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);
|
|
|
+ // }
|
|
|
}
|
|
|
if(UartReadMsg.Header[2]>0)
|
|
|
{
|
|
@@ -186,7 +202,7 @@ static void UartTask(void* arg)
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- if(AppNVMData.isBattLocked==TRUE && (UartReadMsg.data[(0x1B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2+1])&0x03!=0x00 && Timer_count%20==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);
|
|
@@ -197,7 +213,7 @@ static void UartTask(void* arg)
|
|
|
osMessageQueuePut(UartWriteCmdHandle,&UartWriteData,0,1000);
|
|
|
PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_READ);
|
|
|
}
|
|
|
- else if (AppNVMData.isBattLocked==FALSE && (UartReadMsg.data[(0x1B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2+1])&0x03==0x00 && Timer_count%20==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);
|
|
@@ -208,6 +224,16 @@ static void UartTask(void* arg)
|
|
|
osMessageQueuePut(UartWriteCmdHandle,&UartWriteData,0,1000);
|
|
|
PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_READ);
|
|
|
}
|
|
|
+ if(AppNVMData.isBattLocked==FALSE && ret==0x01)
|
|
|
+ {
|
|
|
+ relayControlFunc(3);
|
|
|
+ ret = 0x00;
|
|
|
+ }
|
|
|
+ else if (AppNVMData.isBattLocked==TRUE && ret==0x01)
|
|
|
+ {
|
|
|
+ relayControlFunc(2);
|
|
|
+ ret = 0x00;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
case PROCESS_UART_STATE_READ:
|
|
@@ -247,19 +273,15 @@ static void UartTask(void* arg)
|
|
|
BattChrgEndFlag=FALSE;
|
|
|
}
|
|
|
#ifdef USING_PRINTF1
|
|
|
- printf("\nUart_Recv_buffer: ");
|
|
|
- for(int i=0;i<Uart_Recv_LEN;i++)
|
|
|
- {
|
|
|
- printf("%x ",*((UINT8 *)&UartReadMsg.Header+i));
|
|
|
- }
|
|
|
- printf("\n");
|
|
|
- #endif
|
|
|
+ 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);
|
|
|
+ #endif
|
|
|
break;
|
|
|
}
|
|
|
case PROCESS_UART_STATE_WRITE:
|
|
|
{
|
|
|
- Uart_WriteCmd_func(UartWriteData);
|
|
|
- PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_IDLE);
|
|
|
+ ret = Uart_WriteCmd_func(UartWriteData);
|
|
|
+ osDelay(500);
|
|
|
+ PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_READ);
|
|
|
break;
|
|
|
}
|
|
|
case PROCESS_UART_STATE_UPDATE:
|
|
@@ -358,7 +380,7 @@ static BOOL uartBattInfoDecode(UINT8* dataPtr)
|
|
|
|
|
|
temp = ((dataPtr[(0x09+BATT_CELL_VOL_NUM+TEMP_NUM)*2+1])>>1)&0x03;
|
|
|
battMOSSwitchState = ((temp&0x01)<<1)|((temp&0x02)>>1);
|
|
|
- #ifdef USING_PRINTF
|
|
|
+ #ifdef USING_PRINTF1
|
|
|
printf("[%d]battMOSSwitchState :%x\n",__LINE__,battMOSSwitchState);
|
|
|
#endif
|
|
|
if(AppNVMData.isBattLocked==TRUE)
|
|
@@ -477,14 +499,6 @@ 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;
|
|
|
- if(AppNVMData.isBattLocked==FALSE)
|
|
|
- {
|
|
|
- relayControlFunc(3);
|
|
|
- }
|
|
|
- else if (AppNVMData.isBattLocked==TRUE)
|
|
|
- {
|
|
|
- relayControlFunc(2);
|
|
|
- }
|
|
|
break;
|
|
|
}
|
|
|
case 0x02://是否加热
|
|
@@ -1032,7 +1046,7 @@ void battLockStateDisplay(UINT8 lockState)
|
|
|
void relayControlFunc(UINT8 RingTimes)
|
|
|
{
|
|
|
UINT8 timerCount=0;
|
|
|
- printf("RingTimes=%d\n",RingTimes);
|
|
|
+ //printf("RingTimes=%d\n",RingTimes);
|
|
|
while(timerCount<RingTimes)
|
|
|
{
|
|
|
relayControl(TRUE);
|