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
33#define WS22_TELEMETRY_STATUS_ID 2034U
34#define WS22_TELEMETRY_BUS_ID 2035U
35#define WS22_TELEMETRY_VELOCITY_ID 2036U
36#define WS22_TELEMETRY_TEMP_ID 2037U
37#define WS22_TELEMETRY_DRIVE_CMD_ID 2038U
38#define WS22_TELEMETRY_DLC 4U
45typedef enum {
46 CAN_MSG_PRIORITY_HIGH = 0,
47 CAN_MSG_PRIORITY_MEDIUM,
48 CAN_MSG_PRIORITY_LOW,
49 NUM_CAN_MSG_PRIORITIES,
51
57typedef struct {
58 uint32_t can_id;
59 uint8_t length;
60 uint8_t data[8];
62 bool pending;
64 uint32_t last_tx_tick;
67
73extern const size_t g_can_cache_high_size;
74
80extern const size_t g_can_cache_medium_size;
81
87extern const size_t g_can_cache_low_size;
88
CanMessageCache g_can_cache_low[]
Low-priority (slow-cycle) message cache.
Definition: can_cache.c:58
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:45
CanMessageCache g_can_cache_high[]
High-priority (fast-cycle) message cache.
Definition: can_cache.c:22
Per-message cache entry.
Definition: can_cache.h:57
uint32_t tx_cooldown_ticks
Definition: can_cache.h:65
bool pending
Definition: can_cache.h:62
CanMsgPriority priority
Definition: can_cache.h:61
uint8_t length
Definition: can_cache.h:59
uint32_t last_tx_tick
Definition: can_cache.h:64
uint32_t last_updated_tick
Definition: can_cache.h:63
uint32_t can_id
Definition: can_cache.h:58