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

F4 bxCAN initialization, filters, and interrupt-driven frame transport. More...

#include "phal_F4/can/can.h"
Include dependency graph for can.c:

Classes

struct  PHAL_CAN_bit_timing_t
 

Functions

static bool is_valid_bus (const CAN_TypeDef *bus)
 
static bool get_bit_timing (PHAL_FDCAN_BaudRate_t bit_rate, uint32_t *timing)
 
static void configure_filters (CAN_TypeDef *bus, const uint32_t *sid_list, uint32_t num_sid, const uint32_t *xid_list, uint32_t num_xid)
 
bool PHAL_CAN_init (CAN_TypeDef *bus, PHAL_FDCAN_BaudRate_t bit_rate)
 
bool PHAL_CAN_setFilters (CAN_TypeDef *bus, const uint32_t *sid_list, uint32_t num_sid, const uint32_t *xid_list, uint32_t num_xid)
 
bool PHAL_CAN_send (CanMsgTypeDef_t *msg)
 
bool PHAL_CAN_txFifoFree (const CAN_TypeDef *bus)
 
static void rx_irq_handler (CAN_TypeDef *bus)
 
static void tx_irq_handler (CAN_TypeDef *bus)
 
void CAN1_RX0_IRQHandler (void)
 
void CAN1_TX_IRQHandler (void)
 
void CAN2_RX0_IRQHandler (void)
 
void CAN2_TX_IRQHandler (void)
 
void CAN3_RX0_IRQHandler (void)
 
void CAN3_TX_IRQHandler (void)
 
void PHAL_CAN_txCallback (CAN_TypeDef *can)
 
void PHAL_CAN_rxCallback (CanMsgTypeDef_t *msg)
 

Variables

uint32_t APB1ClockRateHz
 
static constexpr uint32_t PHAL_CAN_BANKS_PER_BUS = 14U
 
static constexpr uint32_t PHAL_CAN_IDS_PER_BANK = 2U
 
static constexpr uint32_t PHAL_CAN_MAX_FILTER_IDS = PHAL_CAN_BANKS_PER_BUS * PHAL_CAN_IDS_PER_BANK
 
static constexpr uint32_t PHAL_CAN_MAX_STD_ID = 0x7FFU
 
static constexpr uint32_t PHAL_CAN_MAX_EXT_ID = 0x1FFFFFFFU
 

Detailed Description

F4 bxCAN initialization, filters, and interrupt-driven frame transport.

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

Function Documentation

◆ CAN1_RX0_IRQHandler()

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

◆ CAN1_TX_IRQHandler()

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

◆ CAN2_RX0_IRQHandler()

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

◆ CAN2_TX_IRQHandler()

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

◆ CAN3_RX0_IRQHandler()

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

◆ CAN3_TX_IRQHandler()

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

◆ configure_filters()

static void configure_filters ( CAN_TypeDef * bus,
const uint32_t * sid_list,
uint32_t num_sid,
const uint32_t * xid_list,
uint32_t num_xid )
static
Here is the caller graph for this function:

◆ get_bit_timing()

static bool get_bit_timing ( PHAL_FDCAN_BaudRate_t bit_rate,
uint32_t * timing )
static
Here is the caller graph for this function:

◆ is_valid_bus()

static bool is_valid_bus ( const CAN_TypeDef * bus)
static
Here is the caller graph for this function:

◆ PHAL_CAN_init()

bool PHAL_CAN_init ( CAN_TypeDef * bus,
PHAL_FDCAN_BaudRate_t bit_rate )

Initialize the bus with an accept-all FIFO0 filter, waiting for hardware acknowledgement. Bus must be CAN1, CAN2 or CAN3 (nullptr is rejected). Return false for an invalid bus or unsupported clock/baud combination, before changing hardware.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PHAL_CAN_rxCallback()

void PHAL_CAN_rxCallback ( CanMsgTypeDef_t * msg)
Here is the caller graph for this function:

◆ PHAL_CAN_send()

bool PHAL_CAN_send ( CanMsgTypeDef_t * msg)

Queue a frame in any free mailbox; return false immediately if none is free.

Here is the call graph for this function:

◆ PHAL_CAN_setFilters()

bool PHAL_CAN_setFilters ( CAN_TypeDef * bus,
const uint32_t * sid_list,
uint32_t num_sid,
const uint32_t * xid_list,
uint32_t num_xid )

Replace this bus's filters. Empty lists accept all IDs; invalid input returns false.

Here is the call graph for this function:

◆ PHAL_CAN_txCallback()

void PHAL_CAN_txCallback ( CAN_TypeDef * can)
Here is the caller graph for this function:

◆ PHAL_CAN_txFifoFree()

bool PHAL_CAN_txFifoFree ( const CAN_TypeDef * bus)

Return true if a mailbox is free; false for an invalid bus (including nullptr).

Here is the call graph for this function:

◆ rx_irq_handler()

static void rx_irq_handler ( CAN_TypeDef * bus)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tx_irq_handler()

static void tx_irq_handler ( CAN_TypeDef * bus)
static
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ APB1ClockRateHz

uint32_t APB1ClockRateHz
extern

◆ PHAL_CAN_BANKS_PER_BUS

uint32_t PHAL_CAN_BANKS_PER_BUS = 14U
staticconstexpr

◆ PHAL_CAN_IDS_PER_BANK

uint32_t PHAL_CAN_IDS_PER_BANK = 2U
staticconstexpr

◆ PHAL_CAN_MAX_EXT_ID

uint32_t PHAL_CAN_MAX_EXT_ID = 0x1FFFFFFFU
staticconstexpr

◆ PHAL_CAN_MAX_FILTER_IDS

uint32_t PHAL_CAN_MAX_FILTER_IDS = PHAL_CAN_BANKS_PER_BUS * PHAL_CAN_IDS_PER_BANK
staticconstexpr

◆ PHAL_CAN_MAX_STD_ID

uint32_t PHAL_CAN_MAX_STD_ID = 0x7FFU
staticconstexpr