firmware
IEM Firmware Documentation
|
Data Structures | |
struct | CAN_Msg_t |
struct | canlib_scheduled_msg_params |
Typedefs | |
typedef void(* | CAN_Rx_Handler_t) (CAN_Msg_t *msg_ptr) |
Enumerations | |
enum | can_bus { CAN_1 = 0U , CAN_2 , CAN_3 , CAN_BUS_MAX } |
CAN bus ID enum. More... |
Functions | |
void | canlib_tx_task_init (Task_Init_t *init_ptr, enum can_bus bus, FDCAN_HandleTypeDef *hfdcan, uint16_t tx_queue_length) |
Initializes a FreeRTOS CAN transmit task for bus and creates a transmit queue with capacity tx_queue_length . | |
void | canlib_rx_task_init (Task_Init_t *init_ptr, enum can_bus bus, FDCAN_HandleTypeDef *hfdcan, uint32_t rx_location, CAN_Rx_Handler_t handler) |
Initializes a FreeRTOS CAN receive task for bus that receives messages from rx_location . Calls callback when a new message is received. | |
void | canlib_start (void) |
Starts all STM32 FDCAN peripherals that were registered to a CAN transmit or receive task. | |
void | canlib_register_timeout_ids (enum can_bus bus, FDCAN_HandleTypeDef *hfdcan, uint32_t timeout_ids_ptr[], unsigned timeout_ids_cnt) |
Registers CAN messages for timeout tracking by the CAN receive task for a CAN bus (also sorts the array of CAN IDs in ascending order, lol) | |
TimerHandle_t | canlib_register_scheduled_msgs (struct canlib_scheduled_msg_params *params_ptr) |
Registers an array of CAN messages for periodic transmission on a set interval with a FreeRTOS software timer. | |
uint32_t | canlib_get_msg_timeout (enum can_bus bus, uint32_t msg_id) |
Get the time since a message with ID msg_id was received on bus . If the CAN ID wasn't registered with canlib_register_timeout_ids() first on initialization, the returned value will be CANLIB_TIMEOUT_INVALID (UINT32_MAX) | |
bool | canlib_tx_generic (const CAN_Msg_t *msg_ptr, TickType_t block_time, bool is_critical) |
Queues a CAN message for transmission. | |
static __always_inline bool | canlib_tx (const CAN_Msg_t *msg_ptr, TickType_t block_time) |
static __always_inline bool | canlib_tx_critical (const CAN_Msg_t *msg_ptr, TickType_t block_time) |
bool | canlib_is_bus_ok (enum can_bus bus) |
Checks for protocol errors on bus . |
typedef void(* CAN_Rx_Handler_t) (CAN_Msg_t *msg_ptr) |
enum can_bus |
uint32_t canlib_get_msg_timeout | ( | enum can_bus | bus, |
uint32_t | msg_id ) |
Get the time since a message with ID msg_id
was received on bus
. If the CAN ID wasn't registered with canlib_register_timeout_ids() first on initialization, the returned value will be CANLIB_TIMEOUT_INVALID (UINT32_MAX)
bus | |
msg_id | CAN ID registered for timeout tracking |
bool canlib_is_bus_ok | ( | enum can_bus | bus | ) |
Checks for protocol errors on bus
.
bus |
TimerHandle_t canlib_register_scheduled_msgs | ( | struct canlib_scheduled_msg_params * | params_ptr | ) |
Registers an array of CAN messages for periodic transmission on a set interval with a FreeRTOS software timer.
params_ptr | Scheduled CAN message parameter struct |
void canlib_register_timeout_ids | ( | enum can_bus | bus, |
FDCAN_HandleTypeDef * | hfdcan, | ||
uint32_t | timeout_ids_ptr[], | ||
unsigned | timeout_ids_cnt ) |
Registers CAN messages for timeout tracking by the CAN receive task for a CAN bus (also sorts the array of CAN IDs in ascending order, lol)
bus | |
timeout_ids_ptr | Array of CAN IDs on bus to keep track of timeout data for |
timeout_ids_cnt | Length of array |
void canlib_rx_task_init | ( | Task_Init_t * | init_ptr, |
enum can_bus | bus, | ||
FDCAN_HandleTypeDef * | hfdcan, | ||
uint32_t | rx_location, | ||
CAN_Rx_Handler_t | handler ) |
Initializes a FreeRTOS CAN receive task for bus
that receives messages from rx_location
. Calls callback
when a new message is received.
init_ptr | Task initialization parameters |
bus | CAN bus for the transmit task |
hfdcan | HAL FDCAN peripheral handle |
rx_location | Either FDCAN_RX_FIFO0 or FDCAN_RX_FIFO1 |
callback | Received message handler function for project-specific CAN message handling. Called when the task receives a new message |
void canlib_start | ( | void | ) |
Starts all STM32 FDCAN peripherals that were registered to a CAN transmit or receive task.
|
static |
|
static |
bool canlib_tx_generic | ( | const CAN_Msg_t * | msg_ptr, |
TickType_t | block_time, | ||
bool | is_critical ) |
Queues a CAN message for transmission.
msg_ptr | |
block_time | In FreeRTOS kernel ticks |
block_time
ticks void canlib_tx_task_init | ( | Task_Init_t * | init_ptr, |
enum can_bus | bus, | ||
FDCAN_HandleTypeDef * | hfdcan, | ||
uint16_t | tx_queue_length ) |
Initializes a FreeRTOS CAN transmit task for bus
and creates a transmit queue with capacity tx_queue_length
.
init_ptr | Task initialization parameters |
bus | CAN bus for the transmit task |
hfdcan | HAL FDCAN peripheral handle |
tx_queue_length | Transmit queue capacity for this bus/task (number of CAN messages) |