STM32G0 MCAL 0.0.1
Tiny MCAL for educational purpose.
Loading...
Searching...
No Matches
Can_Arch.c File Reference

Can Specific Arquitecture Driver More...

#include "Std_Types.h"
#include "Registers.h"
#include "Can_Cfg.h"
#include "Can_Arch.h"
#include "Bfx.h"
#include "CanIf_Can.h"

Data Structures

struct  _HwObjectHandler
 Tx Hardware objecj descriptor. More...
 
struct  _HwExtFilter
 Extended Filter descriptor. More...
 

Macros

#define Det_ReportRuntimeError(ModuleId, InstanceId, ApiId, ErrorId)
 
#define CCCR_INIT_BIT   0u
 
#define CCCR_CCE_BIT   1u
 
#define CCCR_ASM_BIT   2u
 
#define CCCR_CSA_BIT   3u
 
#define CCCR_CSR_BIT   4u
 
#define CCCR_MON_BIT   5u
 
#define CCCR_DAR_BIT   6u
 
#define CCCR_TEST_BIT   7u
 
#define CCCR_FDOE_BIT   8u
 
#define CCCR_BRSE_BIT   9u
 
#define CCCR_PXHD_BIT   12u
 
#define CCCR_TXP_BIT   14u
 
#define TEST_LBCK_BIT   4u
 
#define NBTP_NTSEG2_BIT   0u
 
#define NBTP_NTSEG1_BIT   8u
 
#define NBTP_NBRP_BIT   16u
 
#define NBTP_NSJW_BIT   25u
 
#define NBTP_NSJW_SIZE   7u
 
#define NBTP_NTSEG1_SIZE   8u
 
#define NBTP_NTSEG2_SIZE   7u
 
#define NBTP_NBRP_SIZE   9u
 
#define DBTP_DSJW_BIT   0u
 
#define DBTP_DTSEG1_BIT   8u
 
#define DBTP_DTSEG2_BIT   4u
 
#define DBTP_DBRP_BIT   16u
 
#define DBTP_DSJW_SIZE   4u
 
#define DBTP_DTSEG1_SIZE   5u
 
#define DBTP_DTSEG2_SIZE   4u
 
#define DBTP_DBRP_SIZE   5u
 
#define TXBC_TFQM_BIT   24u
 
#define RXGFC_LSS_BIT   16u
 
#define RXGFC_LSE_BIT   24u
 
#define RXGFC_ANFS_BIT   4u
 
#define RXGFC_ANFE_BIT   2u
 
#define RXGFC_RRFE_BIT   0u
 
#define RXGFC_RRFS_BIT   1u
 
#define RXGFC_LSS_SIZE   5u
 
#define RXGFC_LSE_SIZE   4u
 
#define RXGFC_ANFS_SIZE   2u
 
#define RXGFC_ANFE_SIZE   2u
 
#define ECR_TEC_BIT   0u
 
#define ECR_REC_BIT   8u
 
#define ECR_RP_BIT   15u
 
#define ECR_TEC_SIZE   8u
 
#define ECR_REC_SIZE   7u
 
#define TXFQS_TFQF_BIT   20u
 
#define TXFQS_TFQPI_BIT   16u
 
#define TXFQS_TFQPI_SIZE   2u
 
#define TXEFS_EFGI_BIT   8u
 
#define TXEFS_EFFL_BIT   0u
 
#define TXEFS_EFGI_SIZE   2u
 
#define TXEFS_EFFL_SIZE   3u
 
#define RXF0S_F0GI_BIT   8
 
#define RXF0S_F0FL_BIT   0
 
#define RXF0S_F0GI_SIZE   3
 
#define RXF0S_F0FL_SIZE   4
 
#define PSR_BO_BIT   7u
 
#define PSR_EP_BIT   5u
 
#define PSR_LEC_BIT   0u
 
#define PSR_DLEC_BIT   8u
 
#define PSR_LEC_SIZE   3u
 
#define PSR_DLEC_SIZE   3u
 
#define TX_BUFFER_ID_11_BITS   18u
 
#define TX_BUFFER_ID_29_BITS   0u
 
#define TX_BUFFER_XTD_BIT   30u
 
#define TX_BUFFER_DLC_BIT   16u
 
#define TX_BUFFER_BRS_BIT   20u
 
#define TX_BUFFER_FDF_BIT   21u
 
#define TX_BUFFER_EFC_BIT   23u
 
#define TX_BUFFER_MM_BIT   24u
 
#define TX_BUFFER_ID_11_SIZE   11u
 
#define TX_BUFFER_ID_29_SIZE   29u
 
#define TX_BUFFER_DLC_SIZE   4u
 
#define TX_BUFFER_MM_SIZE   8u
 
#define RX_BUFFER_ID_11_BITS   18u
 
#define RX_BUFFER_ID_29_BITS   0u
 
#define RX_BUFFER_DLC_BIT   16u
 
#define RX_BUFFER_XTD_BIT   30u
 
#define RX_BUFFER_FDF_BIT   21u
 
#define RX_BUFFER_ID_11_SIZE   11u
 
#define RX_BUFFER_ID_29_SIZE   29u
 
#define RX_BUFFER_DLC_SIZE   4u
 
#define MSG_ID_BIT   31u
 
#define MSG_FORMAT_BIT   30u
 
#define FLSSA_SFID2_BIT   0u
 
#define FLSSA_SFID1_BIT   16u
 
#define FLSSA_SFEC_BIT   27u
 
#define FLSSA_SFT_BIT   30u
 
#define FLSSA_SFT_SIZE   2u
 
#define FLSSA_SFEC_SIZE   3u
 
#define FLESA_EFID_BIT   0u
 
#define FLESA_EFEC_BIT   29u
 
#define FLESA_EFT_BIT   30u
 
#define FLESA_EFT_SIZE   2u
 
#define FLESA_EFEC_SIZE   3u
 

Typedefs

typedef struct _HwObjectHandler HwObjectHandler
 Tx Hardware objecj descriptor.
 
typedef struct _HwExtFilter HwExtFilter
 Extended Filter descriptor.
 

Functions

static void Can_SetupConfiguredInterrupts (const Can_Controller *Controller, Can_RegisterType *Can)
 setup Can controller interrupts
 
static void Can_SetupConfiguredFilters (const Can_ConfigType *Config, uint8 Controller)
 Setup reception Filters
 
static void Can_SetupBaudrateConfig (const Can_ControllerBaudrateConfig *Baudrate, Can_RegisterType *Can)
 setup Can controller baudrate
 
static uint8 Can_GetClosestDlcWithPadding (uint8 Dlc, uint32 *RamBuffer, uint8 PaddingValue)
 Determine data lenth to send
 
static uint8 Can_GetTxPduId (const Can_Controller *Controller, PduIdType *CanPduId)
 Get an CAN PduId from the Tx Event FIFO zone
 
static void Can_GetMessage (volatile uint32 *Fifo, PduInfoType *PduInfo, uint32 *CanId)
 Get a Message from one of the the Rx FIFOs
 
static void Can_Isr_RxFifo0NewMessage (Can_HwUnit *HwUnit, uint8 Controller)
 Can Rx Fifo 0 New Message Callback
 
static void Can_Isr_RxFifo0Full (Can_HwUnit *HwUnit, uint8 Controller)
 Can Rx Fifo 0 Full Callback
 
static void Can_Isr_RxFifo0MessageLost (Can_HwUnit *HwUnit, uint8 Controller)
 Can Rx Fifo 0 Message Lost Callback
 
static void Can_Isr_RxFifo1NewMessage (Can_HwUnit *HwUnit, uint8 Controller)
 Can Rx Fifo 1 New Message Callback
 
static void Can_Isr_RxFifo1Full (Can_HwUnit *HwUnit, uint8 Controller)
 Can Rx Fifo 1 Full Callback
 
static void Can_Isr_RxFifo1MessageLost (Can_HwUnit *HwUnit, uint8 Controller)
 Can Rx Fifo 1 Message Lost Callback
 
static void Can_Isr_HighPriorityMessageRx (Can_HwUnit *HwUnit, uint8 Controller)
 Can Tx Fifo/Queue Error Callback
 
static void Can_Isr_TransmissionCompleted (Can_HwUnit *HwUnit, uint8 Controller)
 Can Transmission completed Callback
 
static void Can_Isr_TransmissionCancellationFinished (Can_HwUnit *HwUnit, uint8 Controller)
 Can Transmission cancellation finished Callback
 
static void Can_Isr_TxEventFifoElementLost (Can_HwUnit *HwUnit, uint8 Controller)
 Can Tx Event Fifo Element Lost Callback
 
static void Can_Isr_TxEventFifoFull (Can_HwUnit *HwUnit, uint8 Controller)
 Can Tx Event Fifo Full Callback
 
static void Can_Isr_TxEventFifoNewEntry (Can_HwUnit *HwUnit, uint8 Controller)
 Can Tx Event Fifo New Entry Callback
 
static void Can_Isr_TxFifoEmpty (Can_HwUnit *HwUnit, uint8 Controller)
 Can Tx Event Fifo Empty Callback
 
static void Can_Isr_TimestampWraparound (Can_HwUnit *HwUnit, uint8 Controller)
 Timestamp wraparound
 
static void Can_Isr_MessageRamAccessFailure (Can_HwUnit *HwUnit, uint8 Controller)
 Message RAM access failure
 
static void Can_Isr_TimeoutOccurred (Can_HwUnit *HwUnit, uint8 Controller)
 Timeout occurred
 
static void Can_Isr_ErrorLoggingOverflow (Can_HwUnit *HwUnit, uint8 Controller)
 Error logging overflow
 
static void Can_Isr_ErrorPassive (Can_HwUnit *HwUnit, uint8 Controller)
 Error passive
 
static void Can_Isr_WarningStatus (Can_HwUnit *HwUnit, uint8 Controller)
 Warning status
 
static void Can_Isr_BusOffStatus (Can_HwUnit *HwUnit, uint8 Controller)
 Can Bus Off Callback
 
static void Can_Isr_WatchdogInterrupt (Can_HwUnit *HwUnit, uint8 Controller)
 Watchdog error
 
static void Can_Isr_ProtocolErrorInArbitrationPhase (Can_HwUnit *HwUnit, uint8 Controller)
 Protocol error in arbitration phase (nominal bit time is used)
 
static void Can_Isr_ProtocolErrorInDataPhase (Can_HwUnit *HwUnit, uint8 Controller)
 Protocol error in data phase (data bit time is used)
 
void Can_Arch_Init (Can_HwUnit *HwUnit, const Can_ConfigType *Config, uint8 Controller)
 Can low level Initialization
 
void Can_Arch_DeInit (Can_HwUnit *HwUnit, uint8 Controller)
 Can low level Deinitialization
 
Std_ReturnType Can_Arch_SetBaudrate (Can_HwUnit *HwUnit, uint8 Controller, uint16 BaudRateConfigID)
 Can low level Set Baudrate
 
Std_ReturnType Can_Arch_SetControllerMode (Can_HwUnit *HwUnit, uint8 Controller, Can_ControllerStateType Transition)
 Can low level Set Controller Mode
 
void Can_Arch_EnableControllerInterrupts (Can_HwUnit *HwUnit, uint8 Controller)
 Can low level Enable Controller Interrupts
 
void Can_Arch_DisableControllerInterrupts (Can_HwUnit *HwUnit, uint8 Controller)
 Can low level Disable Controller Interrupts
 
Std_ReturnType Can_Arch_CheckWakeup (Can_HwUnit *HwUnit, uint8 Controller)
 Can low level wakeup check
 
Std_ReturnType Can_Arch_GetControllerErrorState (Can_HwUnit *HwUnit, uint8 ControllerId, Can_ErrorStateType *ErrorStatePtr)
 Can low level Get Controller Error State
 
Std_ReturnType Can_Arch_GetControllerMode (Can_HwUnit *HwUnit, uint8 Controller, Can_ControllerStateType *ControllerModePtr)
 Can low level Get Controller Mode
 
Std_ReturnType Can_Arch_GetControllerRxErrorCounter (Can_HwUnit *HwUnit, uint8 ControllerId, uint8 *RxErrorCounterPtr)
 Can low level Get Controller Rx Error Counter
 
Std_ReturnType Can_Arch_GetControllerTxErrorCounter (Can_HwUnit *HwUnit, uint8 ControllerId, uint8 *TxErrorCounterPtr)
 Can low level Get Controller Tx Error Counter
 
Std_ReturnType Can_Arch_GetCurrentTime (Can_HwUnit *HwUnit, uint8 ControllerId, Can_TimeStampType *timeStampPtr)
 Can low level Get Current Time
 
void Can_Arch_EnableEgressTimeStamp (Can_HwUnit *HwUnit, Can_HwHandleType Hth)
 Can low level Enable Egress TimeStamp
 
Std_ReturnType Can_Arch_GetEgressTimeStamp (Can_HwUnit *HwUnit, PduIdType TxPduId, Can_HwHandleType Hth, Can_TimeStampType *timeStampPtr)
 Can low level Get Egress TimeStamp
 
Std_ReturnType Can_Arch_GetIngressTimeStamp (Can_HwUnit *HwUnit, Can_HwHandleType Hrh, Can_TimeStampType *timeStampPtr)
 Can low level Get Ingress TimeStamp
 
Std_ReturnType Can_Arch_Write (Can_HwUnit *HwUnit, Can_HwHandleType Hth, const Can_PduType *PduInfo)
 Can low level Write
 
void Can_Arch_IsrMainHandler (Can_HwUnit *HwUnit, uint8 Controller)
 Can Interrupt Handler
 

Variables

static const Can_ErrorType AutosarError []
 Autosar errors to report.
 
static Can_RegisterTypeCanPeripherals [] = { CAN1, CAN2 }
 Can controller register structure.
 
static SramCan_RegisterTypeSramCanPeripherals [] = { SRAMCAN1, SRAMCAN2 }
 Can controller SRAM register structure.
 
static const uint8 DlcToBytes [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 20, 24, 32, 48, 64 }
 Dlc defines to actual bytes.
 
static const uint8 Fifo0ToCtrlIds [] = { 1u , 4u }
 Fifo 0 to controller id decoder.
 
static const uint8 Fifo1ToCtrlIds [] = { 2u , 5u }
 Fifo 1 to controller id decoder.
 

Detailed Description

Can Specific Arquitecture Driver

Author
Diego Perez

Can driver implementation for the STM32G0xx family of microcontrollers. This file contains the hardware specific implementation of the Can driver. The file is implemented as a means of abstraction from the hardware, this way we can avoid to include Arch headers in the actual driver header, making the low level interfaces available only for the inmediate upper layer.

Macro Definition Documentation

◆ Det_ReportRuntimeError

#define Det_ReportRuntimeError ( ModuleId,
InstanceId,
ApiId,
ErrorId )
Value:
(void)0
Parameters
ModuleIdmodule id number
InstanceIdInstance Id
ApiIdPai id
ErrorIdError code

◆ TXBC_TFQM_BIT

#define TXBC_TFQM_BIT   24u

Tx FIFO/Queue Mode bit

Function Documentation

◆ Can_Arch_CheckWakeup()

Std_ReturnType Can_Arch_CheckWakeup ( Can_HwUnit * HwUnit,
uint8 Controller )

Can low level wakeup check

This function checks if a wakeup has occurred for the given controller.

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the wakeup shall be checked.
Return values
E_OKwakeup detected E_NOT_OK: no wakeup detected

◆ Can_Arch_DeInit()

void Can_Arch_DeInit ( Can_HwUnit * HwUnit,
uint8 Controller )

Can low level Deinitialization

This function deinitializes the CAN controller. It sets the complete CAN controller into a state comparable to power on reset. All CAN controller registers will be reset to their reset values.

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller to be de-initialized
Requirement
SWS_Can_00223

< Initialization bit

< Initialization bit

< Clock stop request bit

< Clock stop acknowledge bit

< Configuration change enable bit

< Interrupt Line 0

< Interrupt Line 1

◆ Can_Arch_DisableControllerInterrupts()

void Can_Arch_DisableControllerInterrupts ( Can_HwUnit * HwUnit,
uint8 Controller )

Can low level Disable Controller Interrupts

This function disables all interrupts for this CAN controller. The function will only disable the internals interrupt lines zero and one, the external interrupt line must be disabled by the application using the Nvic Driver.

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which interrupts shall be disabled.
Requirement
SWS_Can_00049

< Interrupt Line 0

< Interrupt Line 1

◆ Can_Arch_EnableControllerInterrupts()

void Can_Arch_EnableControllerInterrupts ( Can_HwUnit * HwUnit,
uint8 Controller )

Can low level Enable Controller Interrupts

This function enables all interrupts for this CAN controller. The function will only enable the internals interrupt lines zero and one, the external interrupt line must be enabled by the application using the Nvic Driver.

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which interrupts shall be enabled.
Requirement
SWS_Can_00208

< Interrupt Line 0

< Interrupt Line 1

◆ Can_Arch_EnableEgressTimeStamp()

void Can_Arch_EnableEgressTimeStamp ( Can_HwUnit * HwUnit,
Can_HwHandleType Hth )

Can low level Enable Egress TimeStamp

Activates egress time stamping on the messages to be transmitted.

Parameters
HwUnitPointer to the hardware unit configuration
Hthinformation which HW-transmit handle shall be used for enabling the time stamp.
Note
This is the smallest granularity which can be added for enabling the timestamp, at HTH level, without affecting the performance.

◆ Can_Arch_GetControllerErrorState()

Std_ReturnType Can_Arch_GetControllerErrorState ( Can_HwUnit * HwUnit,
uint8 ControllerId,
Can_ErrorStateType * ErrorStatePtr )

Can low level Get Controller Error State

This function returns the error state of the CAN controller reading the internal registers.

Parameters
HwUnitPointer to the hardware unit configuration
ControllerIdCanIf ControllerId which is assigned to a CAN controller, which is requested for ErrorState.
ErrorStatePtrPointer to a memory location, where the error state of the CAN controller will be stored.
Return values
E_OKrequest accepted E_NOT_OK: request not accepted
Requirement
SWS_Can_91008

< Bus_Off bit

< Protocol_Error bit

◆ Can_Arch_GetControllerMode()

Std_ReturnType Can_Arch_GetControllerMode ( Can_HwUnit * HwUnit,
uint8 Controller,
Can_ControllerStateType * ControllerModePtr )

Can low level Get Controller Mode

The fucntion only returns the current software flag which stores the mode of the CAN controller set by the Can_Arch_SetControllerMode() function. It does not read any hardware registers

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be read.
ControllerModePtrPointer to a memory location, where the current mode of the CAN
Return values
E_OKrequest accepted E_NOT_OK: request not accepted
Requirement
SWS_Can_91014, SWS_Can_91015

◆ Can_Arch_GetControllerRxErrorCounter()

Std_ReturnType Can_Arch_GetControllerRxErrorCounter ( Can_HwUnit * HwUnit,
uint8 ControllerId,
uint8 * RxErrorCounterPtr )

Can low level Get Controller Rx Error Counter

Reads and return the Rx internal error counter of the can peripheral

Parameters
HwUnitPointer to the hardware unit configuration
ControllerIdCAN controller, whose current Rx error counter shall be acquired.
RxErrorCounterPtrPointer to a memory location, where the current Rx error counter of the CAN controller will be stored.
Return values
E_OKRx error counter available. E_NOT_OK: Wrong ControllerId, or Rx error counter not available.
Requirement
SWS_Can_00511, SWS_Can_00515

< Receive Error Counter

< Receive Error Counter bitfiled size

< Receive Error Passive

◆ Can_Arch_GetControllerTxErrorCounter()

Std_ReturnType Can_Arch_GetControllerTxErrorCounter ( Can_HwUnit * HwUnit,
uint8 ControllerId,
uint8 * TxErrorCounterPtr )

Can low level Get Controller Tx Error Counter

Reads and return the Tx internal error counter of the can peripheral

Parameters
HwUnitPointer to the hardware unit configuration
ControllerIdCAN controller, whose current Tx error counter shall be acquired.
TxErrorCounterPtrPointer to a memory location, where the current Tx error counter
Return values
E_OKTx error counter available. E_NOT_OK: Wrong ControllerId, or Tx error counter not
Requirement
SWS_Can_00516, SWS_Can_00520

< Transmit Error Counter

< Transmit Error Counter bitfiled size

◆ Can_Arch_GetCurrentTime()

Std_ReturnType Can_Arch_GetCurrentTime ( Can_HwUnit * HwUnit,
uint8 ControllerId,
Can_TimeStampType * timeStampPtr )

Can low level Get Current Time

Returns a time value out of the HW registers.

Parameters
HwUnitPointer to the hardware unit configuration
ControllerIdCAN controller, whose current time shall be acquired.
timeStampPtrPointer to a memory location, where the current time of the CAN
Return values
E_OKsuccessful E_NOT_OK: failed

◆ Can_Arch_GetEgressTimeStamp()

Std_ReturnType Can_Arch_GetEgressTimeStamp ( Can_HwUnit * HwUnit,
PduIdType TxPduId,
Can_HwHandleType Hth,
Can_TimeStampType * timeStampPtr )

Can low level Get Egress TimeStamp

Reads back the egress time stamp on a dedicated message object. It needs to be called within the TxConfirmation() function.

Parameters
HwUnitPointer to the hardware unit configuration
TxPduIdTx-PDU handle of CAN L-PDU that has been transmitted.
Hthinformation which HW-transmit handle shall be used for reading the time stamp.
timeStampPtrPointer to a memory location where the time stamp value shall be stored.
Return values
E_OKsuccess E_NOT_OK: failed to read time stamp.

◆ Can_Arch_GetIngressTimeStamp()

Std_ReturnType Can_Arch_GetIngressTimeStamp ( Can_HwUnit * HwUnit,
Can_HwHandleType Hrh,
Can_TimeStampType * timeStampPtr )

Can low level Get Ingress TimeStamp

Reads back the ingress time stamp on a dedicated message object. It needs to be called within the RxIndication() function.

Parameters
HwUnitPointer to the hardware unit configuration
Hrhinformation which HW-receive handle shall be used for reading the time stamp.
timeStampPtrPointer to a memory location where the time stamp value shall be stored.
Return values
E_OKsuccess E_NOT_OK: failed to read time stamp.

◆ Can_Arch_Init()

void Can_Arch_Init ( Can_HwUnit * HwUnit,
const Can_ConfigType * Config,
uint8 Controller )

Can low level Initialization

Set up the internal register for the CAN controller inside the microcontroller. This function shall take out the controller from the reset mode, set operation mode and initialize the baudrate according to the parameters in config structure, enable the interrupts for the controller and initialize all message objects as free.

Parameters
HwUnitPointer to the hardware unit configuration
ConfigPointer to driver configuration
ControllerIndex of the controller to be initialized
Requirement
SWS_Can_00237, SWS_Can_00236, SWS_Can_00238, SWS_Can_00239, SWS_Can_00419, SWS_Can_00250, SWS_Can_00053, SWS_Can_00407, SWS_Can_00021, SWS_Can_00291, SWS_Can_00413, SWS_Can_00223 SWS_Can_00245

< Clock stop request bit

< Clock stop acknowledge bit

< Initialization bit

< Initialization bit

< Configuration change enable bit

< Disable automatic retransmission bit

< Transmit pause bit

< Protocol exception handling disable bit

< FD operation enable bit

< Test mode enable bit

< Bus monitoring mode bit

< Restricted operation mode bit

< Loop back mode bit

< Restricted Operation mode

< Restricted operation mode bit

< Normal mode

< Bus Monitoring mode

< Test mode enable bit

< Loop back mode bit

< Internal LoopBack mode

< Bus monitoring mode bit

< Bus monitoring mode bit

< Tx FIFO/Queue Mode bit

< Reject Remote Frames Standard

< Reject Remote Frames Extended

< Reject Remote Frames Standard

< Reject Remote Frames Extended

◆ Can_Arch_IsrMainHandler()

void Can_Arch_IsrMainHandler ( Can_HwUnit * HwUnit,
uint8 Controller )

Can Interrupt Handler

This function is the interrupt handler for the Can controller, it will check the interrupt flags and call the corresponding callback functions.

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be changed.
Requirement
SWS_Can_00420, SWS_Can_00033

◆ Can_Arch_SetBaudrate()

Std_ReturnType Can_Arch_SetBaudrate ( Can_HwUnit * HwUnit,
uint8 Controller,
uint16 BaudRateConfigID )

Can low level Set Baudrate

This function sets the baudrate configuration of the CAN controller. The fucntion will determine if FD baud rate configuration is required and will set the baud rate accordingly. Function does not check if the baud rate configuration is valid.

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the baud rate shall be set.
BaudRateConfigIDreferences a baud rate configuration by ID
Return values
E_OKService request accepted, setting of (new) baud rate started E_NOT_OK: Service request not accepted
Requirement
SWS_Can_00255, SWS_Can_00256, SWS_Can_00260, SWS_Can_00422, SWS_Can_00500 SWS_Can_00062

◆ Can_Arch_SetControllerMode()

Std_ReturnType Can_Arch_SetControllerMode ( Can_HwUnit * HwUnit,
uint8 Controller,
Can_ControllerStateType Transition )

Can low level Set Controller Mode

This function performs software triggered state transitions of the CAN controller State machine. Trnasitions are: Start, Stop, Wakeup, Reset. It is required a previous state in order to proceed with the requested transition, otherwise the function will return E_NOT_OK.

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be changed.
TransitionTransition value to request new state.
Return values
E_OKrequest accepted E_NOT_OK: request not accepted
Requirement
SWS_Can_00261, SWS_Can_00409, SWS_Can_00265, SWS_Can_00266, SWS_Can_00411, SWS_Can_00017 SWS_Can_00384, SWS_Can_00257, SWS_Can_00282, SWS_Can_00426, SWS_Can_00425

< Initialization bit

< Initialization bit

< Initialization bit

< Clock stop request bit

< Clock stop acknowledge bit

< Configuration change enable bit

< Clock stop request bit

< Clock stop acknowledge bit

◆ Can_Arch_Write()

Std_ReturnType Can_Arch_Write ( Can_HwUnit * HwUnit,
Can_HwHandleType Hth,
const Can_PduType * PduInfo )

Can low level Write

The function stores the message pointed to by PduInfo into the internal Tx message buffer of the CAN Sram area and activates the corresponding hardware transmit bits. It reades the hardware fifo index to know which of the three buffers is available for transmission. The function will return CAN_BUSY if no buffer is available.

Parameters
HwUnitPointer to the hardware unit configuration
Hthinformation 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.
PduInfoPointer to SDU user memory, Data Length and Identifier
Return values
E_OKWrite 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)
Requirement
SWS_Can_00213, SWS_Can_00214, SWS_Can_00275, SWS_Can_00277, SWS_Can_00401, SWS_Can_00402 SWS_Can_00403, SWS_Can_00011, SWS_Can_00486, SWS_Can_00502, SWS_Can_00276

< Tx FIFO/Queue Full

< Tx FIFO/Queue Put Index

< Tx FIFO/Queue Put Index bitfiled size

< ID bit

< Standard ID

< Tx standard ID bit

< Tx standard ID bitfield size

< Extended identifier bit

< Tx extended ID bit

< Tx extended ID bitfield size

< Extended identifier bit

< Message Marker bit

< Message Marker bitfield size

< Fromat ID bit

< Classic mode

< FD format bit

< FD format bit

< Bit rate switch enable bit

< Bit rate switch bit

< Event FIFO Control bit

< Data length code bit

< Data length code bitfield size

◆ Can_GetClosestDlcWithPadding()

static uint8 Can_GetClosestDlcWithPadding ( uint8 Dlc,
uint32 * RamBuffer,
uint8 PaddingValue )
static

Determine data lenth to send

< Add static when no testing

This function determines the data lenght to send according to the CAN FD specification, in case the actual data lenght do not match with any of the available data lenghts, the function will return the closest data lenght with padding.

Parameters
DlcData lenght to send
RamBufferPointer to the buffer where the data will be stored
PaddingValueValue to use for padding
Return values
DataLenghtDefine with for data lenght to send

< Add static when no testing

< 12 bytes payload length

< 16 bytes payload length

< 20 bytes payload length

< 24 bytes payload length

< 32 bytes payload length

< 48 bytes payload length

< 64 bytes payload length

< 8 bytes payload length

◆ Can_GetMessage()

static void Can_GetMessage ( volatile uint32 * Fifo,
PduInfoType * PduInfo,
uint32 * CanId )
static

Get a Message from one of the the Rx FIFOs

< Add static when no testing

This function gets the oldest message from one of the the Rx FIFOs, it also returns the message ID and the data lenght, the message is actually store into the ObjHeader1, ObjHeader2 and ObjPayload fields of the Rx FIFO element.

Parameters
FifoPointer to the Rx FIFO element.
PduInfoPointer to the variable where the message will be stored.
CanIdPointer to the variable where the message ID will be stored.

< Add static when no testing

< Data length code bit

< Data length code bitfield size

< Extended identifier bit

< Standard ID

< Rx standard ID bit

< Rx standard ID bitfield size

< Rx extended ID bit

< Rx extended ID bitfield size

< ID bit

< FD format bit

< Fromat ID bit

◆ Can_GetTxPduId()

static uint8 Can_GetTxPduId ( const Can_Controller * Controller,
PduIdType * CanPduId )
static

Get an CAN PduId from the Tx Event FIFO zone

< Add static when no testing

This function gets the oldest CAN PduId from the Tx Event FIFO zone, it also returns the number of elements in the Tx Event FIFO zone., the CAN Pdu id is actually store into the MM field of the Tx Event FIFO element.

Parameters
ControllerCAN controller for which the status shall be changed.
CanPduIdPointer to the variable where the CAN PduId will be stored.
Return values
Numberof elements left in the Tx Event FIFO zone.

< Add static when no testing

< Tx FIFO/Queue Get Index

< Tx FIFO/Queue Get Index bitfiled size

< Message Marker bit

< Message Marker bitfield size

< Tx FIFO/Queue Fill Level

< Tx FIFO/Queue Fill Level bitfiled size

◆ Can_Isr_BusOffStatus()

static void Can_Isr_BusOffStatus ( Can_HwUnit * HwUnit,
uint8 Controller )
static

Can Bus Off Callback

< Add static when no testing

This function is the callback for the Bus Off interrupt, it will set the controller mode to stopped and notify the upper layer that the controller is in bus off mode.

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be changed.
Requirement
SWS_Can_00020, SWS_Can_00272, SWS_Can_00273, SWS_Can_00274

< Add static when no testing

< Bus_Off bit

< Initialization bit

< Configuration change enable bit

◆ Can_Isr_ErrorLoggingOverflow()

static void Can_Isr_ErrorLoggingOverflow ( Can_HwUnit * HwUnit,
uint8 Controller )
static

Error logging overflow

< Add static when no testing

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be changed.

< Add static when no testing

◆ Can_Isr_ErrorPassive()

static void Can_Isr_ErrorPassive ( Can_HwUnit * HwUnit,
uint8 Controller )
static

Error passive

< Add static when no testing

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be changed.
Requirement
SWS_Can_91023

< Add static when no testing

◆ Can_Isr_HighPriorityMessageRx()

static void Can_Isr_HighPriorityMessageRx ( Can_HwUnit * HwUnit,
uint8 Controller )
static

Can Tx Fifo/Queue Error Callback

< Add static when no testing

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be changed.

< Add static when no testing

◆ Can_Isr_MessageRamAccessFailure()

static void Can_Isr_MessageRamAccessFailure ( Can_HwUnit * HwUnit,
uint8 Controller )
static

Message RAM access failure

< Add static when no testing

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be changed.

< Add static when no testing

◆ Can_Isr_ProtocolErrorInArbitrationPhase()

static void Can_Isr_ProtocolErrorInArbitrationPhase ( Can_HwUnit * HwUnit,
uint8 Controller )
static

Protocol error in arbitration phase (nominal bit time is used)

< Add static when no testing

The function report the Error code to upper layer CanIf in error happens in arbitration phase, errors reported are only tose the Mcu supports, if the Mcu doesn't support the error it will be ignored

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be changed.
Requirement
SWS_Can_91021, SWS_Can_91022, SWS_Can_91024

< Add static when no testing

◆ Can_Isr_ProtocolErrorInDataPhase()

static void Can_Isr_ProtocolErrorInDataPhase ( Can_HwUnit * HwUnit,
uint8 Controller )
static

Protocol error in data phase (data bit time is used)

< Add static when no testing

The function report the Error code to upper layer CanIf in error happens in data phase, errors reported are only tose the Mcu supports, if the Mcu doesn't support the error it will be ignored

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be changed.
Requirement
SWS_Can_91021, SWS_Can_91022, SWS_Can_91024

< Add static when no testing

◆ Can_Isr_RxFifo0Full()

static void Can_Isr_RxFifo0Full ( Can_HwUnit * HwUnit,
uint8 Controller )
static

Can Rx Fifo 0 Full Callback

< Add static when no testing

This function is the callback for the Rx Fifo 0 Full interrupt, it will read all the messages arrived and pass them to the upper layer.

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be changed.
Requirement
SWS_Can_00489, SWS_Can_00501, SWS_Can_00423, SWS_Can_00279

< Add static when no testing

< Rx FIFO 0 Fill Level

< Rx FIFO 0 Fill Level

< Rx FIFO 0 Get Index

< Rx FIFO 0 Get Index bitfiled size

◆ Can_Isr_RxFifo0MessageLost()

static void Can_Isr_RxFifo0MessageLost ( Can_HwUnit * HwUnit,
uint8 Controller )
static

Can Rx Fifo 0 Message Lost Callback

< Add static when no testing

A messages haven't read on time and it was overwritten or not by a new message. if FIfo is in blocking mode the message will never overwrite but this ISR will be called

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be changed.
Requirement
SWS_Can_00395

< Add static when no testing

◆ Can_Isr_RxFifo0NewMessage()

static void Can_Isr_RxFifo0NewMessage ( Can_HwUnit * HwUnit,
uint8 Controller )
static

Can Rx Fifo 0 New Message Callback

< Add static when no testing

This function is the callback for the Rx Fifo 0 New Message interrupt, it will read the oldest message arrived and pass it to the upper layer.

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be changed.
Requirement
SWS_Can_00489, SWS_Can_00501, SWS_Can_00423, SWS_Can_00279

< Add static when no testing

< Rx FIFO 0 Get Index

< Rx FIFO 0 Get Index bitfiled size

◆ Can_Isr_RxFifo1Full()

static void Can_Isr_RxFifo1Full ( Can_HwUnit * HwUnit,
uint8 Controller )
static

Can Rx Fifo 1 Full Callback

< Add static when no testing

This function is the callback for the Rx Fifo 1 Full interrupt, it will read all the messages arrived and pass them to the upper layer.

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be changed.
Requirement
SWS_Can_00489, SWS_Can_00501, SWS_Can_00423, SWS_Can_00279

< Add static when no testing

< Rx FIFO 0 Fill Level

< Rx FIFO 0 Fill Level

< Rx FIFO 0 Get Index

< Rx FIFO 0 Get Index bitfiled size

◆ Can_Isr_RxFifo1MessageLost()

static void Can_Isr_RxFifo1MessageLost ( Can_HwUnit * HwUnit,
uint8 Controller )
static

Can Rx Fifo 1 Message Lost Callback

< Add static when no testing

A messages haven't read on time and it was overwritten or not by a new message. if FIfo is in blocking mode the message will never overwrite but this ISR will be called

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be changed.
Requirement
SWS_Can_00395

< Add static when no testing

◆ Can_Isr_RxFifo1NewMessage()

static void Can_Isr_RxFifo1NewMessage ( Can_HwUnit * HwUnit,
uint8 Controller )
static

Can Rx Fifo 1 New Message Callback

< Add static when no testing

This function is the callback for the Rx Fifo 1 New Message interrupt, it will read the oldest message arrived and pass it to the upper layer.

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be changed.
Requirement
SWS_Can_00489, SWS_Can_00501, SWS_Can_00423, SWS_Can_00279

< Add static when no testing

< Rx FIFO 0 Get Index

< Rx FIFO 0 Get Index bitfiled size

◆ Can_Isr_TimeoutOccurred()

static void Can_Isr_TimeoutOccurred ( Can_HwUnit * HwUnit,
uint8 Controller )
static

Timeout occurred

< Add static when no testing

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be changed.

< Add static when no testing

◆ Can_Isr_TimestampWraparound()

static void Can_Isr_TimestampWraparound ( Can_HwUnit * HwUnit,
uint8 Controller )
static

Timestamp wraparound

< Add static when no testing

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be changed.

< Add static when no testing

◆ Can_Isr_TransmissionCancellationFinished()

static void Can_Isr_TransmissionCancellationFinished ( Can_HwUnit * HwUnit,
uint8 Controller )
static

Can Transmission cancellation finished Callback

< Add static when no testing

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be changed.

< Add static when no testing

◆ Can_Isr_TransmissionCompleted()

static void Can_Isr_TransmissionCompleted ( Can_HwUnit * HwUnit,
uint8 Controller )
static

Can Transmission completed Callback

< Add static when no testing

This function is the callback for the Transmission completed interrupt, it will read the PduId of the recent message transmitted and pass it to the upper layer.

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be changed.
Note
This interrupt callback shall not be called if Can_Isr_TxEventFifoNewEntry is been use
Requirement
SWS_Can_00016

< Add static when no testing

◆ Can_Isr_TxEventFifoElementLost()

static void Can_Isr_TxEventFifoElementLost ( Can_HwUnit * HwUnit,
uint8 Controller )
static

Can Tx Event Fifo Element Lost Callback

< Add static when no testing

A messages event haven't read on time and it was overwritten or not by a new message. if FIfo is in blocking mode the message will never overwrite but this ISR will be called

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be changed.
Requirement
SWS_Can_91022

< Add static when no testing

◆ Can_Isr_TxEventFifoFull()

static void Can_Isr_TxEventFifoFull ( Can_HwUnit * HwUnit,
uint8 Controller )
static

Can Tx Event Fifo Full Callback

< Add static when no testing

This function is the callback for the Tx Event Fifo Full interrupt, it will read the PduId of the all recent message transmitted and pass it to the upper layer.

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be changed.
Note
This interrupt callback shall not be called if Can_Isr_TxFifoEmpty is been use
Requirement
SWS_Can_00016

< Add static when no testing

◆ Can_Isr_TxEventFifoNewEntry()

static void Can_Isr_TxEventFifoNewEntry ( Can_HwUnit * HwUnit,
uint8 Controller )
static

Can Tx Event Fifo New Entry Callback

< Add static when no testing

This function is the callback for the Tx Event Fifo New Entry interrupt, it will read the PduId of the recent message transmitted and pass it to the upper layer.

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be changed.
Note
This interrupt callback shall not be called if Can_Isr_TransmissionCompleted is been use
Requirement
SWS_Can_00016

< Add static when no testing

◆ Can_Isr_TxFifoEmpty()

static void Can_Isr_TxFifoEmpty ( Can_HwUnit * HwUnit,
uint8 Controller )
static

Can Tx Event Fifo Empty Callback

< Add static when no testing

This function is the callback for the Tx Event Fifo Empty interrupt, it will read the PduId of the all recent message transmitted and pass it to the upper layer.

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be changed.
Note
This interrupt callback shall not be called if Can_Isr_TxEventFifoFull is been use
Requirement
SWS_Can_00016

< Add static when no testing

◆ Can_Isr_WarningStatus()

static void Can_Isr_WarningStatus ( Can_HwUnit * HwUnit,
uint8 Controller )
static

Warning status

< Add static when no testing

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be changed.

< Add static when no testing

◆ Can_Isr_WatchdogInterrupt()

static void Can_Isr_WatchdogInterrupt ( Can_HwUnit * HwUnit,
uint8 Controller )
static

Watchdog error

< Add static when no testing

Parameters
HwUnitPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be changed.

< Add static when no testing

◆ Can_SetupBaudrateConfig()

static void Can_SetupBaudrateConfig ( const Can_ControllerBaudrateConfig * Baudrate,
Can_RegisterType * Can )
static

setup Can controller baudrate

< Add static when no testing

This function sets up the baudrate for the given controller. It will set the baudrate for the nominal and data bit timing registers. The function will only set the baudrate if the Baudrate pointer is not NULL.

Parameters
BaudrateBaudrate configuration
CanRegister structure of the CAN controller

< Add static when no testing

< Nominal (Re)Synchronization Jump Width

< Nominal Jump Width bitfiled size

< Nominal Time Segment 1

< Nominal Time Segment 1 bitfiled size

< Nominal Time Segment 2

< Nominal Time Segment 2 bitfiled size

< Nominal Baud Rate Prescaler

< Nominal Baud Rate Prescaler bitfiled size

< Data (Re)Synchronization Jump Width

< Data Jump Width bitfiled size

< Data Time Segment 1

< Data Time Segment 1 bitfiled size

< Data Time Segment 2

< Data Time Segment 2 bitfiled size

< Data Baud Rate Prescaler

< Nominal Baud Rate Preescaler bitfiled size

< Bit rate switch enable bit

◆ Can_SetupConfiguredFilters()

static void Can_SetupConfiguredFilters ( const Can_ConfigType * Config,
uint8 Controller )
static

Setup reception Filters

< Add static when no testing

This function sets up the reception filters for the given controller. It will set the filters for the standard and extended ID's. The function will only set the filters if the HwFilter pointer is not NULL.

Parameters
ConfigPointer to the hardware unit configuration
ControllerCAN controller for which the status shall be changed.

< Add static when no testing

< Receive object

< Standard ID

< Mixed ID

< Standard ID

< Standard ID Filter 1

< Rx standard ID bitfield size

< Standard ID Filter 2

< Rx standard ID bitfield size

< Standard ID Filter Element Configuration

< Standard ID Filter 1 bitfield size

< Standard ID Filter Type

< Standard ID Filter Type bitfield size

< Extended ID

< Mixed ID

< Extended ID

< Extended ID Filter 1

< Rx extended ID bitfield size

< Extended ID Filter 1

< Rx extended ID bitfield size

< Extended ID Filter Type

< Extended ID Filter Type bitfield size

< Extended ID Filter Element Configuration

< Extended ID Filter 1 bitfield size

< List Size Standard

< List Size Standard

< Accept Non-matching Frames Standard

< Accept Non-matching Frames Standard

< List Size Extended

< List Size Extended

< Accept Non-matching Frames Extended

< Accept Non-matching Frames Extended

◆ Can_SetupConfiguredInterrupts()

static void Can_SetupConfiguredInterrupts ( const Can_Controller * Controller,
Can_RegisterType * Can )
static

setup Can controller interrupts

< Add static when no testing

This function setup the interrupts for the Can controller, tkaes the values in Line0ActiveITs and Line1ActiveITs and assign to interrupt lines plus enable the Tx complete and abort interrupts

Parameters
ControllerCAN controller for which the status shall be changed.
CanPointer to the Can controller register structure

< Add static when no testing

< Rx FIFO 1 message lost

< Rx FIFO 1 message lost

< Tx Event FIFO element lost

< Error_Passive status changed

< Protocol error in arbitration phase detected

< Protocol error in data phase detected

< Misc. Interrupts Group: TOOL: Timeout Occurred, MRAFL: Message RAM Access Failure and TSWL: Timestamp Wraparound

< Misc. Interrupts List

< Bit and Line Error Interrupts Group: EPL: Error Passive and ELOL: Error Logging Overflow

< Bit and Line Error Interrupts List

< Protocol Error Group: ARAL: Access to Reserved Address Line, PEDL: Protocol Error in Data Phase Line, PEAL: Protocol Error in Arbitration Phase Line WDIL: Watchdog Interrupt Line, BOL: Bus_Off Status and EWL: Warning Status

< Protocol Error Interrupts List

< Transmission Completed

< Add message to Tx Buffer 0

< Add message to Tx Buffer 1

< Add message to Tx Buffer 2

< Transmission Cancellation Finished

< Add message to Tx Buffer 0

< Add message to Tx Buffer 1

< Add message to Tx Buffer 2

Variable Documentation

◆ AutosarError

const Can_ErrorType AutosarError[]
static
Initial value:
= {
0,
}
@ CAN_ERROR_CHECK_ACK_FAILED
Definition Can_GeneralTypes.h:101
@ CAN_ERROR_CHECK_CRC_FAILED
Definition Can_GeneralTypes.h:108
@ CAN_ERROR_CHECK_FORM_FAILED
Definition Can_GeneralTypes.h:106
@ CAN_ERROR_CHECK_STUFFING_FAILED
Definition Can_GeneralTypes.h:107
@ CAN_ERROR_BIT_MONITORING1
Definition Can_GeneralTypes.h:97
@ CAN_ERROR_BIT_MONITORING0
Definition Can_GeneralTypes.h:98

Autosar errors to report.