STM32G0 MCAL 0.0.1
Tiny MCAL for educational purpose.
|
Header file for the CAN interface. More...
Macros | |
#define | Det_ReportError(ModuleId, InstanceId, ApiId, ErrorId) |
#define | Det_ReportRuntimeError(ModuleId, InstanceId, ApiId, ErrorId) |
Functions | |
void | CanIf_Init (const CanIf_ConfigType *ConfigPtr) |
Initializes the CAN interface. | |
void | CanIf_DeInit (void) |
Deinitializes the CAN interface. | |
Std_ReturnType | CanIf_SetControllerMode (uint8 ControllerId, Can_ControllerStateType ControllerMode) |
Sets the CAN controller mode. | |
Std_ReturnType | CanIf_GetControllerMode (uint8 ControllerId, Can_ControllerStateType *ControllerModePtr) |
Gets the CAN controller mode. | |
Std_ReturnType | CanIf_GetControllerErrorState (uint8 ControllerId, Can_ErrorStateType *ErrorStatePtr) |
Gets the CAN controller error state. | |
Std_ReturnType | CanIf_Transmit (PduIdType TxPduId, const PduInfoType *PduInfoPtr) |
Transmits a CAN L-PDU. | |
Std_ReturnType | CanIf_SetPduMode (uint8 ControllerId, CanIf_PduModeType PduModeRequest) |
Sets the requested PDU mode. | |
Std_ReturnType | CanIf_GetPduMode (uint8 ControllerId, CanIf_PduModeType *PduModePtr) |
Gets the requested PDU mode. | |
void | CanIf_SetDynamicTxId (PduIdType CanIfTxSduId, Can_IdType CanId) |
Sets the CAN controller baudrate. | |
CanIf_NotifStatusType | CanIf_GetTxConfirmationState (uint8 ControllerId) |
Gets the CAN controller Tx confirmation state. | |
Std_ReturnType | CanIf_GetControllerRxErrorCounter (uint8 ControllerId, uint8 *RxErrorCounterPtr) |
Gets the CAN controller Rx error counter. | |
Std_ReturnType | CanIf_GetControllerTxErrorCounter (uint8 ControllerId, uint8 *TxErrorCounterPtr) |
Gets the CAN controller Tx error counter. | |
void | CanIf_TxConfirmation (PduIdType CanTxPduId) |
Handles the transmit confirmation. | |
void | CanIf_RxIndication (const Can_HwType *Mailbox, const PduInfoType *PduInfoPtr) |
Handles the received CAN frame. | |
void | CanIf_ControllerBusOff (uint8 ControllerId) |
Handles the bus-off event. | |
void | CanIf_ControllerModeIndication (uint8 ControllerId, Can_ControllerStateType ControllerMode) |
Controller mode indication. | |
void | CanIf_ControllerErrorStatePassive (uint8 ControllerId, uint16 RxErrorCounter, uint16 TxErrorCounter) |
Signal the error state of the CAN controller. | |
void | CanIf_ErrorNotification (uint8 ControllerId, Can_ErrorType CanError) |
Signal the error notification of the CAN controller. | |
Variables | |
static const CanIf_ConfigType * | LocalConfigPtr = ( (void *)0 ) |
Pointer to the configuration structure. | |
Header file for the CAN interface.
The CAN Interface module provides CAN communication abstracted access to the CAN Driver and CAN Transceiver Driver services for control and supervision of the CAN network. The CAN Interface forwards downwards the status change requests from the CAN State Manager to the lower layer CAN device drivers, and upwards the CAN Driver / CAN Transceiver Driver events are forwarded by the CAN Interface module to e.g. the corresponding NM module.
#define Det_ReportError | ( | ModuleId, | |
InstanceId, | |||
ApiId, | |||
ErrorId ) |
ModuleId | module id number |
InstanceId | Instance Id |
ApiId | Pai id |
ErrorId | Error code |
#define Det_ReportRuntimeError | ( | ModuleId, | |
InstanceId, | |||
ApiId, | |||
ErrorId ) |
ModuleId | module id number |
InstanceId | Instance Id |
ApiId | Pai id |
ErrorId | Error code |
void CanIf_ControllerBusOff | ( | uint8 | ControllerId | ) |
Handles the bus-off event.
This service indicates a Controller BusOff event referring to the corresponding CAN Controller with the abstract CanIf ControllerId.
[in] | ControllerId | CAN controller for which the status shall be changed. |
void CanIf_ControllerErrorStatePassive | ( | uint8 | ControllerId, |
uint16 | RxErrorCounter, | ||
uint16 | TxErrorCounter ) |
Signal the error state of the CAN controller.
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.
[in] | ControllerId | Abstracted CanIf ControllerId which is assigned to a CAN controller. |
[in] | RxErrorCounter | Value of the Rx error counter |
[in] | TxErrorCounter | Value of the Tx error counter |
void CanIf_ControllerModeIndication | ( | uint8 | ControllerId, |
Can_ControllerStateType | ControllerMode ) |
Controller mode indication.
This service indicates a controller state transition referring to the corresponding CAN controller with the abstract CanIf ControllerId.
[in] | ControllerId | CAN controller for which the status shall be changed. |
[in] | ControllerMode | New controller mode. |
void CanIf_DeInit | ( | void | ) |
Deinitializes the CAN interface.
De-initializes the CanIf module. Caller of the CanIf_DeInit() function has to be sure there are no on-going transmissions/receptions, nor any pending transmission confirmations.
void CanIf_ErrorNotification | ( | uint8 | ControllerId, |
Can_ErrorType | CanError ) |
Signal the error notification of the CAN controller.
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.
[in] | ControllerId | CAN controller for which the status shall be changed. |
[in] | CanError | Reported CAN error |
Std_ReturnType CanIf_GetControllerErrorState | ( | uint8 | ControllerId, |
Can_ErrorStateType * | ErrorStatePtr ) |
Gets the CAN controller error state.
This service calls the corresponding CAN Driver service for getting the current CAN controller error state.
[in] | ControllerId | CAN controller for which the status shall be changed. |
[out] | ErrorStatePtr | Pointer to a memory location, where the current error state of the CAN controller will be stored. |
< Error return value
< OK return value
Std_ReturnType CanIf_GetControllerMode | ( | uint8 | ControllerId, |
Can_ControllerStateType * | ControllerModePtr ) |
Gets the CAN controller mode.
This service calls the corresponding CAN Driver service for getting the current CAN controller mode.
[in] | ControllerId | CAN controller for which the status shall be changed. |
[out] | ControllerModePtr | Pointer to a memory location, where the current mode of the CAN controller will be stored. |
< Error return value
< OK return value
Std_ReturnType CanIf_GetControllerRxErrorCounter | ( | uint8 | ControllerId, |
uint8 * | RxErrorCounterPtr ) |
Gets the CAN controller Rx error counter.
This service calls the corresponding CAN Driver service for obtaining the Rx error counter of the CAN controller.
[in] | ControllerId | CAN controller for which the status shall be changed. |
[out] | RxErrorCounterPtr | Pointer to a memory location, where the current Rx error counter |
< Error return value
< OK return value
Std_ReturnType CanIf_GetControllerTxErrorCounter | ( | uint8 | ControllerId, |
uint8 * | TxErrorCounterPtr ) |
Gets the CAN controller Tx error counter.
This service calls the corresponding CAN Driver service for obtaining the Tx error counter of the CAN controller.
[in] | ControllerId | CAN controller for which the status shall be changed. |
[out] | TxErrorCounterPtr | Pointer to a memory location, where the current Tx error counter |
< Error return value
< OK return value
Std_ReturnType CanIf_GetPduMode | ( | uint8 | ControllerId, |
CanIf_PduModeType * | PduModePtr ) |
Gets the requested PDU mode.
This service returns the requested mode of the L-PDUs of a predefined logical PDU channel.
[in] | ControllerId | All PDUs of the own ECU connected to the corresponding CanIf ControllerId, which is assigned to a physical CAN controller are addressed. |
[out] | PduModePtr | Pointer to a memory location, where the requested PDU mode is stored. |
< Error return value
< OK return value
CanIf_NotifStatusType CanIf_GetTxConfirmationState | ( | uint8 | ControllerId | ) |
Gets the CAN controller Tx confirmation state.
This service reports, if any TX confirmation has been done for the whole CAN controller since the last CAN controller start.
[in] | ControllerId | CAN controller for which the status shall be changed. |
void CanIf_Init | ( | const CanIf_ConfigType * | ConfigPtr | ) |
Initializes the CAN interface.
This service Initializes internal and external interfaces of the CAN Interface for the further processing.
[in] | ConfigPtr | Pointer to the CAN Interface configuration structure. |
void CanIf_RxIndication | ( | const Can_HwType * | Mailbox, |
const PduInfoType * | PduInfoPtr ) |
Handles the received CAN frame.
This service indicates a successful reception of a received CAN Rx L-PDU to the CanIf after passing all filters and validation checks.
[in] | Mailbox | Identifies the HRH and its corresponding CAN Controller |
[in] | PduInfoPtr | Pointer to the received L-PDU |
Std_ReturnType CanIf_SetControllerMode | ( | uint8 | ControllerId, |
Can_ControllerStateType | ControllerMode ) |
Sets the CAN controller mode.
This service calls the corresponding CAN Driver service for changing of the CAN controller mode.
[in] | ControllerId | CAN controller for which the status shall be changed. |
[in] | ControllerMode | Requested mode transition. |
< Error return value
< OK return value
void CanIf_SetDynamicTxId | ( | PduIdType | CanIfTxSduId, |
Can_IdType | CanId ) |
Sets the CAN controller baudrate.
This service reconfigures the corresponding CAN identifier of the requested CAN L-PDU.
[in] | CanIfTxSduId | L-SDU handle to be transmitted. This handle specifies the corresponding CAN L-SDU ID and implicitly the CAN Driver instance as well as the corresponding CAN controller device. |
[in] | CanId | Standard/Extended CAN ID of CAN L-SDU that shall be transmitted as FD or conventional CAN frame. |
Std_ReturnType CanIf_SetPduMode | ( | uint8 | ControllerId, |
CanIf_PduModeType | PduModeRequest ) |
Sets the requested PDU mode.
This service sets the requested mode at the L-PDUs of a predefined logical PDU channel.
[in] | ControllerId | All PDUs of the own ECU connected to the corresponding CanIf ControllerId, which is assigned to a physical CAN controller are addressed. |
[in] | PduModeRequest | Requested PDU mode change. |
< Error return value
< OK return value
Std_ReturnType CanIf_Transmit | ( | PduIdType | TxPduId, |
const PduInfoType * | PduInfoPtr ) |
Transmits a CAN L-PDU.
This service calls the corresponding CAN Driver service for transmission of a CAN L-PDU.
[in] | TxPduId | Identifier of the PDU to be transmitted |
[in] | PduInfoPtr | Length of and pointer to the PDU data and pointer to MetaData. |
< Error return value
< OK return value
void CanIf_TxConfirmation | ( | PduIdType | CanTxPduId | ) |
Handles the transmit confirmation.
This service confirms a previously successfully processed transmission of a CAN TxPDU.
[in] | CanTxPduId | ID of the successfully transmitted Tx L-PDU |
|
static |
Pointer to the configuration structure.
< Add static when no testing