C/C++ API Reference¶
This section is generated from the source code using Doxygen + Breathe.
-
class MessageRouter¶
Typed topics for CAN cluster and system status with sticky last values.
Public Types
-
using ClusterCallback = void (*)(const Cluster_t &msg, uint32_t tsMs, void *ctx)¶
Callback signature for Cluster topic subscribers.
-
using SystemStatusCallback = void (*)(const SystemStatus &status, uint32_t tsMs, void *ctx)¶
Callback signature for SystemStatus topic subscribers.
Public Functions
-
MessageRouter()¶
Construct an empty router (allocate subscribers via Init).
-
bool Init(std::size_t maxClusterSubs = 8)¶
Initialize storage for subscribers.
- Parameters:
maxClusterSubs – Maximum number of Cluster subscribers to support.
- Returns:
true on success, false if allocation fails.
-
bool SubscribeCluster(ClusterCallback cb, void *ctx)¶
Register a callback for Cluster messages.
-
void UnsubscribeCluster(ClusterCallback cb, void *ctx)¶
Unregister a previously registered Cluster callback.
-
void PublishCluster(const Cluster_t &msg, uint32_t tsMs)¶
Publish a new Cluster message to all subscribers.
-
bool GetLastCluster(Cluster_t &out, uint32_t &tsMs) const¶
Retrieve last published Cluster message if available.
-
bool GetLastSeenMs(uint32_t &tsMs) const¶
Retrieve timestamp of last Cluster publication if available.
-
bool SubscribeSystemStatus(SystemStatusCallback cb, void *ctx)¶
Register a callback for SystemStatus updates.
-
void UnsubscribeSystemStatus(SystemStatusCallback cb, void *ctx)¶
Unregister a previously registered SystemStatus callback.
-
void PublishSystemStatus(const SystemStatus &status, uint32_t tsMs)¶
Publish a new SystemStatus snapshot to all subscribers.
-
bool GetLastSystemStatus(SystemStatus &out, uint32_t &tsMs) const¶
Retrieve last published SystemStatus if available.
-
struct SystemStatus¶
Lightweight snapshot of system state for consumers (e.g., IO gating)
-
using ClusterCallback = void (*)(const Cluster_t &msg, uint32_t tsMs, void *ctx)¶
-
class SystemController¶
Drives the main RX control flow by consuming EventQueue and publishing to MessageRouter.
Public Functions
-
SystemController(EventQueue &eventQueue, CanInterface &canInterface, UiController &uiController, HealthMonitor &healthMonitor, MessageRouter &messageRouter)¶
-
bool RunBootSequence()¶
Run one-time boot sequence (display, driver init).
-
void Dispatch(const Event &event)¶
Handle a single event.
Non-blocking; may transition state.
-
void Update()¶
Periodic tick for housekeeping (health checks, UI timers).
-
inline SystemState GetState() const¶
Current state accessor.
-
SystemController(EventQueue &eventQueue, CanInterface &canInterface, UiController &uiController, HealthMonitor &healthMonitor, MessageRouter &messageRouter)¶
-
class EventQueue¶
Thin wrapper around FreeRTOS queue for typed Event messages.
Public Functions
-
EventQueue()¶
-
~EventQueue()¶
-
bool Init(uint16_t queueLength = 10)¶
Initialize internal FreeRTOS queue.
-
bool Push(const Event &event)¶
Enqueue an event from task context.
-
bool PushFromISR(const Event &event)¶
Enqueue an event from ISR context.
-
bool Pop(Event &event, TickType_t timeout = 0)¶
Dequeue an event with optional timeout.
-
EventQueue()¶
-
class CanInterface¶
Initializes driver, sets mailbox filters, and bridges ISR -> EventQueue.
Public Functions
-
CanInterface()¶
-
bool Init(EventQueue &eventQueue)¶
Initialize CAN hardware and register ISR handler.
Public Static Functions
-
static void CanMsgHandler(CAN_FRAME *frame)¶
ISR entrypoint registered with the CAN driver.
-
CanInterface()¶
-
class IOModule¶
Configures pins and maintains blink state machine for indicators.
Public Functions
-
IOModule()¶
-
bool Init(uint8_t leftPin = IO_LEFT_RELAY_PIN, uint8_t rightPin = IO_RIGHT_RELAY_PIN, bool activeHigh = true)¶
Initialize IO pins and polarity.
-
bool Start(MessageRouter &router)¶
Subscribe to router topics to start receiving updates.
-
void Stop(MessageRouter &router)¶
Unsubscribe from router topics.
-
void Update(uint32_t nowMs)¶
Update outputs based on time and requested state.
-
IOModule()¶
-
class UiController¶
Initializes LVGL, manages screens, and runs an optional UI task processing queues.
Public Functions
-
UiController()¶
-
bool Init()¶
-
bool StartTask(uint16_t dataQueueLen = 1, uint16_t msgQueueLen = 10, UBaseType_t priority = 2, uint16_t stackWords = 20 * 1024)¶
-
bool EnqueueUiData(const UiData &data)¶
-
bool EnqueueMessage(const UiMessage &msg)¶
-
void ApplyCluster(const Cluster_t &cluster)¶
-
void ShowDegraded()¶
-
void ShowFault()¶
-
void ServiceTimers()¶
-
void ShowDashboardScreen()¶
-
void ShowLogScreen()¶
-
void AddLogLine(const char *line)¶
-
void AddLogLine(const std::string &line)¶
Public Static Functions
-
static uint16_t ConvertSpeedToArcValue(uint16_t rawSpeed)¶
-
UiController()¶
-
class HealthMonitor¶
Simple watchdog for Cluster flow staleness.
Public Functions
-
HealthMonitor()¶
-
bool CheckTimeout(EventQueue &eventQueue, const MessageRouter &router)¶
Check for timeout vs last-seen timestamp and enqueue events.
- Returns:
true if a timeout crossing was detected and an event enqueued.
-
void Reset()¶
Reset internal timeout latch.
-
void SetTimeoutMs(uint32_t timeoutMs)¶
Configure timeout threshold in milliseconds.
-
HealthMonitor()¶
Quick links¶
Message routing:
src/common/MessageRouter.hRX orchestration:
src/rx/SystemController.hEvent queue:
src/rx/EventQueue.hCAN interface:
src/rx/CanInterface.hIO outputs:
src/rx/IoModule.hUI controller:
src/rx/UiController.h