STM32G0 MCAL 0.0.1
Tiny MCAL for educational purpose.
|
Can Driver More...
Macros | |
#define | Det_ReportError(ModuleId, InstanceId, ApiId, ErrorId) |
Functions | |
void | Can_Init (const Can_ConfigType *Config) |
Can Initialization | |
void | Can_DeInit (void) |
Can Deinitialization | |
Std_ReturnType | Can_SetBaudrate (uint8 Controller, uint16 BaudRateConfigID) |
Can Set Baudrate | |
Std_ReturnType | Can_SetControllerMode (uint8 Controller, Can_ControllerStateType Transition) |
Can Set Controller Mode | |
void | Can_EnableControllerInterrupts (uint8 Controller) |
Can Enable Controller Interrupts | |
void | Can_DisableControllerInterrupts (uint8 Controller) |
Can Disable Controller Interrupts | |
Std_ReturnType | Can_CheckWakeup (uint8 Controller) |
Can wakeup check | |
Std_ReturnType | Can_GetControllerErrorState (uint8 ControllerId, Can_ErrorStateType *ErrorStatePtr) |
Can Get Controller Error State | |
Std_ReturnType | Can_GetControllerMode (uint8 Controller, Can_ControllerStateType *ControllerModePtr) |
Can Get Controller Mode | |
Std_ReturnType | Can_GetControllerRxErrorCounter (uint8 ControllerId, uint8 *RxErrorCounterPtr) |
Can Get Controller Rx Error Counter | |
Std_ReturnType | Can_GetControllerTxErrorCounter (uint8 ControllerId, uint8 *TxErrorCounterPtr) |
Can Get Controller Tx Error Counter | |
Std_ReturnType | Can_GetCurrentTime (uint8 ControllerId, Can_TimeStampType *timeStampPtr) |
Can Get Current Time | |
void | Can_EnableEgressTimeStamp (Can_HwHandleType Hth) |
Can Enable Egress TimeStamp | |
Std_ReturnType | Can_GetEgressTimeStamp (PduIdType TxPduId, Can_HwHandleType Hth, Can_TimeStampType *timeStampPtr) |
Can Get Egress TimeStamp | |
Std_ReturnType | Can_GetIngressTimeStamp (Can_HwHandleType Hrh, Can_TimeStampType *timeStampPtr) |
Can Get Ingress TimeStamp | |
Std_ReturnType | Can_Write (Can_HwHandleType Hth, const Can_PduType *PduInfo) |
Can Write | |
void | Can_GetVersionInfo (Std_VersionInfoType *versioninfo) |
Can Get Version | |
Variables | |
static Can_ControllerStateType | CtrlState [CAN_NUMBER_OF_CONTROLLERS] |
static Can_HwUnit | HwUnit |
Variable for the initial value of the port configuration array. | |
Can Driver
The Can module provides services for initiating transmissions and calls the callback functions of the CanIf module for notifying events, independently from the hardware. Furthermore, it provides services to control the behavior and state of the CAN controllers that are belonging to the same CAN Hardware Unit. Several CAN controllers can be controlled by a single Can module as long as they belong to the same CAN Hardware Unit.
#define Det_ReportError | ( | ModuleId, | |
InstanceId, | |||
ApiId, | |||
ErrorId ) |
ModuleId | module id number |
InstanceId | Instance Id |
ApiId | Pai id |
ErrorId | Error code |
Std_ReturnType Can_CheckWakeup | ( | uint8 | Controller | ) |
Can wakeup check
This function checks if a wakeup has occurred for the given controller.
Controller | CAN controller for which the wakeup shall be checked. |
E_OK | wakeup detected E_NOT_OK: no wakeup detected |
void Can_DeInit | ( | void | ) |
Can Deinitialization
This function de-initializes the module.
void Can_DisableControllerInterrupts | ( | uint8 | Controller | ) |
Can Disable Controller Interrupts
This function disables all interrupts for this CAN controller.
Controller | CAN controller for which interrupts shall be disabled. |
void Can_EnableControllerInterrupts | ( | uint8 | Controller | ) |
Can Enable Controller Interrupts
This function enables all interrupts for this CAN controller.
Controller | CAN controller for which interrupts shall be enabled. |
void Can_EnableEgressTimeStamp | ( | Can_HwHandleType | Hth | ) |
Can Enable Egress TimeStamp
Activates egress time stamping on a dedicated HTH. Some HW does store once the egress time stamp marker and some HW needs it always before transmission. There will be no "disable" functionality, due to the fact, that the message type is always "time stamped" by network design.
Hth | information which HW-transmit handle shall be used for enabling the time stamp. |
< Transmit object
Std_ReturnType Can_GetControllerErrorState | ( | uint8 | ControllerId, |
Can_ErrorStateType * | ErrorStatePtr ) |
Can Get Controller Error State
This function returns the error state of the CAN controller.
ControllerId | CanIf ControllerId which is assigned to a CAN controller, which is requested for ErrorState. |
ErrorStatePtr | Pointer to a memory location, where the error state of the CAN controller will be stored. |
E_OK | request accepted E_NOT_OK: request not accepted |
Std_ReturnType Can_GetControllerMode | ( | uint8 | Controller, |
Can_ControllerStateType * | ControllerModePtr ) |
Can Get Controller Mode
This service reports about the current status of the requested CAN controller.
Controller | CAN controller for which the status shall be read. |
ControllerModePtr | Pointer to a memory location, where the current mode of the CAN |
E_OK | request accepted E_NOT_OK: request not accepted |
Std_ReturnType Can_GetControllerRxErrorCounter | ( | uint8 | ControllerId, |
uint8 * | RxErrorCounterPtr ) |
Can Get Controller Rx Error Counter
Returns the Rx 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 Rx counter is handled asynchronously in hardware. Applications should not trust this value for any assumption about the current bus state.
ControllerId | CAN controller, whose current Rx error counter shall be acquired. |
RxErrorCounterPtr | Pointer to a memory location, where the current Rx error counter of the CAN controller will be stored. |
E_OK | Rx error counter available. E_NOT_OK: Wrong ControllerId, or Rx error counter not available. |
Std_ReturnType Can_GetControllerTxErrorCounter | ( | uint8 | ControllerId, |
uint8 * | TxErrorCounterPtr ) |
Can Get Controller Tx Error Counter
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.
ControllerId | CAN controller, whose current Tx error counter shall be acquired. |
TxErrorCounterPtr | Pointer to a memory location, where the current Tx error counter |
E_OK | Tx error counter available. E_NOT_OK: Wrong ControllerId, or Tx error counter not |
Std_ReturnType Can_GetCurrentTime | ( | uint8 | ControllerId, |
Can_TimeStampType * | timeStampPtr ) |
Can Get Current Time
Returns a time value out of the HW registers according to the capability of the HW
ControllerId | CAN controller, whose current time shall be acquired. |
timeStampPtr | Pointer to a memory location, where the current time of the CAN |
E_OK | successful E_NOT_OK: failed |
Std_ReturnType Can_GetEgressTimeStamp | ( | PduIdType | TxPduId, |
Can_HwHandleType | Hth, | ||
Can_TimeStampType * | timeStampPtr ) |
Can Get Egress TimeStamp
Reads back the egress time stamp on a dedicated message object. It needs to be called within the TxConfirmation() function.
TxPduId | Tx-PDU handle of CAN L-PDU that has been transmitted. |
Hth | information which HW-transmit handle shall be used for reading the time stamp. |
timeStampPtr | Pointer to a memory location where the time stamp value shall be stored. |
E_OK | success E_NOT_OK: failed to read time stamp. |
< Transmit object
Std_ReturnType Can_GetIngressTimeStamp | ( | Can_HwHandleType | Hrh, |
Can_TimeStampType * | timeStampPtr ) |
Can Get Ingress TimeStamp
Reads back the ingress time stamp on a dedicated message object. It needs to be called within the RxIndication() function.
Hrh | information which HW-receive handle shall be used for reading the time stamp. |
timeStampPtr | Pointer to a memory location where the time stamp value shall be stored. |
E_OK | success E_NOT_OK: failed to read time stamp |
< Receive object
void Can_GetVersionInfo | ( | Std_VersionInfoType * | versioninfo | ) |
Can Get Version
This function returns the version information of this module.
versioninfo | Pointer to where to store the version information of this module. |
void Can_Init | ( | const Can_ConfigType * | Config | ) |
Can Initialization
This function initializes the module and the CAN controller. The CAN controller is initialized according to the parameter Config.
Config | Pointer to driver configuration |
Std_ReturnType Can_SetBaudrate | ( | uint8 | Controller, |
uint16 | BaudRateConfigID ) |
Can Set Baudrate
This service shall set the baud rate configuration of the CAN controller. Depending on necessary baud rate modifications the controller might have to reset.
Controller | CAN controller for which the baud rate shall be set. |
BaudRateConfigID | references a baud rate configuration by ID |
E_OK | Service request accepted, setting of (new) baud rate started E_NOT_OK: Service request not accepted |
Std_ReturnType Can_SetControllerMode | ( | uint8 | Controller, |
Can_ControllerStateType | Transition ) |
Can Set Controller Mode
This function performs software triggered state transitions of the CAN controller State machine.
Controller | CAN controller for which the status shall be changed. |
Transition | Transition value to request new state. |
E_OK | request accepted E_NOT_OK: request not accepted |
Std_ReturnType Can_Write | ( | Can_HwHandleType | Hth, |
const Can_PduType * | PduInfo ) |
Can Write
This function is called by CanIf to pass a CAN message to CanDrv for transmission.
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, Data Length and Identifier |
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 (see Can_ReturnType) |
< Transmit object
< Classic mode
< Classic mode
|
static |
< Add static when no testing
|
static |
Variable for the initial value of the port configuration array.
< Add static when no testing