Autosar代码中Can如何唤醒MCU通讯的
写在前面:
入行一段时间了,基于个人理解整理一些东西,如有错误,欢迎各位大佬评论区指正!!!
1.WakeUp
1.1wakeup source和Check-Wakeup Validation
当Validation Timeout没有被配置为0的时候,通过调用EcuM_ValidateWakeupEvent()进行验证。如果在此期间未验证唤醒事件,EcuM将此事件设置为“过期”,并向BswM报告。该配置主要为了避免误唤醒,例如外部IO或者CAN总线上的电压脉冲唤醒。
以下五种标准的唤醒源不需要校验。
唤醒源分为四种状态:
1.2Can唤醒流程
以TJA1043为例,ECU系统休眠后TJA1043的INH脚处于floating高阻态,外部电路为下拉到低电平。在配置中将TJA1043的INH引脚配置为唤醒源,在休眠中如果收到任意报文该引脚会被拉高,产生一个CAN硬件唤醒事件。如果系统为KL15系统,INH引脚会关联到SBC,INH被触发拉高后ECU会被启动。如果系统为常电系统,INH关联到ECU中断唤醒引脚,通过检测INH唤醒事件激活MCU。
1.2.1EcuM
1.2.2CanIF
1.2.3流程图
2.代码逻辑
1.中断触发EcuM_CheckWakeup(EcuM_WakeupSourceType)
FUNC(void, ECUM_CODE) EcuM_CheckWakeup(EcuM_WakeupSourceType wakeupSource) /* COV_ECUM_CALLOUT */
{
EcuM_StartCheckWakeup(wakeupSource);
EcuM_SetWakeupEvent(wakeupSource);
return;
} /* End of EcuM_CheckWakeup() */
2.调用EcuM_SetWakeupEvent(EcuM_WakeupSourceType)设置唤醒事件
3.EcuM_StartWakeupSources(EcuM_WakeupSourceType)
FUNC(void, ECUM_CODE) EcuM_StartWakeupSources(EcuM_WakeupSourceType wakeupSource) /* PRQA S 3206 */ /* MD_EcuM_3206 */
{
/* Add implementation of EcuM_StartWakeupSources() */
if ((wakeupSource & ECUM_WKSOURCE_CN_ADCANFD_e4bb3036) != 0)
{
(void)CanSM_StartWakeupSources(ComMConf_ComMChannel_CN_ADCANFD_e4bb3036);
}
if ((wakeupSource & ECUM_WKSOURCE_CN_ChassisCAN1_fd490d2b) != 0)
{
(void)CanSM_StartWakeupSources(ComMConf_ComMChannel_CN_ChassisCAN1_fd490d2b);
}
if ((wakeupSource & ECUM_WKSOURCE_CN_FLRCANFD_83cba2e1) != 0)
{
(void)CanSM_StartWakeupSources(ComMConf_ComMChannel_CN_FLRCANFD_83cba2e1);
}
return;
}
4.CanSM_StartWakeupSources(EcuM_WakeupSourceType)设置CanTrancv和driver到NORMAL/START模式用于接收CAN报文。
5.EcuM_CheckValidation(EcuM_WakeupSourceType)
FUNC(void, ECUM_CODE) EcuM_CheckValidation(EcuM_WakeupSourceType wakeupSource)
{
if ((wakeupSource & ECUM_WKSOURCE_CN_ADCANFD_e4bb3036) != 0)
{
CanIf_CheckValidation(ECUM_WKSOURCE_CN_ADCANFD_e4bb3036);
}
if ((wakeupSource & ECUM_WKSOURCE_CN_ChassisCAN1_fd490d2b) != 0)
{
CanIf_CheckValidation(ECUM_WKSOURCE_CN_ChassisCAN1_fd490d2b);
}
if ((wakeupSource & ECUM_WKSOURCE_CN_FLRCANFD_83cba2e1) != 0)
{
CanIf_CheckValidation(ECUM_WKSOURCE_CN_FLRCANFD_83cba2e1);
}
if ((wakeupSource & ECUM_WKSOURCE_BackboneFR_ADCU_008eca5e) != 0)
{
FrIf_CheckWakeupByTransceiver(FrIfConf_FrIfCluster_BackboneFR_688eb60b,FR_CHANNEL_A);
}
return;
}
6.CanIf_CheckValidation(EcuM_WakupSourceType)校验唤醒源
7.校验成功则调用ComM_WakeUpIndication()请求通信,ComMCommunicationAlllowed后就会调转到Full Com状态开启网络.
8.校验失败则调用EcuM_StopWakeupSources()—-CanSM_StopWakeupSources()
FUNC(void, ECUM_CODE) EcuM_StopWakeupSources(EcuM_WakeupSourceType wakeupSource) /* PRQA S 3206 */ /* MD_EcuM_3206 */
{
if ((wakeupSource & ECUM_WKSOURCE_CN_ADCANFD_e4bb3036) != 0)
{
(void)CanSM_StopWakeupSources(ComMConf_ComMChannel_CN_ADCANFD_e4bb3036,wakeupSource);
}
if ((wakeupSource & ECUM_WKSOURCE_CN_ChassisCAN1_fd490d2b) != 0)
{
(void)CanSM_StopWakeupSources(ComMConf_ComMChannel_CN_ChassisCAN1_fd490d2b,wakeupSource);
}
if ((wakeupSource & ECUM_WKSOURCE_CN_FLRCANFD_83cba2e1) != 0)
{
(void)CanSM_StopWakeupSources(ComMConf_ComMChannel_CN_FLRCANFD_83cba2e1,wakeupSource);
}
return;
}
作者:说不得明天