|
OpenLcbCLib 1.0 Alpha
OpenSource C Library to create OpenLcb/Lcc Nodes
|
Type definitions and constants for the CAN transport layer. More...
Go to the source code of this file.
Data Structures | |
| struct | can_msg_state_struct |
| struct | can_msg_struct |
| struct | can_main_statemachine_struct |
| struct | can_statemachine_info_struct |
| struct | alias_mapping_struct |
| struct | alias_mapping_info_struct |
| struct | listener_alias_entry_struct |
Macros | |
| #define | USER_DEFINED_CAN_MSG_BUFFER_DEPTH 10 |
| Number of can_msg_t buffers in the pool (can_buffer_store.h). | |
| #define | ALIAS_MAPPING_BUFFER_DEPTH USER_DEFINED_NODE_BUFFER_DEPTH |
| Number of alias_mapping_t slots. Defaults to USER_DEFINED_NODE_BUFFER_DEPTH. | |
| #define | LEN_CAN_FIFO_BUFFER (USER_DEFINED_CAN_MSG_BUFFER_DEPTH + 1) |
| FIFO slot count — one extra slot so head==tail always means empty. | |
| #define | LEN_CAN_BYTE_ARRAY 8 |
| Number of data bytes in a CAN 2.0 frame. | |
| #define | OFFSET_CAN_WITHOUT_DEST_ADDRESS 0 |
| Pass to functions when the CAN payload starts at byte 0 (no destination alias). | |
| #define | OFFSET_CAN_WITH_DEST_ADDRESS 2 |
| Pass to functions when bytes 0-1 carry a destination alias; data starts at byte 2. | |
| #define | CAN_MTI_PCER_WITH_PAYLOAD_FIRST 0x0F16 |
| CAN framing MTI for first frame of segmented PCER-with-payload. | |
| #define | CAN_MTI_PCER_WITH_PAYLOAD_MIDDLE 0x0F15 |
| CAN framing MTI for middle frame of segmented PCER-with-payload. | |
| #define | CAN_MTI_PCER_WITH_PAYLOAD_LAST 0x0F14 |
| CAN framing MTI for last frame of segmented PCER-with-payload. | |
| #define | LISTENER_ALIAS_TABLE_DEPTH (USER_DEFINED_MAX_LISTENERS_PER_TRAIN * USER_DEFINED_TRAIN_NODE_COUNT) |
| Total listener alias table slots across all train nodes. | |
Typedefs | |
| typedef uint8_t | payload_bytes_can_t[LEN_CAN_BYTE_ARRAY] |
| Fixed 8-byte array holding a CAN frame payload. | |
| typedef struct can_msg_state_struct | can_msg_state_t |
| Bit-field tracking allocation status of a can_msg_t buffer. | |
| typedef struct can_msg_struct | can_msg_t |
| Complete CAN 2.0B extended frame: 29-bit identifier + up to 8 data bytes. | |
| typedef can_msg_t | can_msg_array_t[USER_DEFINED_CAN_MSG_BUFFER_DEPTH] |
| Pre-allocated array of can_msg_t buffers, sized USER_DEFINED_CAN_MSG_BUFFER_DEPTH. | |
| typedef struct can_main_statemachine_struct | can_main_statemachine_t |
| Working context for the CAN main state machine. | |
| typedef struct can_statemachine_info_struct | can_statemachine_info_t |
| Context block passed through the CAN state machine on every iteration. | |
| typedef struct alias_mapping_struct | alias_mapping_t |
| One entry in the alias mapping table: a node_id_t / 12-bit alias pair. | |
| typedef struct alias_mapping_info_struct | alias_mapping_info_t |
| Container for all alias_mapping_t entries plus a global duplicate flag. | |
| typedef struct listener_alias_entry_struct | listener_alias_entry_t |
| One entry in the listener alias table: a node_id_t / 12-bit alias pair. | |
Type definitions and constants for the CAN transport layer.
Defines can_msg_t, alias_mapping_t, alias_mapping_info_t, can_statemachine_info_t, listener_alias_entry_t, and all compile-time constants shared across the CAN driver modules. No executable code — types and macros only.
| #define USER_DEFINED_CAN_MSG_BUFFER_DEPTH 10 |
Number of can_msg_t buffers in the pool (can_buffer_store.h).
Override at compile time: -D USER_DEFINED_CAN_MSG_BUFFER_DEPTH=20
| #define ALIAS_MAPPING_BUFFER_DEPTH USER_DEFINED_NODE_BUFFER_DEPTH |
Number of alias_mapping_t slots. Defaults to USER_DEFINED_NODE_BUFFER_DEPTH.
| #define LEN_CAN_FIFO_BUFFER (USER_DEFINED_CAN_MSG_BUFFER_DEPTH + 1) |
FIFO slot count — one extra slot so head==tail always means empty.
| #define LEN_CAN_BYTE_ARRAY 8 |
Number of data bytes in a CAN 2.0 frame.
| #define OFFSET_CAN_WITHOUT_DEST_ADDRESS 0 |
Pass to functions when the CAN payload starts at byte 0 (no destination alias).
| #define OFFSET_CAN_WITH_DEST_ADDRESS 2 |
Pass to functions when bytes 0-1 carry a destination alias; data starts at byte 2.
| #define CAN_MTI_PCER_WITH_PAYLOAD_FIRST 0x0F16 |
CAN framing MTI for first frame of segmented PCER-with-payload.
| #define CAN_MTI_PCER_WITH_PAYLOAD_MIDDLE 0x0F15 |
CAN framing MTI for middle frame of segmented PCER-with-payload.
| #define CAN_MTI_PCER_WITH_PAYLOAD_LAST 0x0F14 |
CAN framing MTI for last frame of segmented PCER-with-payload.
| #define LISTENER_ALIAS_TABLE_DEPTH (USER_DEFINED_MAX_LISTENERS_PER_TRAIN * USER_DEFINED_TRAIN_NODE_COUNT) |
Total listener alias table slots across all train nodes.
| typedef uint8_t payload_bytes_can_t[LEN_CAN_BYTE_ARRAY] |
Fixed 8-byte array holding a CAN frame payload.
| typedef struct can_msg_state_struct can_msg_state_t |
Bit-field tracking allocation status of a can_msg_t buffer.
| typedef struct can_msg_struct can_msg_t |
Complete CAN 2.0B extended frame: 29-bit identifier + up to 8 data bytes.
| typedef can_msg_t can_msg_array_t[USER_DEFINED_CAN_MSG_BUFFER_DEPTH] |
Pre-allocated array of can_msg_t buffers, sized USER_DEFINED_CAN_MSG_BUFFER_DEPTH.
| typedef struct can_main_statemachine_struct can_main_statemachine_t |
Working context for the CAN main state machine.
| typedef struct can_statemachine_info_struct can_statemachine_info_t |
Context block passed through the CAN state machine on every iteration.
Carries the current node pointer, a statically-allocated login frame buffer, a pointer to an outgoing frame from the pool, and control flags. The login buffer is always valid; outgoing_can_msg is NULL when no message is pending.
| typedef struct alias_mapping_struct alias_mapping_t |
One entry in the alias mapping table: a node_id_t / 12-bit alias pair.
Flags may be set from interrupt context and read from the main loop. Use lock/unlock around accesses shared between contexts.
| typedef struct alias_mapping_info_struct alias_mapping_info_t |
Container for all alias_mapping_t entries plus a global duplicate flag.
has_duplicate_alias is a fast-check flag: when set, at least one entry has is_duplicate set and the main loop should scan the list to find and resolve it.
| typedef struct listener_alias_entry_struct listener_alias_entry_t |
One entry in the listener alias table: a node_id_t / 12-bit alias pair.
Written by the CAN RX interrupt (AMD arrival) and read by the CAN TX main thread (alias resolution). Protected by the existing lock_shared_resources / unlock_shared_resources mechanism.
Copyright (c) 2026 Jim Kueneman all rights reserved. See the License