Autosar 报文到底是怎么发送

本文详细介绍了报文从应用层到硬件驱动的整个发送过程,包括通过Com_SendSignal进行信号更新,经由CanIf模块处理并写入TxBuffer,直至硬件驱动通过中断将数据发送到总线。

报文到底是怎么被发出去的

报文被触发发送方式有两种

  • 轮询
  • 中断
RTE 调取发送接口
/**********************************************************************************************************************
 Function name    : Com_SendSignal
 Syntax           : uint8 Com_SendSignal(Com_SignalIdType SignalId, const void*   SignalDataPtr)
 Description      : Service updates the signal object identified by SignalId with the signal
                    referenced by the SignalDataPtr parameter.
 Parameter        : SignalId -> Id of the signal.
                  : SignalDataPtr -> The pointer to the address where the application data is available.
 Return value     : E_OK/COM_SERVICE_NOT_AVAILABLE/COM_BUSY
 *********************************************************************************************************************/
#define COM_START_SEC_CODE
#include "Com_MemMap.h"
FUNC(uint8, COM_CODE) Com_SendSignal( VAR(Com_SignalIdType, AUTOMATIC)        SignalId,
                                      P2CONST(void, AUTOMATIC, COM_APPL_DATA) SignalDataPtr )
那么数据又发给谁了呢

经过路由,往下走,走到了CanIf

在这里插入图片描述

/************************************************************************************************************/
/* Function name    : CanIf_Transmit                                                                        */
/* Syntax           : FUNC(Std_ReturnType, CANIF_CODE) CanIf_Transmit(
                                                        VAR(PduIdType,AUTOMATIC) CanIfTxSduId,
                                                        P2CONST(PduInfoType, AUTOMATIC, CANIF_APPL_CONST) CanIfTxInfoPtr
                                                                      )   */
/* Description      : This service initiates a request for transmission of the CAN L-PDU specified by the
                      CanTxPduId and CAN related data in the L-PDU structure.                               */
/* Parameter        : CanTxPduId, PduInfoPtr                                                                */
/* Return value     : E_OK / E_NOT_OK                                                                       */
/************************************************************************************************************/
#define CANIF_START_SEC_CODE
#include "CanIf_MemMap.h"

FUNC(Std_ReturnType, CANIF_CODE) CanIf_Transmit(VAR(PduIdType,AUTOMATIC) CanIfTxSduId,
        P2CONST(PduInfoType, AUTOMATIC, CANIF_APPL_CONST) CanIfTxInfoPtr)
发了半天也没发到BUS上啊

在这里插入图片描述

/**********************************************************************************************************************
 * Function name     : CanIf_Prv_WriteTxBuffer
 * Syntax            : void CanIf_Prv_WriteTxBuffer(VAR(PduIdType, AUTOMATIC) CanIfTxSduId,
 *                                                          VAR(Can_PduType, AUTOMATIC) Pdu)
 * Service ID[hex]   : --
 * Sync/Async        : --
 * Reentrancy        : --
 * Parameters (in)   : CanIfTxSduId, Pdu
 * Parameters (inout): None
 * Parameters (out)  : None
 * Return value      : Std_ReturnType
 * Description       : Function is called by CanIf_Transmit() which writes PDU to corresponding TxBuffer.                                                                                          **
 **********************************************************************************************************************/
#define CANIF_START_SEC_CODE
#include "CanIf_MemMap.h"
FUNC(Std_ReturnType, CANIF_CODE) CanIf_Prv_WriteTxBuffer(
                                                            VAR(PduIdType, AUTOMATIC) CanIfTxSduId,
                                                            VAR(Can_PduType, AUTOMATIC) Pdu
                                                        )

这里终于从CanIf到了CAN (硬件驱动相关)

硬件驱动谁来调呢

上一步CanIf 填充了Tx buffer, 这里触发了中断

在这里插入图片描述

这中断咋就被执行了呢

哦 在os 里面,根据芯片硬件的信息已经把对应的中断信息进行了配置

在这里插入图片描述

在这里插入图片描述

中断触发后怎么办呢

这时候才是真正的驱动代码把数据发送到总线,终端服务函数

/*******************************************************************************
** Traceability   : [cover parentID={D47A49B6-985A-4c4f-86D5-C17125DAE268}]   **
**                                                                            **
**                                                                            **
** Syntax           : void Can_17_McmCan_IsrTransmitHandler                   **
**                    (                                                       **
**                      const uint8 HwKernelId                                **
**                      const uint8 NodeIdIndex                               **
**                    )                                                       **
**                                                                            **
** Description    :The function identifies the message object belonging to    **
**                 the given CAN controller for which the transmission request**
**                 was successful. It extracts the corresponding software PDU **
**                 handle and gives notification to upper layer.              **
**                 The Can_17_McmCan_IsrTransmitHandler() handler is available**
**                 only when CanTxProcessing is enabled                       **
**                 Due to Mixed mode support, if one of the HTH is configured **
**                 in INTERRUPT mode every successful transmission will       **
**                 trigger interrupt.                                         **
**                                                                            **
** Service ID       : None                                                    **
**                                                                            **
** Sync/Async       : Synchronous                                             **
**                                                                            **
** Reentrancy       : Reentrant                                               **
**                                                                            **
** Parameters (in)  : HwKernelId - The CAN controller which is to be processed,*
**                    is associated with the passed Kernel                    **
**                    NodeIdIndex - The CAN node which is to be processed     **
**                                                                            **
** Parameters (out) : None                                                    **
**                                                                            **
** Return value     : None                                                    **
*******************************************************************************/
void Can_17_McmCan_IsrTransmitHandler(const uint8 HwKernelId,
                                      const uint8 NodeIdIndex)
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

想发财想自由

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值