PER Firmware
Loading...
Searching...
No Matches
fdcan.c File Reference

G4 FDCAN public API implementation. More...

Include dependency graph for fdcan.c:

Functions

void PHAL_FDCAN_init (FDCAN_GlobalTypeDef *fdcan, PHAL_FDCAN_BaudRate_t bit_rate)
 Initialize an FDCAN peripheral for classic (non-FD) CAN operation.
 
bool PHAL_FDCAN_setFilters (FDCAN_GlobalTypeDef *fdcan, const uint32_t *sid_list, uint32_t num_sid, const uint32_t *xid_list, uint32_t num_xid)
 Configure exact-match acceptance filters for RX FIFO0.
 
bool PHAL_FDCAN_txFifoFree (const FDCAN_GlobalTypeDef *fdcan)
 Check whether the TX FIFO has at least one free slot.
 
bool PHAL_FDCAN_send (CanMsgTypeDef_t *msg)
 Queue a frame for transmission.
 
static void fdcan_rxIRQHandler (FDCAN_GlobalTypeDef *fdcan)
 
static void fdcan_txIRQHandler (FDCAN_GlobalTypeDef *fdcan)
 
void PHAL_FDCAN_rxCallback (CanMsgTypeDef_t *msg)
 Weak callback fired once per received frame.
 
void PHAL_FDCAN_txCallback (FDCAN_GlobalTypeDef *fdcan)
 Weak callback fired when a queued frame finishes transmitting.
 
void FDCAN1_IT0_IRQHandler (void)
 
void FDCAN1_IT1_IRQHandler (void)
 
void FDCAN2_IT0_IRQHandler (void)
 
void FDCAN2_IT1_IRQHandler (void)
 
void FDCAN3_IT0_IRQHandler (void)
 
void FDCAN3_IT1_IRQHandler (void)
 

Detailed Description

G4 FDCAN public API implementation.

Author
Millan Kumar (kumar.nosp@m.798@.nosp@m.purdu.nosp@m.e.ed.nosp@m.u)

Logic level code. All register/message-RAM detail lives in fdcan_priv.c.

Function Documentation

◆ FDCAN1_IT0_IRQHandler()

void FDCAN1_IT0_IRQHandler ( void )
Here is the call graph for this function:

◆ FDCAN1_IT1_IRQHandler()

void FDCAN1_IT1_IRQHandler ( void )
Here is the call graph for this function:

◆ FDCAN2_IT0_IRQHandler()

void FDCAN2_IT0_IRQHandler ( void )
Here is the call graph for this function:

◆ FDCAN2_IT1_IRQHandler()

void FDCAN2_IT1_IRQHandler ( void )
Here is the call graph for this function:

◆ FDCAN3_IT0_IRQHandler()

void FDCAN3_IT0_IRQHandler ( void )
Here is the call graph for this function:

◆ FDCAN3_IT1_IRQHandler()

void FDCAN3_IT1_IRQHandler ( void )
Here is the call graph for this function:

◆ fdcan_rxIRQHandler()

static void fdcan_rxIRQHandler ( FDCAN_GlobalTypeDef * fdcan)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fdcan_txIRQHandler()

static void fdcan_txIRQHandler ( FDCAN_GlobalTypeDef * fdcan)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PHAL_FDCAN_init()

void PHAL_FDCAN_init ( FDCAN_GlobalTypeDef * fdcan,
PHAL_FDCAN_BaudRate_t bit_rate )

Initialize an FDCAN peripheral for classic (non-FD) CAN operation.

  • Setups up FDCAN clock (from PCLK1)
  • ~87.5% sample point
  • Classic CAN mode (FD/BRS off), auto-retransmission enabled, TX pause on
  • TX FIFO mode
  • RX FIFO0 new message (line 0) and TX complete interrupts (line 1)
  • Sets filter to accept everything into RX FIFO0
    • Use PHAL_FDCAN_setFilters later
Parameters
fdcanPeripheral instance (FDCAN1/2/3)
bit_ratedesired bit rate in bits per second
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PHAL_FDCAN_rxCallback()

void PHAL_FDCAN_rxCallback ( CanMsgTypeDef_t * msg)

Weak callback fired once per received frame.

Called from FDCANx_IT0_IRQHandler (interrupt context) for every frame popped from RX FIFO0.

Default implementation does nothing.

Parameters
msgthe received frame (valid only for the duration of the call)
Here is the caller graph for this function:

◆ PHAL_FDCAN_send()

bool PHAL_FDCAN_send ( CanMsgTypeDef_t * msg)

Queue a frame for transmission.

Non-blocking: if the TX FIFO is already full this returns false instead of blocking/waiting.

Parameters
msgframe to send; sent on msg->Bus peripheral
Returns
true if the frame was queued; false if the TX FIFO is full
Here is the call graph for this function:

◆ PHAL_FDCAN_setFilters()

bool PHAL_FDCAN_setFilters ( FDCAN_GlobalTypeDef * fdcan,
const uint32_t * sid_list,
uint32_t num_sid,
const uint32_t * xid_list,
uint32_t num_xid )

Configure exact-match acceptance filters for RX FIFO0.

Every ID in sid_list/xid_list is matched exactly. Any message whose ID is not in either list is rejected.

Note: this replaces any previously existing filter configurations

Parameters
fdcanPeripheral instance (FDCAN1/2/3)
sid_listarray of standard (11-bit) IDs to accept; may be NULL if num_sid == 0
num_sidnumber of entries in sid_list, up to MAX_NUM_SID_FILTER allowed
xid_listarray of extended (29-bit) IDs to accept; may be NULL if num_xid == 0
num_xidnumber of entries in xid_list, up to MAX_NUM_XID_FILTER allowed
Returns
true on success; false if num_sid or num_xid exceeds its max
Here is the call graph for this function:

◆ PHAL_FDCAN_txCallback()

void PHAL_FDCAN_txCallback ( FDCAN_GlobalTypeDef * fdcan)

Weak callback fired when a queued frame finishes transmitting.

Called from FDCANx_IT1_IRQHandler (interrupt context).

Default implementation does nothing.

Parameters
fdcanthe peripheral instance that completed a transmission
Here is the caller graph for this function:

◆ PHAL_FDCAN_txFifoFree()

bool PHAL_FDCAN_txFifoFree ( const FDCAN_GlobalTypeDef * fdcan)

Check whether the TX FIFO has at least one free slot.

Parameters
fdcanperipheral instance
Returns
true if a slot is free
Here is the call graph for this function:
Here is the caller graph for this function: