Avalon Firmware
 
Loading...
Searching...
No Matches
msg_handler.hpp
Go to the documentation of this file.
11
12#ifndef STM_UTILS_INC_MSG_HANDLER_HPP_
13#define STM_UTILS_INC_MSG_HANDLER_HPP_
14
15#include <cstdint>
16#include <fdcan.h>
17
21#define CAN_NODE_ID 0x067
22
26#define DEVC_NODE_ID 0x077
27
36 uint8_t enable_module;
37 uint8_t reset;
38 uint8_t pow_limit;
39 uint16_t energy_buffer;
40} __attribute__((packed));
41
51 uint8_t error;
52 uint8_t cap_energy;
53} __attribute__((packed));
54
59void initCANComm(FDCAN_HandleTypeDef* fdcan_);
60
68class CANComm {
69public:
74 CANComm(FDCAN_HandleTypeDef* fdcan_) : fdcan(fdcan_) { txHeaderConfig(); }
75
80
84 void sendMessage();
85
86private:
90 void txHeaderConfig();
91
95 void handleInterrupts();
96
97 FDCAN_HandleTypeDef* fdcan;
98
99 FDCAN_RxHeaderTypeDef RxHeader;
100 uint8_t* RxData;
101 FDCAN_TxHeaderTypeDef TxHeader;
102
103 supercap_msg_packet txMsg;
104
105 int errorStatus;
106};
107
108#endif /* STM_UTILS_INC_MSG_HANDLER_HPP_ */
void sendMessage()
Sends the current supercap_msg_packet status over CAN.
Definition msg_handler.cpp:75
~CANComm()
Destructor (does nothing but defined for completeness).
Definition msg_handler.hpp:79
CANComm(FDCAN_HandleTypeDef *fdcan_)
Constructor: sets up header configuration for outgoing messages.
Definition msg_handler.hpp:74
This file contains all the function prototypes for the fdcan.c file.
void initCANComm(FDCAN_HandleTypeDef *fdcan_)
Initializes CAN communication: configures filters and starts the FDCAN peripheral.
Definition msg_handler.cpp:24
class CANComm __attribute__
Definition syscalls.c:80
Incoming reference message structure received over CAN.
Definition msg_handler.hpp:35
uint16_t energy_buffer
Optional buffer value to apply limiting strategy.
Definition msg_handler.hpp:39
uint8_t pow_limit
Maximum power budget (W)
Definition msg_handler.hpp:38
uint8_t enable_module
Enable/disable flag for supercap control loop.
Definition msg_handler.hpp:36
uint8_t reset
If set, triggers a software reset.
Definition msg_handler.hpp:37
Outgoing status message structure sent over CAN.
Definition msg_handler.hpp:49
uint8_t cap_energy
Supercap charge percentage (0–255 mapped)
Definition msg_handler.hpp:52
uint8_t error
Error code or flag (0 = OK)
Definition msg_handler.hpp:51
float chassis_power
Computed instantaneous power drawn by chassis.
Definition msg_handler.hpp:50