G4 FDCAN public API implementation.
More...
#include <stdint.h>
#include "stm32g474xx.h"
Go to the source code of this file.
G4 FDCAN public API implementation.
- Author
- Millan Kumar (kumar.nosp@m.798@.nosp@m.purdu.nosp@m.e.ed.nosp@m.u)
◆ PHAL_FDCAN_BaudRate_t
Supported baud rates for PER G4 FDCAN HAL.
| Enumerator |
|---|
| FDCAN_BAUD_250K | |
| FDCAN_BAUD_500K | |
| FDCAN_BAUD_1M | |
◆ PHAL_FDCAN_init()
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
-
| fdcan | Peripheral instance (FDCAN1/2/3) |
| bit_rate | desired bit rate in bits per second |
◆ PHAL_FDCAN_rxCallback()
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
-
| msg | the received frame (valid only for the duration of the call) |
◆ PHAL_FDCAN_send()
Queue a frame for transmission.
Non-blocking: if the TX FIFO is already full this returns false instead of blocking/waiting.
- Parameters
-
| msg | frame to send; sent on msg->Bus peripheral |
- Returns
- true if the frame was queued; false if the TX FIFO is full
◆ 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
-
| fdcan | Peripheral instance (FDCAN1/2/3) |
| sid_list | array of standard (11-bit) IDs to accept; may be NULL if num_sid == 0 |
| num_sid | number of entries in sid_list, up to MAX_NUM_SID_FILTER allowed |
| xid_list | array of extended (29-bit) IDs to accept; may be NULL if num_xid == 0 |
| num_xid | number 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
◆ PHAL_FDCAN_txCallback()
| void PHAL_FDCAN_txCallback |
( |
FDCAN_GlobalTypeDef * | fdcan | ) |
|
|
extern |
Weak callback fired when a queued frame finishes transmitting.
Called from FDCANx_IT1_IRQHandler (interrupt context).
Default implementation does nothing.
- Parameters
-
| fdcan | the peripheral instance that completed a transmission |
◆ PHAL_FDCAN_txFifoFree()
| bool PHAL_FDCAN_txFifoFree |
( |
const FDCAN_GlobalTypeDef * | fdcan | ) |
|
Check whether the TX FIFO has at least one free slot.
- Parameters
-
- Returns
- true if a slot is free
◆ PHAL_FDCAN_MAX_NUM_SID_FILTER
| uint32_t PHAL_FDCAN_MAX_NUM_SID_FILTER = 28 |
|
staticconstexpr |
◆ PHAL_FDCAN_MAX_NUM_XID_FILTER
| uint32_t PHAL_FDCAN_MAX_NUM_XID_FILTER = 8 |
|
staticconstexpr |