Midnight Sun Firmware
Loading...
Searching...
No Matches
can_cache.h
1#pragma once
2
3/************************************************************************************************
4 * @file can_cache.h
5 *
6 * @brief CAN message cache for telemetry round-robin transmission
7 *
8 * @date 2026-06-10
9 * @author Midnight Sun Team #24 - MSXVI
10 ************************************************************************************************/
11
12/* Standard library Headers */
13#include <stdbool.h>
14#include <stddef.h>
15#include <stdint.h>
16
17/* Inter-component Headers */
18
19/* Intra-component Headers */
20
28#define TELEMETRY_STATS_CAN_ID 2020U
30#define TELEMETRY_STATS_DLC 6U
31
34#define WS22_TELEMETRY_STATUS_ID 2039U
35#define WS22_TELEMETRY_BUS_ID 2040U
36#define WS22_TELEMETRY_VELOCITY_ID 2041U
37#define WS22_TELEMETRY_TEMP_ID 2042U
38#define WS22_TELEMETRY_DRIVE_CMD_ID 2043U
39#define WS22_TELEMETRY_DLC 4U
46typedef enum {
47 CAN_MSG_PRIORITY_HIGH = 0,
48 CAN_MSG_PRIORITY_MEDIUM,
49 CAN_MSG_PRIORITY_LOW,
50 NUM_CAN_MSG_PRIORITIES,
52
58typedef struct {
59 uint32_t can_id;
60 uint8_t length;
61 uint8_t data[8];
63 bool pending;
65 uint32_t last_tx_tick;
68
74extern const size_t g_can_cache_high_size;
75
81extern const size_t g_can_cache_medium_size;
82
89extern const size_t g_can_cache_low_size;
90
CanMessageCache g_can_cache_low[]
Low-priority (slow-cycle) message cache.
Definition: can_cache.c:59
CanMessageCache g_can_cache_medium[]
Medium-priority (medium-cycle) message cache.
Definition: can_cache.c:27
CanMsgPriority
Transmission priority tier for a cached CAN message.
Definition: can_cache.h:46
CanMessageCache g_can_cache_high[]
High-priority (fast-cycle) message cache.
Definition: can_cache.c:22
Per-message cache entry.
Definition: can_cache.h:58
uint32_t tx_cooldown_ticks
Definition: can_cache.h:66
bool pending
Definition: can_cache.h:63
CanMsgPriority priority
Definition: can_cache.h:62
uint8_t length
Definition: can_cache.h:60
uint32_t last_tx_tick
Definition: can_cache.h:65
uint32_t last_updated_tick
Definition: can_cache.h:64
uint32_t can_id
Definition: can_cache.h:59