Avalon Firmware
 
Loading...
Searching...
No Matches
msg_handler.cpp File Reference

Handles CAN message reception, decoding, and response for supercap control. More...

Functions

void initCANComm (FDCAN_HandleTypeDef *fdcan_)
 Initializes and configures the CAN peripheral and message filters.
 
void HAL_FDCAN_RxFifo0Callback (FDCAN_HandleTypeDef *hfdcan, uint32_t RxFifo0ITs)
 Callback triggered when a new CAN message is received.
 
void HAL_FDCAN_ErrorStatusCallback (FDCAN_HandleTypeDef *hfdcan, uint32_t ErrorStatusITs)
 Called on FDCAN error interrupt (e.g. bus-off state).
 

Variables

static ref_msg_packet rxMsg
 Local message object storing the latest received control packet.
 

Detailed Description

Handles CAN message reception, decoding, and response for supercap control.

This module handles communication over FDCAN between the supercapacitor module and the main robot controller. It allows receiving control signals (enable/disable, power limit updates) and transmits supercap status (power, energy).

Created by: Yassine Bakkali Date: Jan 20, 2025

Function Documentation

◆ HAL_FDCAN_ErrorStatusCallback()

void HAL_FDCAN_ErrorStatusCallback ( FDCAN_HandleTypeDef * hfdcan,
uint32_t ErrorStatusITs )

Called on FDCAN error interrupt (e.g. bus-off state).

Resets the CAN peripheral and reinitializes the communication settings.

Parameters
hfdcanPointer to the affected CAN instance
ErrorStatusITsInterrupt flags (unused)

◆ HAL_FDCAN_RxFifo0Callback()

void HAL_FDCAN_RxFifo0Callback ( FDCAN_HandleTypeDef * hfdcan,
uint32_t RxFifo0ITs )

Callback triggered when a new CAN message is received.

If the message matches the expected node ID, it handles:

  • Enabling/disabling the supercap loop
  • Resetting the system
  • Updating the power limit and energy buffer reference
Parameters
hfdcanFDCAN peripheral instance
RxFifo0ITsInterrupt source bitmask

◆ initCANComm()

void initCANComm ( FDCAN_HandleTypeDef * fdcan_)

Initializes and configures the CAN peripheral and message filters.

Initializes CAN communication: configures filters and starts the FDCAN peripheral.

This function sets up the CAN ID filters, enables relevant interrupts, configures delay compensation, and starts the FDCAN interface.

Parameters
fdcan_Pointer to the FDCAN handle to initialize.

Variable Documentation

◆ rxMsg

ref_msg_packet rxMsg
static

Local message object storing the latest received control packet.