5.1. CAN
5.1.1. Types
Base type |
Type Name |
Brief |
---|---|---|
enum |
Can Tx/Rx Processing. |
|
enum |
Values that can be returned by CAN Driver APIs. |
|
enum |
Can Handle Type FULL/BASIC. |
|
enum |
Can Controller Instance ID. |
|
enum |
Can Mailbox direction enum. |
|
enum |
Icom signal operation type. |
|
enum |
Can Driver state. |
|
enum |
Enum for the event pin. |
|
enum |
Enum for the Can standard filter selection. |
5.1.1.1. enum Can_ProcessingType
Enumerator |
Value |
Description |
---|---|---|
CAN_INTERRUPT |
0x0U |
Interrupt. |
CAN_MIXED |
0x1U |
Mixed |
CAN_POLLING |
0x2U |
Polling. |
Brief: Can Tx/Rx Processing.
5.1.1.2. enum Can_ReturnType
Enumerator |
Value |
Description |
---|---|---|
CAN_BUSY |
2U |
Transmit request could not be processed because no transmit object was available. |
Brief: Values that can be returned by CAN Driver APIs.
5.1.1.3. enum Can_HandleType
Enumerator |
Value |
Description |
---|---|---|
CAN_FULL |
0x0U |
Full |
CAN_BASIC |
Basic |
Brief: Can Handle Type FULL/BASIC.
5.1.1.4. enum Can_ControllerInstance
Enumerator |
Value |
Description |
---|---|---|
CAN_CONTROLLER_INSTANCE_MCAN1 |
0x0U |
MCANA Controller Instance. |
CAN_CONTROLLER_INSTANCE_MCAN2 |
0x1U |
MCANB Controller Instance. |
CAN_CONTROLLER_INSTANCE_MCAN3 |
0x2U |
MCANC Controller Instance. |
CAN_CONTROLLER_INSTANCE_MCAN4 |
0x3U |
MCAND Controller Instance. |
CAN_CONTROLLER_INSTANCE_MCAN5 |
0x4U |
MCANE Controller Instance. |
CAN_CONTROLLER_INSTANCE_MCAN6 |
0x5U |
MCANF Controller Instance. |
Brief: Can Controller Instance ID.
5.1.1.5. enum Can_MailboxDirectionType
Enumerator |
Value |
Description |
---|---|---|
CAN_RECEIVE |
0x0U |
Mailbox is for receive. |
CAN_TRANSMIT |
Mailbox is for transmit. |
Brief: Can Mailbox direction enum.
5.1.1.6. enum Can_Icom_signal_operation_type
Enumerator |
Value |
Description |
---|---|---|
AND |
0U |
AND. |
EQUAL |
1U |
EQUAL. |
GREATER |
2U |
GREATER. |
SMALLER |
3U |
SMALLER. |
XOR |
4U |
XOR. |
Brief: Icom signal operation type.
5.1.1.7. enum Can_DrvState
Enumerator |
Value |
Description |
---|---|---|
CAN_UNINIT |
0U |
Can module state when reset/power-up. |
CAN_READY |
1U |
Can module state after initialization. |
Brief: Can Driver state.
5.1.1.8. enum Can_EventPin
Enumerator |
Value |
Description |
---|---|---|
CAN_EVENT_PIN_0 |
0x0U |
EVENT PIN0. |
CAN_EVENT_PIN_1 |
0x1U |
EVENT PIN1. |
CAN_EVENT_PIN_NONE |
0x2U |
EVENT NONE. |
Brief: Enum for the event pin.
5.1.1.9. enum Can_StandardFilterType
Enumerator |
Value |
Description |
---|---|---|
CAN_RANGE_FILTER |
0x0U |
Range filter from SFID1 to SFID2 (SFID2 ≥ SFID1) |
CAN_DUAL_ID_FILTER |
0x1U |
Dual ID filter for SFID1 or SFID2. |
CAN_CLASSIC_FILTER |
0x2U |
Classic filter: SFID1 = filter; SFID2 = mask. |
CAN_FILTER_DISABLED |
0x03 |
Filter element disabled. |
Brief: Enum for the Can standard filter selection.
5.1.2. Structures
Name |
Brief |
---|---|
Can Main Function RW Period Ref Type Identifier. |
|
Structure defining the filter mask to be used. |
|
MCan Controller Specific Configuration. |
|
Structure defining the CAN FD data phase baud rate configuration. |
|
Can Controller Baud Rate Configuration definition. |
|
Can Controller Configuration definition. |
|
Structure defining the HW filter to be used. |
|
Can mailbox configuration definition. |
|
Icom signal config data structure. |
|
Icom Rx message data structure. |
|
Icom data structure containing the overall ICOM configuration data. |
|
External data structure containing the overall initialization data for the CAN driver and SFR settings affecting all controllers. |
|
Can periodic readback register definition. |
5.1.3. Defines
Name |
Brief |
---|---|
CAN_SW_MAJOR_VERSION |
Driver Implementation Major Version. |
CAN_SW_MINOR_VERSION |
Driver Implementation Minor Version. |
CAN_SW_PATCH_VERSION |
Driver Implementation Patch Version. |
CAN_AR_RELEASE_MAJOR_VERSION |
AUTOSAR Major version specification implemented by CAN Driver. |
CAN_AR_RELEASE_MINOR_VERSION |
AUTOSAR Minor version specification implemented by CAN Driver. |
CAN_AR_RELEASE_REVISION_VERSION |
AUTOSAR Patch version specification implemented by CAN Driver. |
CAN_VENDOR_ID |
CAN Driver ID Info. |
CAN_MODULE_ID |
CAN Driver Module ID. |
CAN_INSTANCE_ID |
CAN Instance ID. |
CAN_SID_INIT |
The Service Id is one of the argument to Det_ReportError function and is used to identify the source of the error. |
CAN_SID_MAINFUNC_WRITE |
Service ID - Can_MainFunction_Write(). |
CAN_SID_SETCTR |
Service ID - Can_SetControllerMode(). |
CAN_SID_DIINT |
Service ID - Can_DisableControllerInterrupts(). |
CAN_SID_ENINT |
Service ID - Can_EnableControllerInterrupts(). |
CAN_SID_WRITE |
Service ID - Can_Write(). |
CAN_SID_GET_VERSION_INFO |
Service ID - Can_GetVersionInfo(). |
CAN_SID_MAINFUNC_READ |
Service ID - Can_MainFunction_Read(). |
CAN_SID_MAINFUNC_BO |
Service ID - Can_MainFunction_BusOff(). |
CAN_SID_MAINFUNC_WU |
Service ID - Can_MainFunction_Wakeup(). |
CAN_SID_CKWAKEUP |
Service ID - Can_CheckWakeup(). |
CAN_SID_MAINFUNC_MODE |
Service ID - Can_MainFunction_Mode(). |
CAN_SID_CHNGBAUDRATE |
Service ID - Can_ChangeBaudrate(). |
CAN_SID_CHKBAUDRATE |
Service ID - Can_CheckBaudrate(). |
CAN_SID_SETBAUDRATE |
Service ID - Can_SetBaudRate(). |
CAN_SID_DEINIT |
Service ID - Can_DeInit(). |
CAN_SID_GETCNTRERRSTATE |
Service ID - Can_GetControllerErrorState(). |
CAN_SID_GETCNTRMODE |
Service ID - Can_GetControllerMode(). |
CAN_SID_PROCESSISR |
Service ID - Can_ProcessISR(). |
CAN_SID_ICOMCONFIG |
Service ID - Can_SetIcomConfiguration(). |
CAN_SID_READBACK |
Service ID - Can_PeriodicReadback(). |
CAN_E_PARAM_POINTER |
Error codes returned by Can functions - Development Errors. |
CAN_E_PARAM_HANDLE |
Invalid Controller Handle. |
CAN_E_PARAM_DATA_LENGTH |
Invalid length of msg. |
CAN_E_PARAM_CONTROLLER |
Invalid controller id. |
CAN_E_UNINIT |
Error due to API invoked without performing Can_Init(). |
CAN_E_TRANSITION |
Error during Controller state transition. |
CAN_E_PARAM_BAUDRATE |
Invalid Baudrate configuration. |
CAN_E_ICOM_CONFIG_INVALID |
Invalid ICOM configuration Id. |
CAN_E_DATALOST |
Error codes returned by Can functions - Run Time Errors. |
CAN_ICOM_CONFIG_DISABLE |
Icom config disable. |
CAN_EXTENDED_ID |
Extended id. |
CAN_STANDARD_ID |
Standard id. |
CAN_MIXED_ID |
Mixed id. |
5.1.4. Functions
Return type |
Function Name |
Brief |
---|---|---|
void |
Can_GetVersionInfo(Std_VersionInfoType * versioninfo) |
Function returns the version information of this module. |
void |
Can_Init(const Can_ConfigType * Config_Ptr) |
This function initializes the configuration. |
void |
Can_DeInit(void ) |
This function deinitializes the module. |
Std_ReturnType |
Can_SetBaudrate(uint8 Controller, const uint16 BaudRateConfigID) |
This service shall set the baud rate configuration of the CAN Controller. |
Std_ReturnType |
Can_SetControllerMode(uint8 Controller, Can_ControllerStateType Transition) |
This service performs software triggered state transitions of the CAN controller State machine. |
void |
Can_DisableControllerInterrupts(uint8 Controller) |
This service disables all interrupts. |
void |
Can_EnableControllerInterrupts(uint8 Controller) |
This service enables all allowed interrupts. |
Std_ReturnType |
Can_CheckWakeup(uint8 Controller) |
This service checks if a wakeup has occurred for the given controller. |
Std_ReturnType |
Can_GetControllerErrorState(uint8 Controller, Can_ErrorStateType * ErrorStatePtr) |
This service obtains the error state of the CAN controller. |
Std_ReturnType |
Can_GetControllerMode(uint8 Controller, Can_ControllerStateType * ControllerModePtr) |
This service reports about the current status of the requested CAN controller. |
Std_ReturnType |
Can_Write(Can_HwHandleType Hth, const Can_PduType * PduInfo) |
This service is called by CanIf to pass a CAN message to CanDrv for transmission. |
void |
Can_MainFunction_Write(uint16 RWFuncID) |
This service performs the polling of TX confirmation when CAN_TX_PROCESSING is set to POLLING. |
void |
Can_MainFunction_Read(uint16 RWFuncID) |
This service performs the polling of RX indications when CAN_RX_PROCESSING is set to POLLING. |
void |
Can_MainFunction_BusOff(void ) |
This service performs the polling of bus-off events that are configured statically as ‘to be polled’. |
void |
Can_MainFunction_Wakeup(void ) |
This function performs the polling of wake-up events that are configured statically as ‘to be polled’. |
void |
Can_MainFunction_Mode(void ) |
This function performs the polling of CAN controller mode transitions. |
Std_ReturnType |
Can_SetIcomConfiguration(uint8 Controller, IcomConfigIdType ConfigurationId) |
This service shall change the Icom Configuration of a CAN controller to the requested one. |
void |
Can_PeriodicReadback(uint8 Controller, Can_PeriodicReadBackDataType * ReadBackRegisterdata) |
This service shall read all the statically configured registers. |
5.1.4.1. function Can_GetVersionInfo
void Can_GetVersionInfo(
Std_VersionInfoType * versioninfo
)
Brief: Function returns the version information of this module.
This service writes the version information of this module into the data structure referenced by the parameter. If this parameter references NULL_PTR, a development error is reported.
Parameters:
versioninfo Pointer to where to store the version information of this module.
Returns:
None
Return: None
Precondition: None
Postcondition: None
5.1.4.2. function Can_Init
void Can_Init(
const Can_ConfigType * Config_Ptr
)
Brief: This function initializes the configuration.
This function initializes the message RAM, which also clears all the message objects, and places the CAN controller in an init state. Write access to the configuration registers is available as a result, allowing the bit timing and message objects to be setup.
Parameters:
Config_Ptr Pointer to post-build configuration data.
Returns:
None
Return: None
Precondition: None
Postcondition: None
5.1.4.3. function Can_DeInit
void Can_DeInit(
void
)
Brief: This function deinitializes the module.
Returns:
None
Return: None
Precondition: None
Postcondition: None
5.1.4.4. function Can_SetBaudrate
Std_ReturnType Can_SetBaudrate(
uint8 Controller,
const uint16 BaudRateConfigID
)
Brief: This service shall set the baud rate configuration of the CAN Controller.
This function sets the baud rate configuration of the CAN controller. Depending on necessary baud rate modifications the controller might have to reset.
Parameters:
Controller CAN controller, whose baud rate shall be set.
BaudRateConfigID references a baud rate configuration by ID.
Returns:
E_OK - Service request accepted, setting of (new) baud rate started.
E_NOT_OK - Service request not accepted.
Return: Setting the Baudrate successful or failure.
Precondition: None
Postcondition: None
5.1.4.5. function Can_SetControllerMode
Std_ReturnType Can_SetControllerMode(
uint8 Controller,
Can_ControllerStateType Transition
)
Brief: This service performs software triggered state transitions of the CAN controller State machine.
The function perfroms the transition of the CAN controller state machine which is software triggered.
Parameters:
Controller CAN controller for which the status shall be changed.
Transition Transition value to request new CAN controller state.
Returns:
E_OK Request accepted.
E_NOT_OK Request not accepted i.e. an error occured while requesting an incorrect from one state to other or an incorrect transition.
Return: Setting the controller mode successful/failure.
Precondition: None
Postcondition: None
5.1.4.6. function Can_DisableControllerInterrupts
void Can_DisableControllerInterrupts(
uint8 Controller
)
Brief: This service disables all interrupts.
This function checks if there is a DET Error and then disables all the interrupts for the controller.
Parameters:
Controller CAN controller for which interrupts shall be re-enabled.
Returns:
None
Return: None
Precondition: None
Postcondition: None
5.1.4.7. function Can_EnableControllerInterrupts
void Can_EnableControllerInterrupts(
uint8 Controller
)
Brief: This service enables all allowed interrupts.
This function checks the total number of interrupts and enables all the interrupts allowed for the controller.
Parameters:
Controller CAN controller for which interrupts shall be re-enabled.
Returns:
None
Return: None
Precondition: None
Postcondition: None
5.1.4.8. function Can_CheckWakeup
Std_ReturnType Can_CheckWakeup(
uint8 Controller
)
Brief: This service checks if a wakeup has occurred for the given controller.
This function checks if the Init is done and checks if wakeup has occured and returns value accordingly for the given controller.
Parameters:
Controller to be checked for a wakeup.
Returns:
E_OK API call has been accepted.
E_NOT_OK API call has not been accepted.
Return: Wakeup occurred or not for a controller
Precondition: None
Postcondition: None
5.1.4.9. function Can_GetControllerErrorState
Std_ReturnType Can_GetControllerErrorState(
uint8 Controller,
Can_ErrorStateType * ErrorStatePtr
)
Brief: This service obtains the error state of the CAN controller.
This function gets the error state of the CAN controller.
Parameters:
Controller CAN controller, which is requested for ErrorState.
ErrorStatePtr Pointer to a memory location, where the error state of the CAN controller will be stored.
Returns:
E_OK - Error state request has been accepted.
E_NOT_OK - Error state request has not been accepted..
Return: Error state obtained successfully/failed to obtain error state.
Precondition: None
Postcondition: None
5.1.4.10. function Can_GetControllerMode
Std_ReturnType Can_GetControllerMode(
uint8 Controller,
Can_ControllerStateType * ControllerModePtr
)
Brief: This service reports about the current status of the requested CAN controller.
This function gets the current status of the CAN controller.
Parameters:
Controller CAN controller, which is requested for ErrorState.
ControllerModePtr Pointer to a memory location, where the current mode of the CAN controller will be stored.
Returns:
E_OK - Controller mode request has been accepted.
E_NOT_OK - Controller mode request has not been accepted.
Return: Able/unable to fetch current status of the controller.
Precondition: None
Postcondition: None
5.1.4.11. function Can_Write
Std_ReturnType Can_Write(
Can_HwHandleType Hth,
const Can_PduType * PduInfo
)
Brief: This service is called by CanIf to pass a CAN message to CanDrv for transmission.
The function Can_Write first checks if the hardware transmit object is identified and is free. It passes the CAN message to CanDrv for transmission.
Parameters:
Hth information which HW-transmit handle shall be used for transmit. Implicitly this is also the information about the controller to use because the Hth numbers are unique inside one hardware unit.
PduInfo Pointer to SDU user memory, DLC and Identifier.
Returns:
E_OK Write command has been accepted.
E_NOT_OK Development error occurred.
CAN_BUSY No TX hardware buffer available or pre-emptive call of Can_Write that can’t be implemented re-entrant
Return: Can write command is accepted (or) resulted in an error (or) Controller is busy
Precondition: None
Postcondition: None
5.1.4.12. function Can_MainFunction_Write
void Can_MainFunction_Write(
uint16 RWFuncID
)
Brief: This service performs the polling of TX confirmation when CAN_TX_PROCESSING is set to POLLING.
This function checks if Can Initialisation is done to check for error if DET error detect is enabled. For a TX Mailbox if the controller is active polling of TX confirmation is done.
Parameters:
RWFuncID Read/Write period ID
Returns:
None
Return: None
Precondition: None
Postcondition: None
5.1.4.13. function Can_MainFunction_Read
void Can_MainFunction_Read(
uint16 RWFuncID
)
Brief: This service performs the polling of RX indications when CAN_RX_PROCESSING is set to POLLING.
This function checks if Can Initialisation is done to check for error if DET error detect is enabled. For a Rx Mailbox if the controller is active polling of Rx indications is done.
Parameters:
RWFuncID Read/Write period ID
Returns:
None
Return: None
Precondition: None
Postcondition: None
5.1.4.14. function Can_MainFunction_BusOff
void Can_MainFunction_BusOff(
void
)
Brief: This service performs the polling of bus-off events that are configured statically as ‘to be polled’.
This function checks if Can Initialisation is done to check for error if DET error detect is enabled. If the controller is active the polling of bus-off events that are configured statically as ‘to be polled’.
Returns:
None
Return: None
Precondition: None
Postcondition: None
5.1.4.15. function Can_MainFunction_Wakeup
void Can_MainFunction_Wakeup(
void
)
Brief: This function performs the polling of wake-up events that are configured statically as ‘to be polled’.
This function checks if Can Initialisation is done to check for error if DET error detect is enabled. The polling of wake-up events is done.
Returns:
None
Return: None
Precondition: None
Postcondition: None
5.1.4.16. function Can_MainFunction_Mode
void Can_MainFunction_Mode(
void
)
Brief: This function performs the polling of CAN controller mode transitions.
This function checks if Can Initialisation is done to check for error if DET error detect is enabled. The polling of CAN controller mode transitions is done.
Returns:
None
Return: None
Precondition: None
Postcondition: None
5.1.4.17. function Can_SetIcomConfiguration
Std_ReturnType Can_SetIcomConfiguration(
uint8 Controller,
IcomConfigIdType ConfigurationId
)
Brief: This service shall change the Icom Configuration of a CAN controller to the requested one.
Parameters:
Controller CAN controller for which the status shall be changed
ConfigurationId Requested Configuration
Returns:
E_OK CAN driver succeeded in setting a configuration with a valid Configuration id.
E_NOT_OK CAN driver failed to set a configuration with a valid Configuration id.
Return: Std_ReturnType
Precondition: None
Postcondition: None
5.1.4.18. function Can_PeriodicReadback
void Can_PeriodicReadback(
uint8 Controller,
Can_PeriodicReadBackDataType * ReadBackRegisterdata
)
Brief: This service shall read all the statically configured registers.
Parameters:
Controller CAN controller for which the configured registers shall be read
ReadBackRegisterdata pointer for the read back registers
Returns:
None
Return: None
Precondition: None
Postcondition: None