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

CAN communication handler for sending and receiving control messages related to the supercapacitor power module. More...

#include <cstdint>
#include <fdcan.h>

Go to the source code of this file.

Data Structures

struct  ref_msg_packet
 Incoming reference message structure received over CAN. More...
 
struct  supercap_msg_packet
 Outgoing status message structure sent over CAN. More...
 
class  CANComm
 Abstraction class to manage CAN communication for the supercap board. More...
 

Macros

#define CAN_NODE_ID   0x067
 CAN ID for receiving command messages intended for this board.
 
#define DEVC_NODE_ID   0x077
 CAN ID used by this board to send messages to others.
 

Functions

struct ref_msg_packet __attribute__ ((packed))
 
void initCANComm (FDCAN_HandleTypeDef *fdcan_)
 Initializes CAN communication: configures filters and starts the FDCAN peripheral.
 

Variables

uint8_t enable_module
 Enable/disable flag for supercap control loop.
 
uint8_t reset
 If set, triggers a software reset.
 
uint8_t pow_limit
 Maximum power budget (W)
 
uint16_t energy_buffer
 Optional buffer value to apply limiting strategy.
 
float chassis_power
 Computed instantaneous power drawn by chassis.
 
uint8_t error
 Error code or flag (0 = OK)
 
uint8_t cap_energy
 Supercap charge percentage (0–255 mapped)
 
class CANComm __attribute__
 

Detailed Description

CAN communication handler for sending and receiving control messages related to the supercapacitor power module.

This header defines the message packet structures and the CANComm class that abstracts transmission and reception of messages using STM32's FDCAN peripheral.

Created on: Jan 20, 2025 Author: Yassine Bakkali

Macro Definition Documentation

◆ CAN_NODE_ID

#define CAN_NODE_ID   0x067

CAN ID for receiving command messages intended for this board.

< Standard integer types FDCAN peripheral definitions

◆ DEVC_NODE_ID

#define DEVC_NODE_ID   0x077

CAN ID used by this board to send messages to others.

Function Documentation

◆ __attribute__()

struct ref_msg_packet __attribute__ ( (packed) )

◆ initCANComm()

void initCANComm ( FDCAN_HandleTypeDef * fdcan_)

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

Parameters
fdcan_Pointer to the FDCAN handle used (typically &hfdcan3).

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

◆ __attribute__

struct supercap_msg_packet __attribute__

◆ cap_energy

uint8_t cap_energy

Supercap charge percentage (0–255 mapped)

◆ chassis_power

float chassis_power

Computed instantaneous power drawn by chassis.

◆ enable_module

uint8_t enable_module

Enable/disable flag for supercap control loop.

◆ energy_buffer

uint16_t energy_buffer

Optional buffer value to apply limiting strategy.

◆ error

uint8_t error

Error code or flag (0 = OK)

◆ pow_limit

uint8_t pow_limit

Maximum power budget (W)

◆ reset

uint8_t reset

If set, triggers a software reset.