|
@@ -193,7 +193,7 @@ static void Main_Task(void* arg)
|
|
|
uint32_t sleep_time_flag;
|
|
|
int32_t inParam = 0xAABBCCDD;
|
|
|
uint32_t Chrgend_Work_time = 180000;
|
|
|
- uint32_t Wakeup_Work_time = 30000;
|
|
|
+ uint32_t Wakeup_Work_time = 6000;
|
|
|
uint32_t Sleep_Time = 1800000;
|
|
|
//上述参数应写入文件里
|
|
|
slpManWakeSrc_e Wakeup_source;
|
|
@@ -238,7 +238,6 @@ static void Main_Task(void* arg)
|
|
|
{
|
|
|
sleep_time_flag = Chrgend_Work_time;
|
|
|
}
|
|
|
-
|
|
|
if((slpstate == SLP_SLP2_STATE) || (slpstate == SLP_HIB_STATE))
|
|
|
{
|
|
|
PROC_MAIN_STATE_SWITCH(PROCESS_STATE_WORK);
|
|
@@ -289,6 +288,10 @@ static void Main_Task(void* arg)
|
|
|
{
|
|
|
sleep_index = 0;
|
|
|
}
|
|
|
+ if ((Uart_Rece_BattI!=0x0000)&&(Uart_Rece_BattI<=0x8000))
|
|
|
+ {
|
|
|
+ sleep_time_flag = Chrgend_Work_time;
|
|
|
+ }
|
|
|
if (sleep_index >=sleep_time_flag)
|
|
|
{
|
|
|
PROC_MAIN_STATE_SWITCH(PROCESS_STATE_SLEEP);
|
|
@@ -303,11 +306,11 @@ static void Main_Task(void* arg)
|
|
|
PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_SLEEP);
|
|
|
PROC_CAN_STATE_SWITCH(PROCESS_CAN_STATE_SLEEP);
|
|
|
PROC_TCP_STATE_SWITCH(PROCESS_TCP_STATE_SLEEP);
|
|
|
+ Sleep_Flag = TRUE;
|
|
|
if((Uart_Sleep_Flag)&&(Can_Sleep_Flag)&&(Tcp_Sleep_Flag))
|
|
|
break;
|
|
|
}
|
|
|
- Sleep_Flag = TRUE;
|
|
|
- osDelay(2000);
|
|
|
+ osDelay(10000);
|
|
|
#ifdef USING_PRINTF
|
|
|
printf("Ms_sleep:uart_%d,can_%d,tcp_%d\r\n",gProcess_Uart_Task,gProcess_Can_Task,gProcess_Tcp_Task);
|
|
|
#endif
|
|
@@ -443,14 +446,24 @@ uint8_t* Uart_Receive_func(Uart_Receive_Type Uart_Receive_Msg,uint8_t* Uart_Rece
|
|
|
{
|
|
|
return Uart_Rece_buffer;//此处指针移位出现重启问题
|
|
|
}
|
|
|
- else //接收数据的校验不过屏蔽
|
|
|
+ else //接收数据的校验不过
|
|
|
{
|
|
|
+ USARTdrv->Uninitialize();
|
|
|
+ osDelay(1000);
|
|
|
+ USARTdrv->Initialize(USART_callback);
|
|
|
+ USARTdrv->PowerControl(ARM_POWER_FULL);
|
|
|
+ USARTdrv->Control(ARM_USART_MODE_ASYNCHRONOUS |
|
|
|
+ ARM_USART_DATA_BITS_8 |
|
|
|
+ ARM_USART_PARITY_NONE |
|
|
|
+ ARM_USART_STOP_BITS_1 |
|
|
|
+ ARM_USART_FLOW_CONTROL_NONE, 9600);
|
|
|
memset(Uart_Rece_buffer,0xff,Data_Len);
|
|
|
return Uart_Rece_buffer;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ osDelay(100);
|
|
|
memset(Uart_Rece_buffer,0x00,Data_Len);
|
|
|
isRecvTimeout = false;
|
|
|
return Uart_Rece_buffer;
|
|
@@ -636,6 +649,7 @@ static void Uart_Task(void* arg)
|
|
|
}
|
|
|
case PROCESS_UART_STATE_SLEEP:
|
|
|
{
|
|
|
+ USARTdrv->PowerControl(ARM_POWER_LOW);
|
|
|
slpManPlatVoteEnableSleep(UartSlpHandler, SLP_SLP2_STATE);
|
|
|
#ifdef USING_PRINTF
|
|
|
printf("UART_STATE_SLEEP\n");
|
|
@@ -742,7 +756,7 @@ static void Can_Task(void* arg)
|
|
|
Can_ID = 0x001;
|
|
|
for (int i = 0; i < 8; i++)
|
|
|
{
|
|
|
- Can_TxMsg.Data[i] = battbuffer[i+31+send_index*8];
|
|
|
+ Can_TxMsg.Data[i] = battbuffer[i+31+0*8];
|
|
|
}
|
|
|
Can_TxMsg.stdIDH = Can_ID>>3;
|
|
|
Can_TxMsg.stdIDL = Can_ID<<5;
|
|
@@ -755,7 +769,7 @@ static void Can_Task(void* arg)
|
|
|
Can_ID = 0x011;
|
|
|
for (int i = 0; i < 8; i++)
|
|
|
{
|
|
|
- Can_TxMsg.Data[i] = battbuffer[i+31+send_index*8];
|
|
|
+ Can_TxMsg.Data[i] = battbuffer[i+31+1*8];
|
|
|
}
|
|
|
Can_TxMsg.stdIDH = Can_ID>>3;
|
|
|
Can_TxMsg.stdIDL = Can_ID<<5;
|
|
@@ -768,7 +782,7 @@ static void Can_Task(void* arg)
|
|
|
Can_ID = 0x020;
|
|
|
for (int i = 0; i < 8; i++)
|
|
|
{
|
|
|
- Can_TxMsg.Data[i] = battbuffer[i+31+send_index*8];
|
|
|
+ Can_TxMsg.Data[i] = battbuffer[i+31+2*8];
|
|
|
}
|
|
|
Can_TxMsg.stdIDH = Can_ID>>3;
|
|
|
Can_TxMsg.stdIDL = Can_ID<<5;
|
|
@@ -781,16 +795,12 @@ static void Can_Task(void* arg)
|
|
|
Can_ID = 0x031;
|
|
|
for (int i = 0; i < 8; i++)
|
|
|
{
|
|
|
- Can_TxMsg.Data[i] = battbuffer[i+31+send_index*8];
|
|
|
+ Can_TxMsg.Data[i] = battbuffer[i+31+3*8];
|
|
|
}
|
|
|
Can_TxMsg.stdIDH = Can_ID>>3;
|
|
|
Can_TxMsg.stdIDL = Can_ID<<5;
|
|
|
Can_TxMsg.DLC = 8;
|
|
|
HAL_Can_Transmit(Can_TxMsg);
|
|
|
- break;
|
|
|
- }
|
|
|
- case 8:
|
|
|
- {
|
|
|
Can_ID = 0x041;
|
|
|
for (int i = 0; i < 2; i++)
|
|
|
{
|
|
@@ -804,6 +814,7 @@ static void Can_Task(void* arg)
|
|
|
Can_TxMsg.stdIDL = Can_ID<<5;
|
|
|
Can_TxMsg.DLC = 8;
|
|
|
HAL_Can_Transmit(Can_TxMsg);
|
|
|
+
|
|
|
break;
|
|
|
}
|
|
|
case 4:
|
|
@@ -821,12 +832,12 @@ static void Can_Task(void* arg)
|
|
|
}
|
|
|
case 5:
|
|
|
{
|
|
|
+ Can_ID = 0x200;
|
|
|
Batt_Cell_addU = 0x0000;
|
|
|
for (int i = 0; i < Batt_Cell_Num; i++)
|
|
|
{
|
|
|
- Batt_Cell_addU = Batt_Cell_addU + (battbuffer[31+i*2]<<8|battbuffer[31+i*2+1]);
|
|
|
+ Batt_Cell_addU = Batt_Cell_addU + (battbuffer[31+i*2]<<8|battbuffer[31+i*2+1])/10;
|
|
|
}
|
|
|
- Can_ID = 0x201;
|
|
|
Can_TxMsg.Data[0] = battbuffer[19];
|
|
|
Can_TxMsg.Data[1] = battbuffer[20];
|
|
|
Can_TxMsg.Data[2] = battbuffer[21];
|
|
@@ -1035,24 +1046,37 @@ void Tcp_Batt_Data_Assemble(void)
|
|
|
if (Batt_current>0x8000)
|
|
|
{
|
|
|
Batt_current = Batt_current|0x7fff;
|
|
|
+ Batt_current = Batt_current/10;
|
|
|
Batt_current = 0x2710 - Batt_current;
|
|
|
Batt_current = Batt_current;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ Batt_current = Batt_current/10;
|
|
|
Batt_current = Batt_current+0x2710;
|
|
|
Batt_current = Batt_current;
|
|
|
}
|
|
|
battbuffer[17] = Batt_current>>8;
|
|
|
battbuffer[18] = Batt_current;
|
|
|
- BattU = battbuffer[19]<<8|battbuffer[20];
|
|
|
- BattU = BattU/10;
|
|
|
+ BattU =( battbuffer[19]<<8|battbuffer[20])/10;
|
|
|
battbuffer[19] = BattU>>8;
|
|
|
battbuffer[20] = BattU;
|
|
|
battbuffer[21] = BattU>>8;
|
|
|
battbuffer[22] = BattU;//外电压
|
|
|
data_index = 32+Batt_Cell_Num_2+Batt_Temp_Num;
|
|
|
- battbuffer[data_index] = 0x00;//电池状态
|
|
|
+ if(Batt_current==10000)
|
|
|
+ {
|
|
|
+ battbuffer[data_index] = 0x00;//电池状态
|
|
|
+ }
|
|
|
+ else if(Batt_current>10000)
|
|
|
+ {
|
|
|
+ battbuffer[data_index] = 0x02;//电池状态
|
|
|
+ }
|
|
|
+ else if(Batt_current<10000)
|
|
|
+ {
|
|
|
+ battbuffer[data_index] = 0x01;//电池状态
|
|
|
+ }
|
|
|
+
|
|
|
data_index++;
|
|
|
battbuffer[data_index] = 0x00;//是否加热
|
|
|
data_index++;
|