AUTOSAR Classic CAN
Das CAN-Cluster (Controller Area Network) stellt hardwarenahe Treiber, standardisierte Hardware-Abstraktion (CanIf), State-Management und ISO 15765-2 Transportprotokolle (CanTp) für klassische CAN-, CAN FD- und CAN XL-Netzwerke bereit.
初始化与状态
Can_DeInitCan_GetVersionInfoCan_InitCanIf_DeInitCanIf_GetVersionInfoCanIf_InitCanNm_DeInitCanNm_GetVersionInfoCanNm_InitCanSM_DeInitCanSM_GetVersionInfoCanSM_InitCanTp_GetVersionInfoCanTp_InitCanTrcv_DeInitCanTrcv_GetVersionInfoCanTrcv_Init服务 · T…
服务 · Get…
服务 · Set…
服务 · Check…
服务 · Read…
服务 · Clear…
服务 · Controller…
服务 · Confirm…
服务 · Enable…
服务 · Request…
服务 · Transmit…
服务 · 其他
Can_DisableControllerInterruptsCan_WriteCanIf_ErrorNotificationCanIf_TrcvModeIndicationCanNm_ActivateTxPnShutdownMsgCanNm_DeactivateTxPnShutdownMsgCanNm_DisableCommunicationCanNm_NetworkReleaseCanNm_NetworkRequestCanNm_PassiveStartUpCanNm_PnLearningRequestCanNm_RepeatMessageRequestCanSM_CurrentIcomConfigurationCanSM_StartWakeupSourceCanSM_StopWakeupSourceCanSM_TransceiverModeIndicationCanSM_TxTimeoutExceptionCanTp_CancelReceiveCanTp_CancelTransmitCanTp_ChangeParameterCanTp_ShutdownCanXL_ImmediateTransmitCanXL_ReleaseRxBuffer回调
CanIf_RxIndicationCanIf_TriggerTransmitCanIf_TxConfirmationCanNm_RxIndicationCanNm_TriggerTransmitCanNm_TxConfirmationCanTp_RxIndicationCanTp_TxConfirmationCallout 与预期接口
<LPDU_CalloutName><User_CheckTrcvWakeFlagIndication><User_ClearTrcvWufFlagIndication><User_ConfirmPnAvailability><User_ControllerBusOff><User_ControllerModeIndication><User_Get Bus Off Delay><User_RxIndication><User_TrcvModeIndication><User_TriggerTransmit><User_TriggerTransmit> (TtcanIf)<User_TxConfirmation><User_ValidateWakeupEvent>周期性
Can_MainFunction_BusOffCan_MainFunction_ModeCan_MainFunction_ReadCan_MainFunction_WakeupCan_MainFunction_WriteCanNm_MainFunctionCanSM_MainFunctionCanTp_MainFunctionCanTrcv_MainFunctionCanTrcv_MainFunctionDiagnostics类型
Can_ConfigTypeCan_ControllerStateTypeCan_ErrorStateTypeCan_ErrorTypeCan_HwHandleTypeCan_HwTypeCan_IdTypeCan_PduTypeCan_TTErrorLevelEnumTypeCan_TTErrorLevelTypeCan_TTMasterSlaveModeTypeCan_TTMasterStateTypeCan_TTSyncModeEnumTypeCan_TTTimeSourceTypeCan_TTTimeTypeCanIf_ConfigTypeCanIf_NotifStatusTypeCanIf_PduModeTypeCanIf_TTErrorLevelEnumTypeCanIf_TTErrorLevelTypeCanIf_TTEventEnumTypeCanIf_TTMasterSlaveModeTypeCanIf_TTMasterStateTypeCanIf_TTSevereErrorEnumTypeCanIf_TTSyncModeEnumTypeCanIf_TTTimeSourceTypeCanIf_TTTimeTypeCanIf_TTTimingErrorIRQTypeCanNm_ConfigTypeCanSM_BswMCurrentStateTypeCanSM_ConfigTypeCanSM_StateTypeCanTp_ConfigTypeCanTrcv_ConfigTypeCanTrcv_PNActivationTypeCanTrcv_TrcvFlagStateTypeCanTrcv_TrcvModeTypeCanTrcv_TrcvWakeupModeTypeCanTrcv_TrcvWakeupReasonType函数
<LPDU_CalloutName><User_CheckTrcvWakeFlagIndication><User_ClearTrcvWufFlagIndication><User_ConfirmPnAvailability><User_ControllerBusOff><User_ControllerModeIndication><User_Get Bus Off Delay><User_RxIndication><User_TrcvModeIndication><User_TriggerTransmit><User_TriggerTransmit> (TtcanIf)<User_TxConfirmation><User_ValidateWakeupEvent>Can_CheckWakeupCan_DeInitCan_DisableControllerInterruptsCan_EnableControllerInterruptsCan_GetControllerErrorStateCan_GetControllerModeCan_GetControllerRxErrorCounterCan_GetControllerTxErrorCounterCan_GetVersionInfoCan_InitCan_MainFunction_BusOffCan_MainFunction_ModeCan_MainFunction_ReadCan_MainFunction_WakeupCan_MainFunction_WriteCan_SetBaudrateCan_SetControllerModeCan_TTAckTimeMarkCan_TTCancelTimeMarkCan_TTDisableTimeMarkIRQCan_TTEnableTimeMarkIRQCan_TTGetControllerTimeCan_TTGetErrorLevelCan_TTGetMasterStateCan_TTGetNTUActualCan_TTGetSyncQualityCan_TTGetTimeMarkIRQStatusCan_TTGlobalTimePresetCan_TTMainFunction_IRQCan_TTReceiveCan_TTSetEndOfGapCan_TTSetExtClockSyncCommandCan_TTSetNextIsGapCan_TTSetNTUAdjustCan_TTSetTimeCommandCan_TTSetTimeMarkCan_WriteCanIf_CheckTrcvWakeFlagCanIf_CheckTrcvWakeFlagIndicationCanIf_CheckValidationCanIf_CheckWakeupCanIf_ClearTrcvWufFlagCanIf_ClearTrcvWufFlagIndicationCanIf_ConfirmPnAvailabilityCanIf_ControllerBusOffCanIf_ControllerErrorStatePassiveCanIf_ControllerModeIndicationCanIf_DeInitCanIf_EnableBusMirroringCanIf_ErrorNotificationCanIf_GetControllerErrorStateCanIf_GetControllerModeCanIf_GetControllerRxErrorCounterCanIf_GetControllerTxErrorCounterCanIf_GetPduModeCanIf_GetTrcvModeCanIf_GetTrcvWakeupReasonCanIf_GetTxConfirmationStateCanIf_GetVersionInfoCanIf_InitCanIf_ReadRxNotifStatusCanIf_ReadRxPduDataCanIf_ReadTxNotifStatusCanIf_RxIndicationCanIf_SetBaudrateCanIf_SetControllerModeCanIf_SetDynamicTxIdCanIf_SetPduModeCanIf_SetTrcvModeCanIf_SetTrcvWakeupModeCanIf_TransmitCanIf_TrcvModeIndicationCanIf_TriggerTransmitCanIf_TTAckTimeMarkCanIf_TTApplWatchdogErrorCanIf_TTCancelTimeMarkCanIf_TTDisableTimeMarkIRQCanIf_TTEnableTimeMarkIRQCanIf_TTGapCanIf_TTGetControllerTimeCanIf_TTGetErrorLevelCanIf_TTGetMasterStateCanIf_TTGetNTUActualCanIf_TTGetSyncQualityCanIf_TTGetTimeMarkIRQStatusCanIf_TTGlobalTimePresetCanIf_TTJobListExec_ControllerCanIf_TTMasterStateChangeCanIf_TTSetEndOfGapCanIf_TTSetExtClockSyncCommandCanIf_TTSetNextIsGapCanIf_TTSetNTUAdjustCanIf_TTSetTimeCommandCanIf_TTSetTimeMarkCanIf_TTSevereErrorCanIf_TTStartOfCycleCanIf_TTTimeDiscCanIf_TTTimingErrorCanIf_TxConfirmationCanNm_ActivateTxPnShutdownMsgCanNm_CheckRemoteSleepIndicationCanNm_ConfirmPnAvailabilityCanNm_DeactivateTxPnShutdownMsgCanNm_DeInitCanNm_DisableCommunicationCanNm_EnableCommunicationCanNm_GetLocalNodeIdentifierCanNm_GetNodeIdentifierCanNm_GetPduDataCanNm_GetStateCanNm_GetUserDataCanNm_GetVersionInfoCanNm_InitCanNm_MainFunctionCanNm_NetworkReleaseCanNm_NetworkRequestCanNm_PassiveStartUpCanNm_PnLearningRequestCanNm_RepeatMessageRequestCanNm_RequestBusSynchronizationCanNm_RequestSynchronizedPncShutdownCanNm_RxIndicationCanNm_SetSleepReadyBitCanNm_SetUserDataCanNm_TransmitCanNm_TriggerTransmitCanNm_TxConfirmationCanSM_CheckTransceiverWakeFlagIndicationCanSM_ClearTrcvWufFlagIndicationCanSM_ConfirmCtrlPnAvailabilityCanSM_ConfirmPnAvailabilityCanSM_ControllerBusOffCanSM_ControllerModeIndicationCanSM_CurrentIcomConfigurationCanSM_DeInitCanSM_GetCurrentComModeCanSM_GetVersionInfoCanSM_InitCanSM_MainFunctionCanSM_RequestComModeCanSM_SetBaudrateCanSM_SetEcuPassiveCanSM_SetIcomConfigurationCanSM_StartWakeupSourceCanSM_StopWakeupSourceCanSM_TransceiverModeIndicationCanSM_TxTimeoutExceptionCanTp_CancelReceiveCanTp_CancelTransmitCanTp_ChangeParameterCanTp_GetVersionInfoCanTp_InitCanTp_MainFunctionCanTp_ReadParameterCanTp_RxIndicationCanTp_ShutdownCanTp_TransmitCanTp_TxConfirmationCanTrcv_CheckWakeFlagCanTrcv_CheckWakeupCanTrcv_ClearTrcvTimeoutFlagCanTrcv_ClearTrcvWufFlagCanTrcv_DeInitCanTrcv_GetBusWuReasonCanTrcv_GetOpModeCanTrcv_GetTrcvSystemDataCanTrcv_GetVersionInfoCanTrcv_InitCanTrcv_MainFunctionCanTrcv_MainFunctionDiagnosticsCanTrcv_ReadTrcvSilenceFlagCanTrcv_ReadTrcvTimeoutFlagCanTrcv_SetOpModeCanTrcv_SetPNActivationStateCanTrcv_SetWakeupModeCanXL_ImmediateTransmitCanXL_ReleaseRxBuffer类型
Can_ConfigTypeCan_ControllerStateTypeCan_ErrorStateTypeCan_ErrorTypeCan_HwHandleTypeCan_HwTypeCan_IdTypeCan_PduTypeCan_TTErrorLevelEnumTypeCan_TTErrorLevelTypeCan_TTMasterSlaveModeTypeCan_TTMasterStateTypeCan_TTSyncModeEnumTypeCan_TTTimeSourceTypeCan_TTTimeTypeCanIf_ConfigTypeCanIf_NotifStatusTypeCanIf_PduModeTypeCanIf_TTErrorLevelEnumTypeCanIf_TTErrorLevelTypeCanIf_TTEventEnumTypeCanIf_TTMasterSlaveModeTypeCanIf_TTMasterStateTypeCanIf_TTSevereErrorEnumTypeCanIf_TTSyncModeEnumTypeCanIf_TTTimeSourceTypeCanIf_TTTimeTypeCanIf_TTTimingErrorIRQTypeCanNm_ConfigTypeCanSM_BswMCurrentStateTypeCanSM_ConfigTypeCanSM_StateTypeCanTp_ConfigTypeCanTrcv_ConfigTypeCanTrcv_PNActivationTypeCanTrcv_TrcvFlagStateTypeCanTrcv_TrcvModeTypeCanTrcv_TrcvWakeupModeTypeCanTrcv_TrcvWakeupReasonType主题图
Can
27CanIf
50CanNm
29CanSM
24CanTp
12CanTrcv
23Ttcan
26TtcanIf
36此版本没有元素数据
Can
-
boolean <LPDU_CalloutName> (uint8 Hrh, Can_IdType CanId, uint8 CanDataLegth, const uint8* CanSduPtr);This function checks if a wakeup has occurred for the given controller.
Std_ReturnType Can_CheckWakeup (uint8 Controller);This function de - initializes the module.
void Can_DeInit (void);This function disables all interrupts for this CAN controller.
void Can_DisableControllerInterrupts (uint8 Controller);This function enables all allowed interrupts.
void Can_EnableControllerInterrupts (uint8 Controller);This service obtains the error state of the CAN controller.
Std_ReturnType Can_GetControllerErrorState (uint8 ControllerId, Can_ErrorStateType* ErrorStatePtr);This service reports about the current status of the requested CAN controller.
Std_ReturnType Can_GetControllerMode (uint8 Controller, Can_ControllerStateType* ControllerModePtr);Returns the Rx error counter for a CAN controller. This value might not be available for all CAN controllers, in which cas e E_ NOT_ OK would be returned. Please note that the value of the counter might not be correct at the moment the API returns it, because the Rx counter is handled asynchronously in hardware. Applications should not trust this value for any assumption about the current bus state.
Std_ReturnType Can_GetControllerRxErrorCounter (uint8 ControllerId, uint8* RxErrorCounterPtr);Returns the Tx error counter for a CAN controller. This value might not be available for all CAN controllers, in which case E_ NOT_ OK would be returned. Please note that the value of the counter might not be correct at the moment the API returns it, because the Tx counter is handled asynchronously in hardware. Applications should not trust this value for any assumption about the current bus state.
Std_ReturnType Can_GetControllerTxErrorCounter (uint8 ControllerId, uint8* TxErrorCounterPtr);This function returns the version information of this module.
void Can_GetVersionInfo (Std_VersionInfoType* versioninfo);This function initializes the module.
void Can_Init (const Can_ConfigType* Config);This function performs the polling of bus - off events that are configured statically as 'to be polled'.
void Can_MainFunction_BusOff (void);This function performs the polling of CAN controller mode transitions.
void Can_MainFunction_Mode (void);This function performs the polling of RX indications when CAN_ RX_ PROCESSING is set to POLLING.
void Can_MainFunction_Read (void);This function performs the polling of wake - up events that are configured statically as 'to be polled'.
void Can_MainFunction_Wakeup (void);This function performs the polling of TX confirmation when CAN_ TX_ PROCESSING is set to POLLING.
void Can_MainFunction_Write (void);This service shall set the baud rate configuration of the CAN controller. Depending on necessary baud rate modifications the controller might have to reset.
Std_ReturnType Can_SetBaudrate (uint8 Controller, uint16 BaudRateConfig ID); ⚠️This function performs software triggered state transitions of the CAN controller State machine.
Std_ReturnType Can_SetControllerMode (uint8 Controller, Can_ControllerStateType Transition);This function is called by Can If to pass a CAN message to Can Drv for transmission.
Std_ReturnType Can_Write (Can_HwHandleType Hth, const Can_PduType* PduInfo);This is the type of the external data structure containing the overall initialization data for the CAN driver and SFR settings affecting all controllers. Furthermore it contains pointers to controller configuration structures. The contents of the initializ ation data structure are CAN hardware specific.
States that are used by the several Controller Mode functions.
Error states of a CAN controller.
The enumeration represents a superset of CAN Error Types which typical CAN HW is able to report. That means not all CAN HW will be able to support the complete set.
Represents the hardware object handles of a CAN hardware unit. For CAN hardware units with more than 255 HW objects use extended range.
This type defines a data structure which clearly provides an Hardware Object Handle including its corresponding CAN Controller and therefore Can Drv as well as the specific Can Id.
Represents the Identifier of an L - PDU. The two most significant bits specify the frame type: 00 CAN message with Standard CAN ID 01 CAN FD frame with Standard CAN ID 10 CAN message with Extended CAN ID 11 CAN FD frame with Extended CAN ID
This type unites Pdu Id (sw Pdu Handle), Sdu Length (length), Sdu Data (sdu), and Can Id (id) for any CAN L - SDU.
CanIf
This service indicates that the wake up flag in the CAN transceiver is set. This function is called in CanIf_CheckTrcvWakeFlagIndication.
void <User_CheckTrcvWakeFlagIndication> (uint8 TransceiverId);This service indicates that the CAN transceiver has cleared the WufFlag. This function is called in CanIf_ClearTrcvWufFlagIndication.
void <User_ClearTrcvWufFlagIndication> (uint8 TransceiverId);This service indicates that the CAN transceiver is running in PN communication mode.
void <User_ConfirmPnAvailability> (uint8 TransceiverId);This service indicates a bus-off event to the corresponding upper layer module (mainly the CAN State Manager module).
void <User_ControllerBusOff> (uint8 ControllerId);This service indicates a CAN controller state transition to the corresponding upper layer module (mainly the CAN State Manager module).
void <User_ControllerModeIndication> (uint8 ControllerId, Can_ControllerStateType ControllerMode);Indication of a received PDU from a lower layer communication interface module.
void <User_RxIndication> (PduIdType RxPduId, const PduInfoType* PduInfoPtr);This service indicates a CAN transceiver state transition to the corresponding upper layer module (mainly the CAN State Manager module).
void <User_TrcvModeIndication> (uint8 TransceiverId, CanTrcv_TrcvModeType TransceiverMode);Within this API, the upper layer module (called module) shall check whether the available data fits into the buffer size reported by PduInfoPtr->SduLength. If it fits, it shall copy its data into the buffer provided by PduInfoPtr->SduDataPtr and update the length of the actual copied data in PduInfoPtr->SduLength. If not, it returns E_NOT_OK without changing PduInfoPtr.
Std_ReturnType <User_TriggerTransmit> (PduIdType TxPduId, PduInfoType* PduInfoPtr);The lower layer communication interface module confirms the transmission of a PDU, or the failure to transmit a PDU.
void <User_TxConfirmation> (PduIdType TxPduId, Std_ReturnType result);This service indicates if a wake up event initiated from the wake up source (CAN controller or transceiver) after a former request to the CAN Driver or CAN Transceiver Driver module is valid.
void <User_ValidateWakeupEvent> (EcuM_WakeupSourceType sources);Requests the CanIf module to check the Wake flag of the designated CAN transceiver.
Std_ReturnType CanIf_CheckTrcvWakeFlag (uint8 TransceiverId);This service indicates that the check of the transceiver's wake-up flag has been finished by the corresponding CAN transceiver with the abstract CanIf TransceiverId. This indication is used to cope with the asynchronous transceiver communication.
void CanIf_CheckTrcvWakeFlagIndication (uint8 TransceiverId);This service is performed to validate a previous wakeup event.
Std_ReturnType CanIf_CheckValidation (EcuM_WakeupSourceType WakeupSource);This service checks, whether an underlying CAN driver or a CAN transceiver driver already signals a wakeup event.
Std_ReturnType CanIf_CheckWakeup (EcuM_WakeupSourceType WakeupSource);Requests the CanIf module to clear the WUF flag of the designated CAN transceiver.
Std_ReturnType CanIf_ClearTrcvWufFlag (uint8 TransceiverId);This service indicates that the transceiver has cleared the WufFlag referring to the corresponding CAN transceiver with the abstract CanIf TransceiverId.
void CanIf_ClearTrcvWufFlagIndication (uint8 TransceiverId);This service indicates that the transceiver is running in PN communication mode referring to the corresponding CAN transceiver with the abstract CanIf TransceiverId.
void CanIf_ConfirmPnAvailability (uint8 TransceiverId);This service indicates a Controller BusOff event referring to the corresponding CAN Controller with the abstract CanIf ControllerId.
void CanIf_ControllerBusOff (uint8 ControllerId);The function derives the ErrorCounterTreshold from RxErrorCounter/ TxErrorCounter values and reports it to the IdsM as security event CANIF_SEV_ERRORSTATE_PASSIVE to the IdsM. It also prepares the context data for the respective security event.
This service indicates a controller state transition referring to the corresponding CAN controller with the abstract CanIf ControllerId.
void CanIf_ControllerModeIndication (uint8 ControllerId, Can_ControllerStateType ControllerMode);De-initializes the CanIf module.
void CanIf_DeInit (void);Enables or disables mirroring for a CAN controller.
Std_ReturnType CanIf_EnableBusMirroring (uint8 ControllerId, boolean MirroringActive);The function shall derive the bus error source rx or tx from the parameter CanError and report the bus error as security event CANIF_SEV_TX_ERROR_DETECTED or CANIF_SEV_RX_ ERROR_DETECTED. It also prepares the context data for the respective security event.
void CanIf_ErrorNotification (uint8 ControllerId, Can_ErrorType Can_ErrorType);This service calls the corresponding CAN Driver service for obtaining the error state of the CAN controller.
Std_ReturnType CanIf_GetControllerErrorState (uint8 ControllerId, Can_ErrorStateType* ErrorStatePtr);This service calls the corresponding CAN Driver service for obtaining the current status of the CAN controller.
Std_ReturnType CanIf_GetControllerMode (uint8 ControllerId, Can_ControllerStateType* ControllerModePtr);This service calls the corresponding CAN Driver service for obtaining the Rx error counter of the CAN controller.
Std_ReturnType CanIf_GetControllerRxErrorCounter (uint8 ControllerId, uint8* RxErrorCounterPtr);This service calls the corresponding CAN Driver service for obtaining the Tx error counter of the CAN controller.
Std_ReturnType CanIf_GetControllerTxErrorCounter (uint8 ControllerId, uint8* TxErrorCounterPtr);This service reports the current mode of a requested PDU channel.
Std_ReturnType CanIf_GetPduMode (uint8 ControllerId, CanIf_PduModeType* PduModePtr);This function invokes CanTrcv_GetOpMode and updates the parameter TransceiverModePtr with the value OpMode provided by CanTrcv.
Std_ReturnType CanIf_GetTrcvMode (uint8 TransceiverId, CanTrcv_TrcvModeType* TransceiverModePtr);This service returns the reason for the wake up of the transceiver TransceiverId, via calling the corresponding CAN Transceiver Driver service.
Std_ReturnType CanIf_GetTrcvWakeupReason (uint8 TransceiverId, CanTrcv_TrcvWakeupReasonType* TrcvWuReasonPtr);This service reports, if any TX confirmation has been done for the whole CAN controller since the last CAN controller start.
CanIf_NotifStatusType CanIf_GetTxConfirmationState (uint8 ControllerId);This service returns the version information of the called CAN Interface module.
void CanIf_GetVersionInfo (Std_VersionInfoType* VersionInfo);This service Initializes internal and external interfaces of the CAN Interface for the further processing.
void CanIf_Init (const CanIf_ConfigType* ConfigPtr);This service returns the indication status (indication occurred or not) of a specific CAN Rx L-PDU, requested by the CanIfRxSduId.
CanIf_NotifStatusType CanIf_ReadRxNotifStatus (PduIdType CanIfRxSduId);This service provides the Data Length and the received data of the requested CanIfRxSduId to the calling upper layer.
Std_ReturnType CanIf_ReadRxPduData (PduIdType CanIfRxSduId, PduInfoType* CanIfRxInfoPtr);This service returns the confirmation status (confirmation occurred or not) of a specific static or dynamic CAN Tx L-PDU, requested by the CanIfTxSduId.
CanIf_NotifStatusType CanIf_ReadTxNotifStatus (PduIdType CanIfTxSduId);This service indicates a successful reception of a received CAN Rx L-PDU to the CanIf after passing all filters and validation checks.
void CanIf_RxIndication (const Can_HwType* Mailbox, const PduInfoType* PduInfoPtr);This service shall set the baud rate configuration of the CAN controller. Depending on necessary baud rate modifications the controller might have to reset.
Std_ReturnType CanIf_SetBaudrate (uint8 ControllerId, uint16 BaudRateConfigID);This service calls the corresponding CAN Driver service for changing of the CAN controller mode.
Std_ReturnType CanIf_SetControllerMode (uint8 ControllerId, Can_ControllerStateType ControllerMode);This service reconfigures the corresponding CAN identifier of the requested CAN L-PDU.
void CanIf_SetDynamicTxId (PduIdType CanIfTxSduId, Can_IdType CanId);This service sets the requested mode at the L-PDUs of a predefined logical PDU channel.
Std_ReturnType CanIf_SetPduMode (uint8 ControllerId, CanIf_PduModeType PduModeRequest);This service changes the operation mode of the tansceiver TransceiverId, via calling the corresponding CAN Transceiver Driver service.
Std_ReturnType CanIf_SetTrcvMode (uint8 TransceiverId, CanTrcv_TrcvModeType TransceiverMode);This function shall call CanTrcv_SetTrcvWakeupMode.
Std_ReturnType CanIf_SetTrcvWakeupMode (uint8 TransceiverId, CanTrcv_TrcvWakeupModeType TrcvWakeupMode);Requests transmission of a PDU.
Std_ReturnType CanIf_Transmit (PduIdType TxPduId, const PduInfoType* PduInfoPtr);This service indicates a transceiver state transition referring to the corresponding CAN transceiver with the abstract CanIf TransceiverId.
void CanIf_TrcvModeIndication (uint8 TransceiverId, CanTrcv_TrcvModeType TransceiverMode);Within this API, the upper layer module (called module) shall check whether the available data fits into the buffer size reported by PduInfoPtr->SduLength. If it fits, it shall copy its data into the buffer provided by PduInfoPtr->SduDataPtr and update the length of the actual copied data in PduInfoPtr->SduLength. If not, it returns E_NOT_OK without changing PduInfoPtr.
Std_ReturnType CanIf_TriggerTransmit (PduIdType TxPduId, PduInfoType* PduInfoPtr);This service confirms a previously successfully processed transmission of a CAN TxPDU.
void CanIf_TxConfirmation (PduIdType CanTxPduId);This type defines a data structure for the post build parameters of the CAN interface for all underlying CAN drivers. At initialization the CanIf gets a pointer to a structure of this type to get access to its configuration data, which is necessary for initialization.
Type CanIf_NotifStatusType.
The PduMode of a channel defines its transmit or receive activity. Communication direction (transmission and/or reception) of the channel can be controlled separately or together by upper layers.
CanNm
NM indicate to activate the transmission of PN shutdown messages on the given NM - Channel. This results in transmission of a NM - PD U with PNSR bit set to 1 (PN shutdown message).
Std_ReturnType CanNm_ActivateTxPnShutdownMsg(NetworkHandleType nmChannelHandle);Check if remote sleep indication takes place or not.
Std_ReturnType CanNm_CheckRemoteSleepIndication(NetworkHandleType nmChannelHandle, boolean* nmRemoteSleepIndPtr);Enables the PN filter functionality on the indicated NM channel. Availability: The API is only available if Can Nm Global Pn Support is TRUE.
void CanNm_ConfirmPnAvailability(NetworkHandleType nmChannelHandle);NM indicate to deactive the transmission of PN shutdown messages on the given NM - Channel. This result in transmission of a usual NM - PDUs with PNSR bit set to 0.
Std_ReturnType CanNm_DeactivateTxPnShutdownMsg(NetworkHandleType nmChannelHandle);De - initializes the Can Nm module.
void CanNm_DeInit(void);Disable the NM PDU transmission ability due to a ISO14229 Communication Control (28hex) service
Std_ReturnType CanNm_DisableCommunication(NetworkHandleType nmChannelHandle);Enable the NM PDU transmission ability due to a ISO14229 Communication Control (28hex) service
Std_ReturnType CanNm_EnableCommunication(NetworkHandleType nmChannelHandle);Get node identifier configured for the local node.
Std_ReturnType CanNm_GetLocalNodeIdentifier(NetworkHandleType nmChannelHandle, uint8* nmNodeIdPtr);Get node identifier out of the most recently received N M PDU.
Std_ReturnType CanNm_GetNodeIdentifier(NetworkHandleType nmChannelHandle, uint8* nmNodeIdPtr);Get the whole PDU data out of the most recently received NM PDU.
Std_ReturnType CanNm_GetPduData(NetworkHandleType nmChannelHandle, uint8* nmPduDataPtr);Returns the state and the mode of the network management.
Std_ReturnType CanNm_GetState(NetworkHandleType nmChannelHandle, Nm_StateType* nmStatePtr, Nm_ModeType* nmModePtr);Get user data out of the most recently received NM PDU.
Std_ReturnType CanNm_GetUserData(NetworkHandleType nmChannelHandle, uint8* nmUserDataPtr);This service returns the version information of this module.
void CanNm_GetVersionInfo(Std_VersionInfoType* versioninfo);Initialize the Can Nm module.
void CanNm_Init(const CanNm_ConfigType* cannmConfigPtr);Main function of the Can Nm which processes the algorithm describes in that document.
void CanNm_MainFunction(void);Release the network, since ECU doesn't have to communicate on the bus.
Std_ReturnType CanNm_NetworkRelease(NetworkHandleType nmChannelHandle);Request the network, since ECU needs to communicate on the bus.
Std_ReturnType CanNm_NetworkRequest(NetworkHandleType nmChannelHandle);Passive startup of the AUTOSAR CAN NM. It triggers the transition from Bus - Sleep Mode or Prepare Bus Sleep Mode to the Network Mode in Repeat Message State. Caveats: Can Nm is initia lized correctly.
Std_ReturnType CanNm_PassiveStartUp(NetworkHandleType nmChannelHandle);Set Repeat Message Request Bit and Partial Network Learning Bit for NM messages transmitted next on the bus. This will force all nodes to enter the PNC Learning Phase. This is needed for the optional Dynamic PNC - to - channel - mapping feature.
Std_ReturnType CanNm_PnLearningRequest(NetworkHandleType nmChannelHandle);Set Repeat Message Request Bit for NM PDUs transmitted next on the bus.
Std_ReturnType CanNm_RepeatMessageRequest(NetworkHandleType nmChannelHandle);Request bus synchronization.
Std_ReturnType CanNm_RequestBusSynchronization(NetworkHandleType nmChannelHandle);Requests transmission of a NM - PDU with PNSR bit set to 1 (PN shutdown message) Tags: atp.Status=draft
Std_ReturnType CanNm_RequestSynchronizedPncShutdown(NetworkHandleType nmChannelHandle, PNCHandleType pncId);Indication of a receive d PDU from a lower layer communication interface module.
void CanNm_RxIndication(PduIdType RxPduId, const PduInfoType* PduInfoPtr);Set the NM Coordinator S leep Ready bit in the Control Bit Vector
Std_ReturnType CanNm_SetSleepReadyBit(NetworkHandleType nmChannelHandle, boolean nmSleepReadyBit);Set user data for NM PDUs transmitted next on the bus.
Std_ReturnType CanNm_SetUserData(NetworkHandleType nmChannelHandle, const uint8* nmUserDataPtr);Requests transmission of a PDU.
Std_ReturnType CanNm_Transmit(PduIdType TxPduId, const PduInfoType* PduInfoPtr);Within this API, the upper layer module (called module) shall check whether the available data fits into the buffer size reported by Pdu Info Ptr - >Sdu Length. If it fits, it shall copy its data into the buffer provided by Pdu Info Ptr - >Sdu Data Ptr and update the length of the actual copied data in Pdu Info Ptr - >Sdu Length. If not, it returns E_ NOT_ OK without changing Pdu Info Ptr.
Std_ReturnType CanNm_TriggerTransmit(PduIdType TxPduId, PduInfoType* PduInfoPtr);The lower layer communication interface module confirms the transmission of a PDU, or the failure to transmit a PDU.
void CanNm_TxConfirmation(PduIdType TxPduId, Std_ReturnType result);This type shall contain at least all parameters that are post - build able according to chapter 10.
CanSM
This callout function returns the number of Can SM base cycles to wait additionally to L1/ L2 after a Bus Off occurred.
void <User_Get Bus Off Delay>(NetworkHandleType network, uint8* delayCyclesPtr);This callback function indicates the Can If_ Check Trcv Wake Flag API process end for the notified CAN Transceiver.
void CanSM_CheckTransceiverWakeFlagIndication(uint8 Transceiver);This callback function shall indicate the Can If_ Clear Trcv Wuf Flag API process end for the notified CAN Transceiver.
void CanSM_ClearTrcvWufFlagIndication(uint8 Transceiver);This callback function indicates that the controller is running in PN communication mode. Tags: atp.Status=draft
void CanSM_ConfirmCtrlPnAvailability(uint8 ControllerId);This callback function indicates that the transceiver is running in PN communication mode.
void CanSM_ConfirmPnAvailability(uint8 TransceiverId);This callback function notifies the Can SM about a bus - off event on a certain CAN controller, which needs to be considered with the specified bus - off recovery handling for th e impacted CAN network.
void CanSM_ControllerBusOff(uint8 ControllerId);This callback shall notify the Can SM module about a CAN controller mode change.
void CanSM_ControllerModeIndication(uint8 ControllerId, Can_ControllerStateType ControllerMode);This service shall inform about the change of the Icom Configuration of a CAN network.
void CanSM_CurrentIcomConfiguration(uint8 ControllerId, IcomConfigIdType ConfigurationId, IcomSwitch_ErrorType Error);This service de - initializes the Can SM module.
void CanSM_DeInit(void);This service shall put out the current communication mode of a CAN network.
Std_ReturnType CanSM_GetCurrentComMode(NetworkHandleType network, ComM_ModeType* ComM_ModePtr);This service puts out the version information of this module (module ID, vendor ID, vendor specific version numbers related to BSW00407)
void CanSM_GetVersionInfo(Std_VersionInfoType* VersionInfo);This service initializes the Can SM module
void CanSM_Init(const CanSM_ConfigType* ConfigPtr);Scheduled function of the Can SM
void CanSM_MainFunction(void);This service shall change the communication mode of a CAN network to the requested one.
Std_ReturnType CanSM_RequestComMode(NetworkHandleType network, ComM_ModeType ComM_Mode);This service shall start an asynchronous process to change the baud rate for the configured CAN controllers of a certain CAN network. Depending on necessary baud rate modifications the controllers might have to reset.
Std_ReturnType CanSM_SetBaudrate(NetworkHandleType Network, uint16 BaudRateConfig ID); ⚠️Service Name Can SM_ Set Ecu Passive Syntax Std_ Return Type Can SM_ Set Ecu Passive ( boolean Can SM_ Passive ) Service ID [hex] 0x13 Sync/ Async Synchronous Reentrancy Non Reentrant Parameters (in) Can SM_ Passive TRUE: set all Can SM channels to passive, i.e. receive only FALSE: set all Can SM channels back to non - passive Parameters (inout) None Parameters (out) None Return value Std _ Return - E_ OK: Request accepted Type E_ NOT_ OK: Request not accepted Descr iption This function can be used to set all Can SM channels of the ECU to a receive only mode. Available via Can SM.h
Std_ReturnType CanSM_SetEcuPassive(boolean CanSM_Passive);This service shall change the Icom Configuration of a CAN network to the requested one.
Std_ReturnType CanSM_SetIcomConfiguration(NetworkHandleType Network, IcomConfigIdType ConfigurationId);This function shall be called by Ecu M when a wakeup source shall be started.
Std_ReturnType CanSM_StartWakeupSource(NetworkHandleType network);This function shall be called by Ecu M when a wakeup source shall be stopped.
Std_ReturnType CanSM_StopWakeupSource(NetworkHandleType network);This callback shall notify the Can SM module about a CAN transceiver mode change.
void CanSM_TransceiverModeIndication(uint8 TransceiverId, CanTrcv_TrcvModeType TransceiverMode);This function shall notify the Can SM module, that the Can Nm has detected for the affected partial CAN network a tx timeout exception, which shall be recovered within the respective network state machine of the Can SM module.
void CanSM_TxTimeoutException(NetworkHandleType Channel);Can specific communication modes / states notified to the Bsw M module
This type defines a data structure for the post build parameters of the Can SM. At initialization the Can SM gets a pointer to a structure of this type to get access to its configuration data, which is neces sary for initialization. Available Can SM.h via
Defines the values of the internal states of the Can SM module
CanTp
Requests cancellation of an ongoing reception of a PDU in a lower layer transport protocol module.
Std_ReturnType CanTp_CancelReceive (PduIdType RxPduId);Requests cancellation of an ongoing transmission of a PDU in a lower layer communication module.
Std_ReturnType CanTp_CancelTransmit (PduIdType TxPduId);Request to change a specific transport protocol parameter (e.g. block size).
Std_ReturnType CanTp_ChangeParameter (PduIdType id, TPParameterType parameter, uint16 value);This function returns the version information of the Can Tp module.
void CanTp_GetVersionInfo (Std_VersionInfoType* versioninfo);This function initializes the Can Tp module.
void CanTp_Init (const CanTp_ConfigType* CfgPtr);The main function for scheduling the CAN TP.
void CanTp_MainFunction (void);This service is used to read the current value of reception parameters BS and STmin for a specified N - SDU.
Std_ReturnType CanTp_ReadParameter (PduIdType id, TPParameterType parameter, uint16* value);Indication of a received PDU from a lower layer communication interface module.
void CanTp_RxIndication (PduIdType RxPduId, const PduInfoType* PduInfoPtr);This function is called to shutdown the Can Tp module.
void CanTp_Shutdown (void);Requests transmission of a PDU.
Std_ReturnType CanTp_Transmit (PduIdType TxPduId, const PduInfoType* PduInfoPtr);The lower layer communication interface module confirms the transmission of a PDU, or the failure to transmit a PDU.
void CanTp_TxConfirmation (PduIdType TxPduId, Std_ReturnType result);Data structure type for the post - build configuration parameters.
CanTrcv
Requests to check the status of the wakeup flag from the transceiver hardware.
Std_ReturnType CanTrcv_CheckWakeFlag (uint8 Transceiver);Service is called by underlying CANIF in case a wake up interrupt is detected.
Std_ReturnType CanTrcv_CheckWakeup (uint8 Transceiver);Clears the status of the timeout flag in the transceiver hardware. This API shall exist only if Can Trcv Hw Pn Support = TRUE.
Std_ReturnType CanTrcv_ClearTrcvTimeoutFlag (uint8 Transceiver);Clears the WUF flag in the transceiver hardware. This API shall exist only if Can Trcv Hw Pn Support = TRUE.
Std_ReturnType CanTrcv_ClearTrcvWufFlag (uint8 Transceiver);De - initializes the Can Trcv module.
void CanTrcv_DeInit (void);Gets the wakeup reason for the Transceiver and returns it in parameter Reason.
Std_ReturnType CanTrcv_GetBusWuReason (uint8 Transceiver, CanTrcv_TrcvWakeupReasonType* reason);Gets the mode of the Transceiver and returns it in Op Mode.
Std_ReturnType CanTrcv_GetOpMode (uint8 Transceiver, CanTrcv_TrcvModeType* OpMode);Reads the transceiver configuration/ status data and returns it through parameter Trcv Sys Data. This API shall exist only if Can Trcv Hw Pn Support = TRUE.
Std_ReturnType CanTrcv_GetTrcvSystemData (uint8 Transceiver, uint32* TrcvSysData);Gets the version of the module and returns it in Version Info.
void CanTrcv_GetVersionInfo (Std_VersionInfoType* versioninfo);Initializes the Can Trcv module.
void CanTrcv_Init (const CanTrcv_ConfigType* ConfigPtr);Service to scan all busses for wake up events and perform these event.
void CanTrcv_MainFunction (void);Reads the transceiver diagnostic status periodically and sets product/ development accordingly.
void CanTrcv_MainFunctionDiagnostics (void);Reads the status of the silence flag from the transceiver hardware. This API shall exi st only if Can Trcv Hw Pn Support = TRUE.
Std_ReturnType CanTrcv_ReadTrcvSilenceFlag (uint8 Transceiver, CanTrcv_TrcvFlagStateType* FlagState);Reads the status of the tim eout flag from the transceiver hardware. This API shall exist only if Can Trcv Hw Pn Support = TRUE.
Std_ReturnType CanTrcv_ReadTrcvTimeoutFlag (uint8 Transceiver, CanTrcv_TrcvFlagStateType* FlagState);Sets the mode of the Transceiver to the value Op Mode.
Std_ReturnType CanTrcv_SetOpMode (uint8 Transceiver, CanTrcv_TrcvModeType OpMode);The API configures the wake - up of the transceiver for Standby and Sleep Mode: Either the CAN transceiver is woken up by a remote wake - up pattern (standard CAN wake - up) or by the configured remote wake - up frame.
Std_ReturnType CanTrcv_SetPNActivationState (CanTrcv_PNActivationType ActivationState);En ables, disables or clears wake - up events of the Transceiver according to Trcv Wakeup Mode.
Std_ReturnType CanTrcv_SetWakeupMode (uint8 Transceiver, CanTrcv_TrcvWakeupModeType TrcvWakeupMode);This is the type of the external data structure containing the overall initialization data for the CAN transceiver driver and settings affecting all transceivers. Furthermore it contains pointers to transceiver configuration structures. The con tents of the initialization data structure are CAN transceiver hardware specific.
Datatype used for describing whether PN wakeup functionality in Can Trcv is enabled or disabled.
Provides the state of a flag in the transceiver hardware.
Operating modes of the CAN Transceiver Driver.
This type shall be used to control the CAN transceiver concerning wake up events and wake up notifications.
This type denotes the wake up reason detected by the CAN transceiver in detail. AUTOSAR CP R20 - of Document ID : AUTOSAR_SWS_CANTransceiverDriver
CanXL
Request transmission of an Ethernet frame, where each upper layer a header part as element of a single linked list. All headers together with the payload form an entire Ethernet frame Tags: atp.Status=draft
Std_ReturnType CanXL_ImmediateTransmit(uint8 CtrlIdx, Eth_BufIdxType TxHandleId, uint8 Priority, ListElemStructType* HeaderListPtr, uint8* PayloadPtr, uint16 PayloadLength);Indication from the upper layer to release the reception buffer (ingress queue element) of the given physical Ethernet controller. Tags: atp.Status=draft
void CanXL_ReleaseRxBuffer(uint8 CtrlIdx, Eth_BufIdxType RxHandleId);Ttcan
Acknowledges the time mark interrupt by resetting the flag in the interrupt vector register.
void Can_TTAckTimeMark(uint8 Controller);Cancels the time mark.
void Can_TTCancelTimeMark(uint8 Controller);Disables the time mark interrupt.
void Can_TTDisableTimeMarkIRQ(uint8 Controller);Enables the time mark interrupt.
void Can_TTEnableTimeMarkIRQ(uint8 Controller);Gets the error level. This includes the severity of the error level (S0-S3) and the minimum and maximum value of the message status count.
void Can_TTGetErrorLevel(uint8 Controller, Can_TTErrorLevelType* Can_TTErrorLevel);Gets the master state. The master state includes the sync mode (sync_off, synchronizing, in_ gap, in_schedule) the master-slave mode (master_off, slave, backup_master, current_master) and the current value for ref trigger offset.
void Can_TTGetMasterState(uint8 Controller, Can_TTMasterStateType* Can_TTMasterState);Gets the actual value of NTU (network time unit). Together with the local oscillator period, the actual value of NTU can be derived from the actual value of TUR.
void Can_TTGetNTUActual(uint8 Controller, Can_TTTURType* Can_TTTURAct);Sets the value of "global time preset".
void Can_TTGlobalTimePreset(uint8 Controller, Can_TTTimeType Can_TTGlobalTimePreset);Polls the interrupt flags specific to TTCAN
void Can_TTMainFunction_IRQ(void);Reads received data from the controller by returning the pointer of the CanID, the DLC and the Data of the message in the requested HRH.
void Can_TTReceive(uint8 Controller, uint8 Hrh, Can_IdType* CanId, uint8* CanDlc, uint8* CanSduPtr);Signals the end of a gap.
void Can_TTSetEndOfGap(uint8 Controller);Adjusts the NTU (network time unit) according to the value given by "NTU adjust". Together with the local oscillator period, "TUR adjust" can be derived from "NTU adjust".
void Can_TTSetExtClockSyncCommand(uint8 Controller);Sets the "Next_is_Gap" bit.
void Can_TTSetNextIsGap(uint8 Controller);Sets the value of "NTU adjust". Together with the local oscillator period, "TUR adjust" can be derived from "NTU adjust".
void Can_TTSetNTUAdjust(uint8 Controller, Can_TTTURType Can_TTTURAdjust);Adjusts the global time at the beginning of the next basic cycle by the amount of "global time preset"
void Can_TTSetTimeCommand(uint8 Controller);Sets a new value for the time mark for the given time source.
void Can_TTSetTimeMark(uint8 Controller, Can_TTTimeType Can_TTTimeMark, Can_TTTimeSourceType Can_TTTimeSource);Error level (S0-S3)
TTCAN error level including min and max values of message status count
Master-Slave Mode
Master state type including sync mode, master-slave mode and current ref trigger offset
Sync mode
Time source
16 bit value representing time values of TTCAN, e.g. cycle, local or global time
TtcanIf
Within this API, the upper layer module (called module) shall check whether the available data fits into the buffer size reported by PduInfoPtr->SduLength. If it fits, it shall copy its data into the buffer provided by PduInfoPtr->SduDataPtr and update the length of the actual copied data in PduInfoPtr->SduLength. If not, it returns E_NOT_OK without changing PduInfoPtr.
Std_ReturnType <User_TriggerTransmit>(PduIdType TxPduId, PduInfoType* PduInfoPtr);Acknowledges the time mark interrupt by resetting the flag in the interrupt vector register.
Std_ReturnType CanIf_TTAckTimeMark(uint8 ControllerId);Reports an application watchdog error.
Std_ReturnType CanIf_TTApplWatchdogError(uint8 ControllerId);Cancels the time mark.
Std_ReturnType CanIf_TTCancelTimeMark(uint8 ControllerId);Disables the time mark interrupt.
Std_ReturnType CanIf_TTDisableTimeMarkIRQ(uint8 ControllerId);Enables the time mark interrupt.
Std_ReturnType CanIf_TTEnableTimeMarkIRQ(uint8 ControllerId);Reports the occurrence of a gap.
Std_ReturnType CanIf_TTGap(uint8 ControllerId);Gets the current values for the global, local and cycle time and the cycle count of the controller
Std_ReturnType CanIf_TTGetControllerTime(uint8 ControllerId, CanIf_TTTimeType* CanIf_TTGlobalTime, CanIf_TTTimeType* CanIf_TTLocalTime, CanIf_TTTimeType* CanIf_TTCycleTime, uint8* CanIf_TTCycleCount);Gets the error level. This includes the severity of the error level (S0-S3) and the minimum and maximum value of the message status count.
Std_ReturnType CanIf_TTGetErrorLevel(uint8 ControllerId, CanIf_TTErrorLevelType* CanIf_TTErrorLevel);Gets the master state. The master state includes the sync mode (sync_off, synchronizing, in_ gap, in_schedule) the master-slave mode (master_off, slave, backup_master, current_master) and the current value for ref trigger offset.
Std_ReturnType CanIf_TTGetMasterState(uint8 ControllerId, CanIf_TTMasterStateType* CanIf_TTMasterState);Gets the actual value of NTU (network time unit). Together with the local oscillator period, the actual value of NTU can be derived from the actual value of TUR.
Std_ReturnType CanIf_TTGetNTUActual(uint8 ControllerId, float32 CanIf_TTNTUAct);Gets the synchronization quality.
Std_ReturnType CanIf_TTGetSyncQuality(uint8 ControllerId, boolean* CanIf_TTClockSpeed, boolean* CanIf_TTGlobalTimePhase);Gets the IRQ status of the time mark.
Std_ReturnType CanIf_TTGetTimeMarkIRQStatus(uint8 ControllerId, boolean* CanIf_TTIRQStatus);Sets the value of "global time preset".
Std_ReturnType CanIf_TTGlobalTimePreset(uint8 ControllerId, CanIf_TTTimeType CanIf_TTGlobalTimePreset);Processes the job list of the TTCAN controller <Controller>.
void CanIf_TTJobListExec_<Controller>(void);Reports change of the master state between potential and current master.
Std_ReturnType CanIf_TTMasterStateChange(uint8 ControllerId, CanIf_TTMasterStateType CanIf_TTMasterState);Signals the end of a gap.
Std_ReturnType CanIf_TTSetEndOfGap(uint8 ControllerId);Adjusts the NTU (network time unit) according to the value given by "NTU adjust". Together with the local oscillator period, "TUR adjust" can be derived from "NTU adjust".
Std_ReturnType CanIf_TTSetExtClockSyncCommand(uint8 ControllerId);Sets the "Next_is_Gap" bit.
Std_ReturnType CanIf_TTSetNextIsGap(uint8 ControllerId);Sets the value of "NTU adjust". Together with the local oscillator period, "TUR adjust" can be derived from "NTU adjust".
Std_ReturnType CanIf_TTSetNTUAdjust(uint8 ControllerId, float32 CanIf_TTNTUAdjust);Adjusts the global time at the beginning of the next basic cycle by the amount of "global time preset"
Std_ReturnType CanIf_TTSetTimeCommand(uint8 ControllerId);Sets a new value for the time mark for the given time source.
Std_ReturnType CanIf_TTSetTimeMark(uint8 ControllerId, CanIf_TTTimeType CanIf_TTTimeMark, CanIf_TTTimeSourceType CanIf_TTTimeSource);Reports one of the following errors: • failed to serve appl. watchdog • config error • watch trigger reached
void CanIf_TTSevereError(uint8 ControllerId, CanIf_TTSevereErrorEnumType CanIf_TTSevereError);Reports the start of a basic cycle.
Std_ReturnType CanIf_TTStartOfCycle(uint8 ControllerId, uint8 CanIf_TTCycleCount);Reports a time discontinuity.
Std_ReturnType CanIf_TTTimeDisc(uint8 ControllerId);Reports one of the following errors: • Change of error level • Tx overflow / underflow • Synchronization failed • Init watch trigger
Std_ReturnType CanIf_TTTimingError(uint8 ControllerId, CanIf_TTTimingErrorIRQType CanIf_TTTimingErrorIRQ);Error level (S0-S3)
TTCAN error level including min and max values of message status count
Event that causes a Timing/Error IRQ
Master-Slave Mode
Master state type including sync mode, master-slave mode and current ref trigger offset
Event that causes a severe error
Sync mode
Time source of time values in TTCAN
16 bit value representing time values of TTCAN, e.g. cycle, local or global time
Combines all events that are reported by CanIf_TTTimingError (event indication and error level)
集群指南人工智能生成
为 CAN 提供硬件驱动程序、接口抽象、分段和收发器控制。
为 CAN 提供硬件驱动程序、接口抽象、分段和收发器控制。
该 Cluster 将 CAN 驱动程序、CAN Interface、符合 ISO 15765-2 的传输协议以及收发器驱动程序连接为 CAN 通信栈的下半部分。上层通过 CanIf_Transmit() 发送。CanIf 将 L-PDU 映射到硬件对象,在硬件繁忙时对其进行缓冲,并分发接收和确认消息 [SWS_CANIF_00005]。CanTp 对大型报文进行分段,并通过 PduR 逐步获取数据 [SWS_CanTp_00086]。仅当控制器处于 CAN_CS_STARTED 状态且 PDU 通道处于就绪发送状态时才进行发送;模式由 CanSM 通过 CanIf 进行控制。
该 Cluster 构成 CAN 通信栈的下部。Can 控制控制器和邮箱,CanIf 抽象驱动程序、控制器和收发器,CanTp 按照 ISO 15765-2 进行分段,CanTrcv 管理收发器的运行模式。CanIf 仅通过驱动程序服务访问硬件缓冲区 [SWS_CANIF_00023]。它为上层提供统一的 ControllerId 和 TransceiverId 范围 [SWS_CANIF_00653] [SWS_CANIF_00655]。
上下文图:CanIf 在一方面是 PduR、CanTp、CanSM 和 EcuM,另一方面是驱动程序 Can 和 CanTrcv 之间进行中介协调。来源:[SWS_CANIF_00005] [SWS_CANIF_00006] [SWS_CANIF_00358]
发送时,CanIf_Transmit() 使用匹配的 HTH 调用 Can_Write() [SWS_CANIF_00318]。若驱动程序报告 CAN_BUSY,CanIf 会缓冲该 L-PDU [SWS_CANIF_00381]。在发送确认期间,它会补发具有最高优先级的缓冲条目 [SWS_CANIF_00668]。接收到的 L-PDU 在 CanIf 中经过软件过滤和数据长度检查后,再由 CanIf 转发给 CanTp 或 PduR [SWS_CANIF_00389] [SWS_CANIF_00390]。CanTp 本身不缓冲有效数据,而是通过 PduR_CanTpCopyTxData() 获取数据或通过 PduR_CanTpCopyRxData() 传递数据 [SWS_CanTp_00086] [SWS_CanTp_00269]。
时序图:直接发送或在 CAN_BUSY 时缓冲,随后在 CanIf_TxConfirmation 中从缓冲区补发。来源:[SWS_CANIF_00381] [SWS_CANIF_00183]
Can 通过其中断或轮询受控的 MainFunctions 工作 [SWS_Can_00225] [SWS_Can_00226]。CanTp_RxIndication() 必须能够在中断上下文中被调用 [SWS_CanTp_00235],而 CanTp_MainFunction() 负责监控协议超时 [SWS_CanTp_00164]。CanIf 保护共享缓冲区免受抢占式访问 [SWS_CANIF_00064]。
初始化后,所有 CanIf 通道均处于 CANIF_OFFLINE 状态 [SWS_CANIF_00864]。CanSM 通过 CanIf_SetControllerMode() 切换控制器 [SWS_CANIF_00308]。SLEEP 强制进入 CANIF_OFFLINE,STOPPED 或 BusOff 强制进入 CANIF_TX_OFFLINE [SWS_CANIF_00865] [SWS_CANIF_00866]。CanIf 向 CanSM 报告 BusOff [SWS_CANIF_00724]。错误上报至 DET;CanTrcv 还向 DEM 报告 CANTRCV_E_BUS_ERROR [SWS_CanTrcv_00206]。发生超时时,CanTp 会以否定确认终止会话 [SWS_CanTp_00310]。
系统架构与 Cluster 的角色
“CAN Communication”Cluster 构成用于 CAN 的 AUTOSAR 通信栈的下部。它从底层 CAN 驱动程序一直延伸至 PduR 和 DCM 所依托的传输协议。核心是 CAN Interface,它将上层与驱动程序及硬件细节解耦。它仅通过驱动程序的服务访问特定于硬件的通信缓冲区 [SWS_CANIF_00023]。它通过独立的 ControllerId 和 TransceiverId 范围对多个驱动程序实例的控制器和收发器进行抽象 [SWS_CANIF_00653] [SWS_CANIF_00655]。
| 模块 | 在 Cluster 中的角色 | 凭据 |
|---|---|---|
Can | 访问 CAN 控制器和邮箱,通过 Can_Write() 发送,每个控制器具有独立状态机 | [SWS_Can_00233] [SWS_Can_91013] |
CanIf | 将 L-PDU 映射至 HTH/HRH、软件过滤、发送缓冲、管理控制器、PDU 通道和收发器的模式 | [SWS_CANIF_00662] [SWS_CANIF_00137] |
CanTp | 基于 ISO 15765-2 的分段与重组、流控制、多路并行连接 | [SWS_CanTp_00033] [SWS_CanTp_00096] |
CanTrcv | NORMAL、STANDBY 和 SLEEP 运行模式,唤醒原因,收发器诊断 | [SWS_CanTrcv_00102] [SWS_CanTrcv_00107] |
CanIf 通过两种类型的句柄对硬件寻址:用于发送对象的 HTH 和用于接收对象的 HRH [SWS_CANIF_00291] [SWS_CANIF_00292]。CanIf 通过每个驱动程序的函数指针接入多个 CAN 驱动程序 [SWS_CANIF_00378]。发生回调时,CanIf 根据 Can_HwType 结构体中的 ControllerId 识别发出调用的驱动程序 CanIf 第68页。对于每种收发器硬件类型,恰好存在一个 CanTrcv 实例 [SWS_CanTrcv_00016]。
上下文图:CanIf 是上层(PduR、CanTp、CanSM、EcuM)与驱动程序 Can 和 CanTrcv 之间的核心枢纽。来源:[SWS_CANIF_00005] [SWS_CANIF_00006] [SWS_CANIF_00358] [SWS_CANIF_00724] [SWS_CanTp_00216] [SWS_CanTrcv_00206]
协作与交互路径
发送:上层调用 CanIf_Transmit() [SWS_CANIF_00005]。CanIf 确定该 TxPduId 对应的 HTH,并使用 Can_PduType 结构体调用 Can_Write() [SWS_CANIF_00318] [SWS_Can_00415]。若 Can_Write() 返回 E_OK,则 CanIf_Transmit() 也返回 E_OK [SWS_CANIF_00162]。若没有空闲的发送对象,驱动程序将报告 CAN_BUSY [SWS_Can_00039]。若启用了发送缓冲,CanIf 会将该 L-PDU 存放在 CanIfTxBuffer 中 [SWS_CANIF_00381] [SWS_CANIF_00063] CanIf 第138页。
发送确认:发送成功后,Can 调用 CanIf_TxConfirmation() [SWS_CANIF_00007]。为此,驱动程序会记住来自 Can_Write() 的 swPduHandle Can 第40页。在此过程中,CanIf 检查是否有针对释放的 HTH 所缓冲的条目。它补发按照 ISO 11898-1 具有最高优先级的条目,并立即将其从缓冲区中移除 [SWS_CANIF_00386] [SWS_CANIF_00070] [SWS_CANIF_00668] [SWS_CANIF_00183]。随后上层接收到 <User_TxConfirmation>(E_OK) [SWS_CANIF_00383]。
时序图:直接发送或在 CAN_BUSY 时缓冲的发送请求,以及在发送确认期间从缓冲区补发。来源:[SWS_CANIF_00318] [SWS_CANIF_00381] [SWS_CANIF_00668] [SWS_CANIF_00183] CanIf 第157页
接收:Can 通过 CanIf_RxIndication() 报告接收到的 L-PDU [SWS_CANIF_00006]。对于 BasicCAN-HRH,CanIf 首先执行软件过滤,然后执行数据长度检查 [SWS_CANIF_00389] [SWS_CANIF_00390] [SWS_CANIF_00663]。随后它将指示转发给配置的接收方 [SWS_CANIF_00415] [SWS_CANIF_00056],例如转发给 CanTp_RxIndication [SWS_CANIF_00448] 或 PduR_CanIfRxIndication [SWS_CANIF_00442]。
传输协议:若数据无法容纳在一个 N-PDU 中,CanTp_Transmit() [SWS_CanTp_00212] 会启动分段传输 [SWS_CanTp_00232]。CanTp 本身不缓冲有效数据,而是通过 PduR_CanTpCopyTxData() [SWS_CanTp_00086] [SWS_CanTp_00298] 为每个 SF、FF 和 CF 获取数据。它通过 CanIf_Transmit() [SWS_CanTp_00216] 传递报文帧。在接收到 SF 或 FF 时,CanTp 使用 PduR_CanTpStartOfReception() 查询可用缓冲区 [SWS_CanTp_00079] [SWS_CanTp_00080]。它使用 PduR_CanTpCopyRxData() [SWS_CanTp_00269] 复制每个 CF。若缓冲区不足以容纳下一个块,CanTp 会发送 Flow Control WAIT [SWS_CanTp_00082] [SWS_CanTp_00325] CanTp 第37页。
收发器:CanIf_SetTrcvMode() 将模式请求转发至 CanTrcv_SetOpMode() [SWS_CANIF_00358]。完成切换后,CanTrcv 调用 CanIf_TrcvModeIndication() [SWS_CanTrcv_00158],CanIf 将该消息转发给 CanSM [SWS_CANIF_00712]。同样,CanIf_GetTrcvWakeupReason() 和 CanIf_SetTrcvWakeupMode() 也委托给 CanTrcv [SWS_CANIF_00368] [SWS_CANIF_00372]。
同步、重入性与任务上下文
对于不同的 PduId,CanIf_Transmit() 是可重入的;对于相同的 PduId,则不可重入 [SWS_CANIF_00005]。CanIf 必须保护共享资源免受相互之间的抢占式访问 [SWS_CANIF_00064]。这尤其涉及发送缓冲区 [SWS_CANIF_00033]、在 CanIf_SetDynamicTxId() 期间动态 L-PDU 的 CanId [SWS_CANIF_00673],以及在 CanIf_ReadRxPduData() 期间的接收缓冲区 [SWS_CANIF_00199]。
Can 支持中断和轮询运行。MainFunctions 根据配置轮询发送确认、接收、BusOff、唤醒以及控制器模式 [SWS_Can_00225] [SWS_Can_00226] [SWS_Can_00227] [SWS_Can_00228] [SWS_Can_00368] CanIf 第152页。因此像 CanIf_ControllerBusOff() 这样的回调可选择在中断级别或任务级别运行 CanIf 第119页。Can_DisableControllerInterrupts() 和 Can_EnableControllerInterrupts() 具有嵌套效果:每个加锁操作都需要对应的解锁释放 [SWS_Can_00231] [SWS_Can_00232] Can 第61页。
CanTp_RxIndication() 和 CanTp_TxConfirmation() 必须能够在中断上下文中被调用 [SWS_CanTp_00235] [SWS_CanTp_00236]。CanTp_MainFunction() 周期性地服务定时器 N_As、N_Bs、N_Cs、N_Ar、N_Br、N_Cr 和 STmin [SWS_CanTp_00213] [SWS_CanTp_00164]。其时钟节拍遵循参数 CanTpMainFunctionPeriod [SWS_CanTp_00300]。解释:该周期大概率决定了超时所能达到的分辨率。每个连接使用独立的缓冲区、定时器和独立的状态机 [SWS_CanTp_00122] CanTp 第42页。CanTrcv_MainFunction() 周期性地在处于 STANDBY 和 SLEEP 的总线上搜索唤醒事件 [SWS_CanTrcv_00013] [SWS_CanTrcv_00112]。 问题 Q-6ee587d8a8f38bff (未决)
生命周期与运行模式
EcuM 使用 CanIf_Init() 初始化 CanIf,并分别初始化驱动程序 Can 和 CanTrcv CanIf 第40页 [SWS_Can_00223] [SWS_CanTrcv_00001]。CanTrcv_Init() 根据配置将各个收发器置于 SLEEP 或 STANDBY [SWS_CanTrcv_00148]。CanTrcv 所使用的驱动程序必须在此之前就绪 [SWS_CanTrcv_00099]。初始化后,CanIf 预期控制器处于 STOPPED 状态,并将所有通道置为 CANIF_OFFLINE [SWS_CANIF_00864]。CanIf 会拒绝初始化之前的服务调用 [SWS_CANIF_00661]。解释:因此 Can 和 CanTrcv 大概率应在 CanIf 之前进行初始化。 问题 Q-4af03fca13da9a5b (未决)CanTp 通过 CanTp_Init() 从 CANTP_OFF 切换至 CANTP_ON [SWS_CanTp_00027] [SWS_CanTp_00170]。分段仅在 CANTP_ON 状态下执行 [SWS_CanTp_00238] CanTp 第27页。
模式切换由 CanSM 控制:CanIf_SetControllerMode() 调用 Can_SetControllerMode() [SWS_CANIF_00003] [SWS_CANIF_00308]。Can 通过 CanIf_ControllerModeIndication() 异步报告完成情况,CanIf 将其转发给 CanSM [SWS_CANIF_00699] [SWS_CANIF_00711]。控制器状态为 UNINIT、STOPPED、STARTED 和 SLEEP [SWS_Can_91013] Can 第38页。在其之上是 CanIf 的 PDU 通道模式 [SWS_CANIF_00137]。CanIf_SetPduMode() 仅在 CAN_CS_STARTED 状态下被接受 [SWS_CANIF_00874]。SLEEP 强制进入 CANIF_OFFLINE;STOPPED 或 BusOff 强制进入 CANIF_TX_OFFLINE [SWS_CANIF_00865] [SWS_CANIF_00866]。
状态图:CanIf 的 PDU 通道模式由 CanIf_SetPduMode 以及控制器模式的切换所决定。来源:[SWS_CANIF_00137] [SWS_CANIF_00864] [SWS_CANIF_00865] [SWS_CANIF_00866] [SWS_CANIF_00874] CanIf 第61页
对于唤醒,CanIf_CheckWakeup() 分别通过 Can_CheckWakeup() 或 CanTrcv_CheckWakeup() 查询驱动程序 [SWS_CANIF_00395] [SWS_Can_00360] [SWS_CanTrcv_00143]。仅当唤醒后存储了有效接收时,CanIf_CheckValidation() 才会向 <User_ValidateWakeupEvent> 报告唤醒事件 [SWS_CANIF_00178] [SWS_CANIF_00179] [SWS_CANIF_00286] CanIf 第102页。对于局部网络,PnTxFilter 在 CAN_CS_SLEEP 之后阻止除 PN 过滤 PDU 之外的所有发送。直到出现发送确认或接收才会解除该阻止 [SWS_CANIF_00749] [SWS_CANIF_00750] [SWS_CANIF_00751] [SWS_CANIF_00896]。在切换到省电模式之前,CanSM 通过 CanIf_ClearTrcvWufFlag() 清除 WUF 标志,以确保不会丢失帧唤醒 [SWS_CANIF_00766] [SWS_CanTrcv_00194] [SWS_CanTrcv_00195] CanTrcv 第57页。模块通过 Can_DeInit()、CanIf_DeInit() 和 CanTrcv_DeInit() 终止 [SWS_Can_91002] [SWS_CANIF_91002] [SWS_CanTrcv_91001]。
错误处理、DET 跟踪与降级
该 Cluster 的所有模块均向 DET 报告开发错误。例如,CanIf 会在 TxPduId 无效或存在空指针时执行此操作 [SWS_CANIF_00319] [SWS_CANIF_00320]。此时 CanTp 还会额外返回 E_NOT_OK [SWS_CanTp_00294];Can 和 CanTrcv 使用各自的错误代码 [SWS_Can_91019] [SWS_CanTrcv_00050]。运行时错误涉及被拒绝的数据长度 [SWS_CANIF_00168]、在处于 CANIF_OFFLINE 模式的通道上尝试发送 [SWS_CANIF_00382]、丢失的接收报文 [SWS_Can_91020] 以及与收发器通信缺失 [SWS_CanTrcv_00113] 等。
在所考察的证据中,仅 CanTrcv 提及了一个 DEM 条目:CanTrcv_MainFunctionDiagnostics() 根据 BUSERR 标志将 CANTRCV_E_BUS_ERROR 设置为 FAILED 或 PASSED [SWS_CanTrcv_00218] [SWS_CanTrcv_00206] [SWS_CanTrcv_00227] CanTrcv 第48页。
Can 通过 CanIf_ControllerBusOff() 报告 BusOff [SWS_CANIF_00218]。CanIf 随后将通道设置为 CANIF_TX_OFFLINE 并通知 CanSM [SWS_CANIF_00866] [SWS_CANIF_00724] CanIf 第147页。在进入 CAN_CS_STOPPED 时,CanIf 清空发送缓冲区并对未决发送进行否定确认 [SWS_CANIF_00485] [SWS_CANIF_00739]。对于恢复,CanSM 可使用 CanIf_GetTxConfirmationState() 查询自上次控制器启动以来是否发生过发送确认 [SWS_CANIF_00734] [SWS_CANIF_00740] CanIf 第103页。错误状态和错误计数器可通过 CanIf 查询 [SWS_CANIF_91001] [SWS_Can_91003] [SWS_CANIF_91003]。若启用了安全事件报告,CanIf 会向 IdsM 报告总线错误以及 Error-Passive 和 BusOff 事件 [SWS_CANIF_00913] [SWS_CANIF_00915] [SWS_CANIF_00917] [SWS_CANIF_00918]。
时序图:BusOff 报告从控制器经由 Can 和 CanIf 传递至 CanSM;在此过程中,CanIf 阻止发送路径并重置发送缓冲区。来源:[SWS_CANIF_00218] [SWS_CANIF_00724] [SWS_CANIF_00866] [SWS_CANIF_00918] [SWS_CANIF_00734] CanIf 第147页
CanTp 会在超时时中止会话,并向上一层发送否定通知,例如在 N_As、N_Bs 或 N_Cr 超时的情况下 [SWS_CanTp_00310] [SWS_CanTp_00316] [SWS_CanTp_00313]。在连续出现 WFTmax 个 FC(WAIT) 之后 [SWS_CanTp_00223] 或收到带有 Overflow 的 FC 时 [SWS_CanTp_00309],CanTp 也会采取同样的处理。作为降级模式,CanIf 在模式 CANIF_TX_OFFLINE_ACTIVE 下向上一层确认发送,而无需向总线上发送 [SWS_CANIF_00072]。
基于模块 Can、CanIf、CanTp 和 CanTrcv 的 AUTOSAR 规范(Classic Platform R20-11)由 AI 生成的指南。唯有链接的 Requirements 具有规范性;标明为解释的陈述未经来源证实。
提供分层的 CAN 通信驱动、接口抽象、传输层分段与收发器控制服务。
CAN 通信模块集群(Can、CanIf、CanTp、CanTrcv)为 AUTOSAR 架构提供完整的 CAN/CAN FD 底层接入、接口抽象与分段传输服务SWS CANInterface 第22页。各模块通过硬件邮箱调度、软件过滤排队及 ISO 15765-2 流控机制实现报文的高效收发与网络唤醒管理[SWS_CANIF_00005][SWS_CanTp_00096]。其核心约束在于发送操作严格依赖控制器与通道处于启动激活状态,并在 BusOff 故障或休眠模式下必须同步执行缓冲区清空与通道降级保护[SWS_CANIF_00317][SWS_CANIF_00485]。
AUTOSAR Classic Platform 的 CAN 通信模块集群由 Can、CanIf、CanTp 和 CanTrcv 四个模块紧密协作构成,共同承载整车 CAN/CAN FD 底层数据链路与网络通信服务SWS CANInterface 第22页。其中,Can 驱动直接控制控制器硬件邮箱,CanTrcv 管理物理收发器芯片与唤醒模式,CanIf 向上层屏蔽硬件细节并提供统一的 L-PDU 路由与排队,而 CanTp 则遵循 ISO 15765-2 规范负责长报文的分段、重组及流控管理[SWS_Can_00416][SWS_CanTp_00096][SWS_CanTrcv_00002]。
架构图: CAN 通信模块集群的分层架构及模块间核心交互关系。Quellen: SWS CANInterface 第22页, [SWS_CANIF_00005], [SWS_CanTp_00212], [SWS_CanTrcv_00002]
在数据收发链路上,上层通过 CanIf_Transmit() 或 CanTp_Transmit() 发起发送请求。若硬件对象空闲,CanIf 直接调用 Can_Write() 写入外设;若遇到硬件繁忙,待发报文将存入 CanIfTxBuffers 队列按 CAN ID 优先级排队,并在中断或轮询返回的 CanIf_TxConfirmation() 触发时重新调度发送并向上层确认SWS CANInterface 第42页[SWS_CANIF_00005][SWS_CANIF_00070][SWS_CANIF_00383]。接收方向上,底层通过 CanIf_RxIndication() 上报新报文,经过软硬件过滤与数据长度校验后分发至 PduR 或 CanTp 完成数据重组[SWS_CANIF_00006][SWS_CANIF_00389][SWS_CanTp_00330]。
时序图: CAN 报文发送、硬件排队缓冲与发送确认交互流程。Quellen: SWS CANInterface 第42页, SWS CANInterface 第46页, [SWS_CANIF_00005], [SWS_CANIF_00007], [SWS_CANIF_00070], [SWS_CANIF_00383]
在生命周期与容错体系中,系统启动后各控制器由 CanSM 在 CAN_CS_STOPPED、CAN_CS_STARTED 与 CAN_CS_SLEEP 间统筹切换,而 CanIf 则通过 CANIF_OFFLINE、CANIF_TX_OFFLINE 和 CANIF_ONLINE 精细控制通道收发[SWS_CANIF_00003][SWS_CANIF_00137]。当遭遇严重物理干扰触发 BusOff 时,CanIf_ControllerBusOff() 会联动清空发送队列并协助网络管理器展开总线恢复,配合 DET 参数校验与局部网络(Partial Networking)过滤机制,全面保障车载通信栈的高可靠性与实时性SWS CANInterface 第70页[SWS_CANIF_00218][SWS_CANIF_00485]。
系统架构与模块集群定位
在 AUTOSAR Classic Platform(R20-11)架构中,CAN 通信模块集群(CAN Communication Cluster)构成了车载网络底层通信与控制的核心基础设施,由 CAN 驱动(Can)、CAN 接口(CanIf)、CAN 传输层(CanTp)以及 CAN 收发器驱动(CanTrcv)四个关键基础软件模块(BSW)组成SWS CANInterface 第22页。该集群横跨微控制器抽象层(MCAL)、ECU 抽象层与通信服务层,向上支持 PDU Router(PduR)、CAN 状态管理器(CanSM)、CAN 网络管理(CanNm)以及诊断通信管理器(Dcm),向下直接管理 CAN 控制器硬件与物理收发器芯片,为 Classical CAN、CAN FD 以及更高规格的车载通信提供高确定性、分层解耦的报文收发服务[SWS_Can_00416]。
在分层体系中,各模块具有明确的职责分工与标准映射:Can 作为硬件直接相关的 MCAL 驱动,负责访问控制器寄存器并调度硬件发送对象(HTH)与硬件接收对象(HRH)[SWS_Can_00429];CanTrcv 负责操作物理层收发器的工作模式并监控总线唤醒与故障事件[SWS_CanTrcv_00002];CanIf 充当核心抽象与路由中枢,完全屏蔽底层多个物理控制器与驱动实例的技术差异,向上层提供统一的基于 L-PDU/L-SDU 的访问接口、软件过滤与发送排队机制SWS CANInterface 第68页;CanTp 遵循 ISO 15765-2 规范,负责在底层单帧(SF)负载限制与上层诊断(如 ISO 14229 UDS)等长报文需求之间实现分段(Segmentation)、重组(Reassembly)与流控(Flow Control)传输管理[SWS_CanTp_00096]。
架构图: CAN 通信模块集群的分层架构及模块间核心交互关系。Quellen: SWS CANInterface 第22页, [SWS_CANIF_00005], [SWS_CanTp_00212], [SWS_CanTrcv_00002]
模块间交互与数据流转路径
报文发送流程由上层通信模块或传输层发起。对于常规 I-PDU,上层模块直接调用 CanIf_Transmit();对于诊断等长报文,上层通过 CanTp_Transmit() 触发传输[SWS_CanTp_00212]。若报文长度适配单个 CAN 帧,CanTp 发送单帧(SF N-PDU);若超过单帧容量,则启动多帧传输会话,依次生成首帧(FF N-PDU)并等待流控帧(FC N-PDU)后分批发送连续帧(CF N-PDU)[SWS_CanTp_00231][SWS_CanTp_00232]。当配置了填充时,CanTp 会根据预编译配置补全帧长度,但向上层交付时仅传递有效载荷[SWS_CanTp_00116][SWS_CanTp_00344]。所有由 CanTp 发出的 N-PDU 最终均通过 CanIf_Transmit() 递交给 CAN 接口层SWS CANTransportLayer 第32页。
在 CanIf_Transmit() 内部,模块首先校验控制器运行状态必须为 CAN_CS_STARTED 且 PDU 通道模式处于激活状态[SWS_CANIF_00317]。随后,CanIf 将目标 TxPduId 映射到具体的控制器与 HTH,并同步调用底层驱动的 Can_Write()SWS CANInterface 第42页。若硬件邮箱空闲,Can_Write() 返回 E_OK;若邮箱繁忙返回 CAN_BUSY,CanIf 会将待发 L-PDU 存入内部缓冲队列 CanIfTxBuffers 中[SWS_CANIF_00070]。一旦硬件释放并触发 CanIf_TxConfirmation() 回调,CanIf 会立即评估缓冲队列,按 CAN 标识符优先级取出最高优先级报文再次调用 Can_Write(),并在底层确认后调用上层确认服务 <User_TxConfirmation>(E_OK)[SWS_CANIF_00183][SWS_CANIF_00383][SWS_CANIF_00386]。对于动态 CAN ID 传输,CanIf_SetDynamicTxId() 允许运行时重构标识符,并在高位指定标准、扩展或 FD 帧格式[SWS_CANIF_00188][SWS_CANIF_00189]。
时序图: CAN 报文发送、硬件排队缓冲与发送确认交互流程。Quellen: SWS CANInterface 第42页, SWS CANInterface 第46页, [SWS_CANIF_00005], [SWS_CANIF_00007], [SWS_CANIF_00070], [SWS_CANIF_00383]
在接收数据流方向,当物理总线收到有效报文后,Can 驱动在中断或轮询上下文中调用 CanIf_RxIndication() 并传入对应的 HRH 邮箱信息与数据指针[SWS_CANIF_00006]。CanIf 依次执行硬件对象映射、BasicCAN/FullCAN 软件过滤以及数据长度检查(DLC Check)[SWS_CANIF_00389][SWS_CANIF_00467]。校验通过后,CanIf 依据配置将数据分发给目标模块:普通通信报文直达 PduR,网络管理报文分发至 CanNm,分段诊断报文则递交给 CanTp_RxIndication()[SWS_CANIF_00415][SWS_CanTp_00330]。若使能了接收缓冲 API,上层还可通过 CanIf_ReadRxPduData() 异步读取最新接收的数据[SWS_CANIF_00194][SWS_CANIF_00198]。
同步机制、可重入性与任务上下文
CAN 集群的运行涉及中断服务例程(ISR)与周期性调度任务(Task)的高度协同。驱动层支持中断与轮询双重处理模式:当配置为轮询或混合模式时,调度实体通过 Can_MainFunction_Write() 轮询发送确认,通过 Can_MainFunction_Read() 轮询接收指示,并通过 Can_MainFunction_BusOff() 和 Can_MainFunction_Wakeup() 轮询总线关闭与唤醒事件[SWS_Can_00031][SWS_Can_00108][SWS_Can_00109][SWS_Can_00112]。为保护外设临界区,Can_DisableControllerInterrupts() 与 Can_EnableControllerInterrupts() 提供了支持多重嵌套的递增式中断屏蔽与恢复机制[SWS_Can_00049][SWS_Can_00202]。
在传输层与收发器层,周期性调度实体负责核心定时机制与诊断监控。CanTp_MainFunction() 由调度管理器(SchM)周期性触发,专门监控 ISO 15765-2 规定的全套协议超时计时器(包括发送端 $N\_As$、$N\_Bs$、$N\_Cs$,接收端 $N\_Ar$、$N\_Br$、$N\_Cr$ 以及帧间最小间隔 $ST_{min}$)[SWS_CanTp_00164][SWS_CanTp_00213]。CanTrcv_MainFunctionDiagnostics() 则周期性读取物理收发器硬件状态,并在检测到总线错误时向诊断事件管理器(DEM)上报故障[SWS_CanTrcv_00204][SWS_CanTrcv_00206]。
在重入性规则方面,CanIf_Transmit() 与 CanTp_Transmit() 均支持针对不同 PDU ID 的可重入调用,但针对同一 PDU ID 为不可重入[SWS_CANIF_00005][SWS_CanTp_00212]。CanTp 内部通过独立的连接通道(Connection Channels)支持多路并发传输(例如同时处理物理寻址与功能寻址会话),各通道拥有专用的缓冲区、状态机和定时器资源[SWS_CanTp_00096][SWS_CanTp_00122]。此外,对于非重入的 CanIf_SetDynamicTxId(),协议要求其必须防范同报文并发 CanIf_Transmit() 调用带来的数据一致性风险[SWS_CANIF_00189][SWS_CANIF_00673]。
典型生命周期与运行模式管理
CAN 通信集群严格遵循 AUTOSAR 标准启动与关闭序列。在系统上电复位后,ECU 状态管理器(EcuM)依次调用 Can_Init()、CanTrcv_Init() 与 CanIf_Init(),初始化全局变量、缓冲区与状态标记[SWS_CANIF_00001][SWS_CANIF_00085]。初始化完成后,CAN 控制器默认停留在 CAN_CS_STOPPED 状态,禁止收发任何报文SWS CANInterface 第40页。与此同时,CanTp_Init() 使传输层从 CANTP_OFF 进入 CANTP_ON 运行态,并将所有通道复位为等待空闲状态(CANTP_RX_WAIT 与 CANTP_TX_WAIT)[SWS_CanTp_00027][SWS_CanTp_00030]。
系统运行期间的模式切换由 CanSM 全程协调。CanSM 经由 CanIf_SetControllerMode() 驱动底层 Can_SetControllerMode() 异步执行控制器状态机转换(CAN_CS_STOPPED、CAN_CS_STARTED、CAN_CS_SLEEP)[SWS_CANIF_00003][SWS_Can_00017][SWS_Can_00230]。每次控制器切换至 CAN_CS_STARTED,底层驱动均会重新应用预设波特率与控制器参数配置[SWS_Can_00384]。对于物理收发器,CanSM 通过 CanIf_SetTrcvMode() 驱动 CanTrcv_SetOpMode() 进入 CANTRCV_TRCVMODE_NORMAL、CANTRCV_TRCVMODE_STANDBY 或 CANTRCV_TRCVMODE_SLEEP 模式[SWS_CANIF_00287][SWS_CanTrcv_00102]。
除物理控制器状态外,CanIf 维护着独立的逻辑 PDU 通道状态(PduMode):初始状态及进入 CAN_CS_SLEEP 时通道处于 CANIF_OFFLINE;控制器处于 CAN_CS_STOPPED 或发生 BusOff 时进入 CANIF_TX_OFFLINE,此时阻断所有发送请求并清空队列,但保留接收能力;在全功能通信时通道切换至 CANIF_ONLINE;此外支持仅模拟内部确认的 CANIF_TX_OFFLINE_ACTIVE 模式[SWS_CANIF_00137][SWS_CANIF_00485][SWS_CANIF_00489][SWS_CANIF_00864][SWS_CANIF_00865][SWS_CANIF_00866]。在休眠与唤醒流程中,集群通过 Can_CheckWakeup() 或 CanTrcv_GetBusWuReason() 捕获总线唤醒源,并经由 CanIf_CheckValidation() 完成唤醒验证闭环[SWS_CANIF_00178][SWS_Can_00361][SWS_CanTrcv_00107]。
状态图: CanIf 逻辑 PDU 通道状态转移模型及通信控制。Quellen: AUTOSAR SWS CANInterface 第61页, [SWS_CANIF_00137], [SWS_CANIF_00864], [SWS_CANIF_00865], [SWS_CANIF_00866]
故障处理、DET 追踪与降级策略
当 CAN 控制器因严重通信干扰导致发送错误计数超限($TEC > 255$)触发 BusOff 时,硬件产生中断或由轮询函数捕获,驱动层立即调用 CanIf_ControllerBusOff() 指示接口层[SWS_CANIF_00218]。CanIf 随即执行降级防御:强制复位当前控制器的发送缓冲队列、将通道模式置为 CANIF_TX_OFFLINE 并调用 <User_ControllerBusOff> 转发至 CanSM,由 CanSM 依据总线恢复算法完成分阶段重启与通信复原[SWS_CANIF_00485][SWS_CANIF_00866]。在错误状态演进中,控制器状态细分为 CAN_ERRORSTATE_ACTIVE、CAN_ERRORSTATE_PASSIVE 与 CAN_ERRORSTATE_BUSOFF[SWS_Can_91003];若使能了安全事件追踪,CanIf 还可通过 CanIf_ErrorNotification() 与 CanIf_ControllerErrorStatePassive() 解析错误细节并向入侵防御系统管理器(IdsM)报告安全事件[SWS_CANIF_91008][SWS_CANIF_91009][SWS_Can_91021]。
在局域网络管理(Partial Networking)与低功耗保护场景下,CanIf 提供了 PnTxFilter 发送过滤机制:当控制器进入休眠态时自动激活该过滤器,除特定配置的唤醒报文(CanIfTxPduPnFilterPdu)允许通过外,所有常规发送请求均被直接拦截并返回 E_NOT_OK,直到成功收到接收指示或发送确认后才解除过滤SWS CANInterface 第70页[SWS_CANIF_00747][SWS_CANIF_00749][SWS_CANIF_00750]。同时,针对支持选择性唤醒的物理收发器,CanSM 经由 CanIf_ClearTrcvWufFlag() 与 CanTrcv_ClearTrcvWufFlag() 异步清除唤醒标志,防止虚假唤醒事件残留[SWS_CANIF_00760][SWS_CanTrcv_00194]。
开发错误追踪(DET)与生产故障记录(DEM)在集群内紧密配合:集群各模块均对输入参数(如 ControllerId、TransceiverId、PDU 句柄和空指针)以及未初始化状态实施严格防御,触发时向 DET 上报规范化错误码(如 CANIF_E_PARAM_CONTROLLERID、CANTP_E_UNINIT、CANTRCV_E_UNINIT)[SWS_CANIF_00311][SWS_CanTp_00031][SWS_CanTrcv_00220]。收发器检测到的硬件总线故障则通过 Dem_SetEventStatus() 上报 CANTRCV_E_BUS_ERROR,实现软硬件全方位的故障容错与可维护性闭环[SWS_CanTrcv_00206]。
本指南由 autodocs 基于 AUTOSAR Classic Platform R20-11 规范知识库自动生成,聚焦于 CAN 通信模块集群的核心机制与规范要求。
Module im Cluster
CAN Driver (Can)
The CAN driver provides hardware-dependent access to the internal and external CAN controllers (CAN 2.0B, CAN FD, CAN XL).
CAN Interface (CanIf)
The CanIf abstracts CAN hardware details and provides uniform access to multiple CAN controllers and transceivers for higher-layer modules (PduR, CanTp, CanNm, CanSM).
CAN Network Management (CanNm)
AUTOSAR Classic Communication Services-Modul CAN Network Management (CanNm, Spezifikation: AUTOSAR_CP_SWS_CANNetworkManagement.pdf, AUTOSAR_SWS_CANNetworkManagement.pdf, AUTOSAR_SWS_CAN_Generic_NM.pdf, AUTOSAR_SWS_CAN_NM.pdf).
CAN State Manager (CanSM)
AUTOSAR Classic Communication Services-Modul CAN State Manager (CanSM, Spezifikation: AUTOSAR_CP_SWS_CANStateManager.pdf, AUTOSAR_SWS_CANStateManager.pdf, AUTOSAR_SWS_CAN_StateManager.pdf).
CAN Transport Layer (CanTp)
Provides segmentation and reassembly of CAN messages up to 4095 bytes (ISO 15765-2).
CAN Transceiver Driver (CanTrcv)
Controls physical bus transceiver states and wakeup detection on CAN lines.
CAN XL Driver (CanXL)
AUTOSAR Classic Communication Drivers-Modul CAN XL Driver (CanXL, Spezifikation: AUTOSAR_CP_SWS_CANXLDriver.pdf, AUTOSAR_SWS_CANXLDriver.pdf).
CAN XL Transceiver Driver (CanXLTrcv)
AUTOSAR Classic Communication HW Abstraction-Modul CAN XL Transceiver Driver (CanXLTrcv, Spezifikation: AUTOSAR_CP_SWS_CANXLTransceiverDriver.pdf, AUTOSAR_SWS_CANXLTransceiverDriver.pdf).
TTCAN Driver (Ttcan)
AUTOSAR Classic Communication Drivers-Modul TTCAN Driver (Ttcan, Spezifikation: AUTOSAR_CP_SWS_TTCANDriver.pdf, AUTOSAR_SWS_TTCANDriver.pdf).
TTCAN Interface (TtcanIf)
AUTOSAR Classic Communication HW Abstraction-Modul TTCAN Interface (TtcanIf, Spezifikation: AUTOSAR_CP_SWS_TTCANInterface.pdf, AUTOSAR_SWS_TTCANInterface.pdf).
gemini-3.8-flash-low· 2026-10-13 · 德文原文