File CANProtocol.h
FileList > CANProtocol > CANProtocol.h
Go to the source code of this file
Shared CAN bus types, frame IDs, and runtime API for OpenSkyhawk STM32 nodes.More...
#include <stdint.h>#include <HIDControls.h>
Namespaces
| Type | Name |
|---|---|
| namespace | CANProtocol |
Public Types
| Type | Name |
|---|---|
| typedef void(*)(uint32_t canId, const uint8_t *data, uint8_t len) | CanRxCallback Fired when a CAN frame is received. Register via onReceive(). |
| enum | CanStatus CAN bus health states. Reported to STM32Board via onStatusChange(). |
| typedef void(*)(CanStatus status) | CanStatusCallback Fired when CAN bus status changes. Register via onStatusChange(). |
| typedef void(*)() | CanSyncReqCallback Fired when SYNC_REQ is received. Register via onSyncReq(). |
Public Static Attributes
| Type | Name |
|---|---|
| constexpr uint32_t | CAN_ID_CTRL_BCAST = 0x010Broadcast ControlPacketPair to all panels. |
| constexpr uint32_t | CAN_ID_SYNC_REQ = 0x012Request all nodes to re-poll inputs. |
| constexpr uint32_t | CAN_ID_TEST_SEQ = 0x011RTT throughput test. |
| constexpr uint16_t | CTRL_ID_DCS_MAX = 0x86FFDCS-BIOS range end. |
| constexpr uint16_t | CTRL_ID_DCS_MIN = 0x8000DCS-BIOS range start. |
| constexpr uint8_t | DIAG_ERR = 0x03CAN error counter frame. |
| constexpr uint8_t | DIAG_EVT = 0x04Sub-node input event forwarded upstream. |
| constexpr uint8_t | DIAG_HB = 0x02Sub-node heartbeat frame. |
| constexpr uint8_t | DIAG_MAGIC = 0xAAFrame sync byte. |
| constexpr uint8_t | DIAG_RTT = 0x01Round-trip time measurement frame. |
Public Functions
| Type | Name |
|---|---|
| struct | __attribute__ ((packed)) Primary input/output routing packet. 4 bytes; two are batched for CTRL_BCAST/EVT_n. |
| constexpr uint32_t | canIdEcho (uint8_t n) TEST_SEQ echo frame ID for node n. Range 0x301-0x33F. |
| constexpr uint32_t | canIdEvt (uint8_t n) Input event frame ID for node n. Range 0x201-0x23F. |
| constexpr uint32_t | canIdEvtDir (uint8_t n) Directional-input event frame ID for node n. RotaryEncoder DIR mode: payload value is a signed ±1 (int16); the bridge formats it INC /DEC for a DCS-BIOS fixed_step control. Range 0x601-0x63F. |
| constexpr uint32_t | canIdEvtRel (uint8_t n) Relative-input event frame ID for node n. RotaryEncoder REL mode: payload value is a signed ±step (int16); the bridge formats it %+d for a DCS-BIOS variable_step control. Range 0x501-0x53F. |
| constexpr uint32_t | canIdHb (uint8_t n) Heartbeat frame ID for node n. Range 0x100-0x13F; n=0 is PanelBridge . |
| constexpr uint32_t | canIdReady (uint8_t n) Boot-complete READY frame ID for node n. Range 0x401-0x43F. |
Detailed Description
Owns all CAN bus interaction for PanelGroup and PanelBridge nodes. Types and constants (ControlPacket, CanStatus, frame IDs, CAN ID functions) are platform-agnostic. The runtime namespace (filters, lifecycle, send, callbacks, diagnostics) is STM32-only and guarded by ARDUINO_ARCH_STM32. CAN arbitration IDs (CAN_ID_*, canId*()) and payload ControlPacket::controlId values are separate namespaces; equal numeric values do not conflict because they occupy different CAN frame fields.
Dependency: STM32Board::begin() must be called before CANProtocol::start(). CANProtocol owns CAN bus operation; STM32Board owns peripheral hardware init.
Version:
0.2.0
Copyright:
GPL-2.0-only — see Firmware/LICENSE
Public Types Documentation
typedef CanRxCallback
Fired when a CAN frame is received. Register via onReceive().
using CanRxCallback = void(*)(uint32_t canId, const uint8_t* data, uint8_t len);
enum CanStatus
CAN bus health states. Reported to STM32Board via onStatusChange().
enum CanStatus {
STARTING,
NORMAL,
TX_ERROR,
BUS_OFF
};
typedef CanStatusCallback
Fired when CAN bus status changes. Register via onStatusChange().
using CanStatusCallback = void(*)(CanStatus status);
typedef CanSyncReqCallback
Fired when SYNC_REQ is received. Register via onSyncReq().
using CanSyncReqCallback = void(*)();
Public Static Attributes Documentation
variable CAN_ID_CTRL_BCAST
Broadcast ControlPacketPair to all panels.
constexpr uint32_t CAN_ID_CTRL_BCAST;
variable CAN_ID_SYNC_REQ
Request all nodes to re-poll inputs.
constexpr uint32_t CAN_ID_SYNC_REQ;
variable CAN_ID_TEST_SEQ
RTT throughput test.
constexpr uint32_t CAN_ID_TEST_SEQ;
variable CTRL_ID_DCS_MAX
DCS-BIOS range end.
constexpr uint16_t CTRL_ID_DCS_MAX;
variable CTRL_ID_DCS_MIN
DCS-BIOS range start.
constexpr uint16_t CTRL_ID_DCS_MIN;
variable DIAG_ERR
CAN error counter frame.
constexpr uint8_t DIAG_ERR;
variable DIAG_EVT
Sub-node input event forwarded upstream.
constexpr uint8_t DIAG_EVT;
variable DIAG_HB
Sub-node heartbeat frame.
constexpr uint8_t DIAG_HB;
variable DIAG_MAGIC
Frame sync byte.
constexpr uint8_t DIAG_MAGIC;
variable DIAG_RTT
Round-trip time measurement frame.
constexpr uint8_t DIAG_RTT;
Public Functions Documentation
function __attribute__
Primary input/output routing packet. 4 bytes; two are batched for CTRL_BCAST/EVT_n.
struct __attribute__ (
(packed)
)
8-byte payload carried by HB_n heartbeat frames.
Two ControlPackets packed into one 8-byte input/output CAN frame.
Used by CTRL_BCAST and EVT_n only. Slot B controlId == 0x0000 signals an empty/padding slot.
Sent every 500 ms by PanelGroup nodes. PanelBridge reads HB_1–HB_63 to track PanelGroup health and populate diagnostics. HB_0 is reserved but not transmitted.
function canIdEcho
TEST_SEQ echo frame ID for node n. Range 0x301-0x33F.
constexpr uint32_t canIdEcho (
uint8_t n
)
function canIdEvt
Input event frame ID for node n. Range 0x201-0x23F.
constexpr uint32_t canIdEvt (
uint8_t n
)
function canIdEvtDir
Directional-input event frame ID for node n. RotaryEncoder DIR mode: payload value is a signed ±1 (int16); the bridge formats it INC /DEC for a DCS-BIOS fixed_step control. Range 0x601-0x63F.
constexpr uint32_t canIdEvtDir (
uint8_t n
)
function canIdEvtRel
Relative-input event frame ID for node n. RotaryEncoder REL mode: payload value is a signed ±step (int16); the bridge formats it %+d for a DCS-BIOS variable_step control. Range 0x501-0x53F.
constexpr uint32_t canIdEvtRel (
uint8_t n
)
function canIdHb
Heartbeat frame ID for node n. Range 0x100-0x13F; n=0 is PanelBridge .
constexpr uint32_t canIdHb (
uint8_t n
)
function canIdReady
Boot-complete READY frame ID for node n. Range 0x401-0x43F.
constexpr uint32_t canIdReady (
uint8_t n
)
The documentation for this class was generated from the following file Firmware/Libraries/CANProtocol/CANProtocol.h