前言
最近项目由于各种原因没有直接采用基于Autosar工具生成的代码。只使用了NXP的MCAL。Demo需求实现XCP功能。本文记录手动集成XCP协议的过程,基于CAN总线。
集成的前提过程是已有了XCP的静态代码和配置代码。可以用Etas或Vector的工具生成。
XCP发送
由于没有CAN If模块,所以涉及到的函数需要手写,本次只是实现了功能,没有保护与诊断
Std_ReturnType CanIf_Transmit(PduIdType CanIfTxSduId,
const PduInfoType * CanIfTxInfoPtr)
{
/* To store the return value */
Std_ReturnType lRetVal_en;
uint16 ltxPduCustId_t;
static Can_PduType Can_PduInfo;
if(CanIfTxSduId == Xcp_CanCfgConst.CanTxPduCfg[0].CanIfTxPduId)
{
Can_PduInfo.id = XCP_CMD_ID;
Can_PduInfo.swPduHandle = 8u;
Can_PduInfo.length = CanIfTxInfoPtr->SduLength;
Can_PduInfo.sdu = CanIfTxInfoPtr->SduDataPtr;
if((Can_Write(CanConf_CanHardwareObject