Commit e5be831f authored by 李冠华's avatar 李冠华

feat:增加仪表CAN信号唤醒功能,优化仪表休眠流程

parent 33e78888
......@@ -5,6 +5,8 @@
#include "can.h"
#include "RTE.h"
uint16_t EnterDeepSleepCount = 0U;
__align(4)
uint32_t pRXBuff[CAN_RX_MSG_Block * CAN_CH0_ID_TOTAL_MAX];
uint32_t pTXBuff[CAN_TX_MSG_Block * CAN_CH0_ID_SEND_TOTAL];
......@@ -341,6 +343,7 @@ void Can_Tx_Apply_Buff(void)
*/
void Can_Rx_Cak(CanTxRxMsg *Msg)
{
EnterDeepSleepCount = 0U;
Co_Can_Buff_Set(&CAN_CH0_CanMsgOp, Co_Can_ConvertSubID_CAN_CH0(Msg->Id), Msg->DLC, Msg->Data);
if ((Msg->Id == DIAG_ID_Rx_FUN) || (Msg->Id == DIAG_ID_Rx_PHY))
......@@ -348,6 +351,20 @@ void Can_Rx_Cak(CanTxRxMsg *Msg)
DoCAN_L_Data_Indication(Msg->Id, Msg->DLC, Msg->Data);
}
}
/*放到哪个任务中调用,就传入time的值是多少,如:100ms任务中就传入100*/
void CAN_Offline_Count(uint8_t time)
{
if(Get_CAN_Power_State() < KEY_ACC)
{
EnterDeepSleepCount += time;
}
else
{
EnterDeepSleepCount = 0U;
}
}
/**
* @brief CAN库初始化TX/RX
*
......
......@@ -30,7 +30,7 @@ typedef struct
uint8_t RecoverTimer;
} RSCAN0BusoffMonitorStruct;
extern uint16_t EnterDeepSleepCount;
extern void CAN_TX_Init(void);
extern void Can_Tx_Apply_Buff(void);
......@@ -39,6 +39,7 @@ extern void Can_BusOff_Recover(uint8_t deltaTime);
extern void COM_CAN_Init(void);
extern void Can_Init(void);
extern void Can_Rx_Cak(CanTxRxMsg *Msg);
extern void CAN_Offline_Count(uint8_t time);
extern uint8_t COM_APP_Process(st_CAN_Msg *Msg);
extern void Can_Write(st_CAN_Msg *Msg);
......
......@@ -71,7 +71,7 @@ static void Power_KL30_Init(void)
g_stRTCInformation.u8RTCMonth = 1;
g_stRTCInformation.u8RTCYear = 20;
RTE_RTC_Init(g_stRTCInformation);
RTE_DEEPSLEEP_GPIO_Interrupt_Enable(KL15_AD_IN,Trigger_Rising);
// RTE_DEEPSLEEP_GPIO_Interrupt_Enable(KL15_AD_IN,Trigger_Rising);
Data_Soc_KL30_Init();
Data_Time_KL30_Init();
Data_Gear_KL30_Init();
......@@ -84,6 +84,7 @@ extern uint32_t PowerIgnOffTimeLine;
static void Power_Wakeup_Init(void)
{
PowerIgnOffTimeLine = 0;
g_u8CanrxSleepstate = 0U;
Simulated_IIC_2_Init();
Gpio_Init(Gpio_WakeUp_Init);
Can_Init();
......@@ -100,7 +101,7 @@ static void Power_Wakeup_Init(void)
TimerM_PWM_CH_Output_init(TIMERM_COUNTER0, TIMERM_CHD, ActiveLevel_High);
TimerM_PWM_CH_Output_init(TIMERM_COUNTER1, TIMERM_CHB, ActiveLevel_High);
Telltales_Init();
RTE_DEEPSLEEP_GPIO_Interrupt_Enable(KL15_AD_IN,Trigger_Rising);
// RTE_DEEPSLEEP_GPIO_Interrupt_Enable(KL15_AD_IN,Trigger_Rising);
}
static void Power_LVP_Init(void)
......@@ -146,7 +147,9 @@ static void Power_Sleep_Init(void)
LED_Driver_Init_Sleep();
LED_Driver_Service();
Analog_Signal_Conv_Stop();
RTE_DEEPSLEEP_Enable();
// RTE_DEEPSLEEP_Enable();
RTE_DEEPSLEEP_GPIO_Interrupt_Enable(CAN_MCU_RXD,Trigger_Falling);
g_u8CanrxSleepstate = 0U;
}
static Power_Status_em Power_Stay_ON(void)
......@@ -170,8 +173,8 @@ static Power_Status_em Power_Stay_OFF(void)
{
Power_Status_em u8PowerSts;
u8PowerSts = EM_IGN_OFF;
if (SYS_OPR_STAT_IGN_ON)
#if (PART_NUMBER == RMR42E_60)
if (Common_Get_IG_Sts( ) == COMMON_POWER_ON)
{
u8PowerSts = EM_IGN_ON_Init;
}
......@@ -186,7 +189,38 @@ static Power_Status_em Power_Stay_OFF(void)
// u8PowerSts = EM_IGN_Sleep_Init;
// }
}
#else
if (Get_CAN_Power_State() == KEY_ACC)
{
u8PowerSts = EM_IGN_ON_Init;
}
else
{
if (Get_CAN_Power_State() == PKEY_ON)
{
if (EnterDeepSleepCount >= 5000)
{
u8PowerSts = EM_IGN_Sleep_Init;
}
else
{
u8PowerSts = EM_IGN_OFF;
}
}
else
{
if ((Common_GetIgnOffTime() < 5000))
{
u8PowerSts = EM_IGN_OFF;
}
else
{
u8PowerSts = EM_IGN_Sleep_Init;
}
}
}
#endif
return u8PowerSts;
}
......@@ -262,7 +296,7 @@ static Power_Status_em Power_Stay_Protect(void)
static Power_Status_em Power_Stay_Sleep(void)
{
Power_Status_em u8PowerSts = EM_IGN_Sleep;
#if (PART_NUMBER == RMR42E_60)
while (1)
{
RTE_WDT_Clear();
......@@ -272,7 +306,22 @@ static Power_Status_em Power_Stay_Sleep(void)
break;
}
}
#else
while (1)
{
RTE_WDT_Clear();
if ((Get_CAN_Power_State() == PKEY_ON) && (g_u8CanrxSleepstate == 1U))/*当电源状态出于PKEY_ON,且接到CAN信号时,才能触发唤醒*/
{
u8PowerSts = EM_IGN_Wakeup;
g_u8CanrxSleepstate = 0U;
break;
}
else
{
RTE_DEEPSLEEP_Enable();
}
}
#endif
return u8PowerSts;
}
......
......@@ -177,10 +177,13 @@ void DEEPSLEEP_EXTI0_IRQHandler(void *msg)
* @warning None
* @since 1.0.0
*/
unsigned char g_u8CanrxSleepstate = 0U;
void DEEPSLEEP_EXTI1_IRQHandler(void *msg)
{
/* ����жϱ�־ */
INTC_ClearPendingIRQ(INTP1_IRQn);
g_u8CanrxSleepstate = 1U;
}
/**
......
......@@ -5,6 +5,7 @@
#include "gpio.h"
#include "intp.h"
extern unsigned char g_u8CanrxSleepstate;
extern void RTE_DEEPSLEEP_GPIO_Interrupt_Enable(uint16_t u16Pin, Trigger_TypeDef EXTI_Trigger);
extern void RTE_DEEPSLEEP_Enable(void);
......
......@@ -36,6 +36,7 @@ void Sys_10ms_Tasks(void)
Data_CumulativeWorkHours_EEPROM_Write();
BackLight_Service();
Fault_Code_Service();
CAN_Offline_Count(10U);
}
void Sys_20ms_Tasks(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment