35#ifndef __DRIVERS_CANBUS_CAN_TYPES__
36#define __DRIVERS_CANBUS_CAN_TYPES__
57#ifndef USER_DEFINED_CAN_MSG_BUFFER_DEPTH
58#define USER_DEFINED_CAN_MSG_BUFFER_DEPTH 10
64#ifndef ALIAS_MAPPING_BUFFER_DEPTH
65#define ALIAS_MAPPING_BUFFER_DEPTH USER_DEFINED_NODE_BUFFER_DEPTH
69#define LEN_CAN_FIFO_BUFFER (USER_DEFINED_CAN_MSG_BUFFER_DEPTH + 1)
72#define LEN_CAN_BYTE_ARRAY 8
75#define OFFSET_CAN_WITHOUT_DEST_ADDRESS 0
78#define OFFSET_CAN_WITH_DEST_ADDRESS 2
81#define CAN_MTI_PCER_WITH_PAYLOAD_FIRST 0x0F16
84#define CAN_MTI_PCER_WITH_PAYLOAD_MIDDLE 0x0F15
87#define CAN_MTI_PCER_WITH_PAYLOAD_LAST 0x0F14
196#define LISTENER_ALIAS_TABLE_DEPTH \
197 (USER_DEFINED_MAX_LISTENERS_PER_TRAIN * USER_DEFINED_TRAIN_NODE_COUNT)
struct listener_alias_entry_struct listener_alias_entry_t
One entry in the listener alias table: a node_id_t / 12-bit alias pair.
struct can_msg_state_struct can_msg_state_t
Bit-field tracking allocation status of a can_msg_t buffer.
#define LEN_CAN_BYTE_ARRAY
Number of data bytes in a CAN 2.0 frame.
Definition can_types.h:72
#define ALIAS_MAPPING_BUFFER_DEPTH
Number of alias_mapping_t slots. Defaults to USER_DEFINED_NODE_BUFFER_DEPTH.
Definition can_types.h:65
#define USER_DEFINED_CAN_MSG_BUFFER_DEPTH
Number of can_msg_t buffers in the pool (can_buffer_store.h).
Definition can_types.h:58
struct alias_mapping_struct alias_mapping_t
One entry in the alias mapping table: a node_id_t / 12-bit alias pair.
struct alias_mapping_info_struct alias_mapping_info_t
Container for all alias_mapping_t entries plus a global duplicate flag.
struct can_main_statemachine_struct can_main_statemachine_t
Working context for the CAN main state machine.
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.
Definition can_types.h:131
struct can_msg_struct can_msg_t
Complete CAN 2.0B extended frame: 29-bit identifier + up to 8 data bytes.
struct can_statemachine_info_struct can_statemachine_info_t
Context block passed through the CAN state machine on every iteration.
uint8_t payload_bytes_can_t[LEN_CAN_BYTE_ARRAY]
Fixed 8-byte array holding a CAN frame payload.
Definition can_types.h:96
OpenLCB protocol constants, MTI codes, and memory configuration commands.
Core type definitions, structures, and configuration constants for the OpenLCB library.
uint64_t node_id_t
48-bit Node ID stored in a 64-bit type (upper 16 bits unused).
Definition openlcb_types.h:359
Definition can_types.h:190
bool has_duplicate_alias
True if any entry has is_duplicate set.
Definition can_types.h:192
alias_mapping_t list[ALIAS_MAPPING_BUFFER_DEPTH]
All registered mappings.
Definition can_types.h:191
Definition can_types.h:173
uint8_t is_permitted
Set after successful login (AMD transmitted).
Definition can_types.h:177
uint16_t alias
Temporary 12-bit CAN alias (0x001-0xFFF).
Definition can_types.h:175
node_id_t node_id
Permanent 48-bit Node ID.
Definition can_types.h:174
uint8_t is_duplicate
Set by ISR when another node claims this alias.
Definition can_types.h:176
Definition can_types.h:137
openlcb_statemachine_worker_t * openlcb_worker
OpenLCB layer worker thread context.
Definition can_types.h:138
Definition can_types.h:105
uint8_t allocated
Set while the buffer is owned by the pool allocator.
Definition can_types.h:106
Definition can_types.h:118
can_msg_state_t state
Allocation flags.
Definition can_types.h:119
uint32_t identifier
29-bit extended CAN identifier.
Definition can_types.h:120
uint8_t payload_count
Number of valid bytes in payload (0-8).
Definition can_types.h:121
payload_bytes_can_t payload
Data bytes of the frame.
Definition can_types.h:122
Definition can_types.h:155
uint8_t login_outgoing_can_msg_valid
Set when login_outgoing_can_msg needs transmitting.
Definition can_types.h:158
can_msg_t * login_outgoing_can_msg
Statically-allocated login frame (CID/RID/AMD).
Definition can_types.h:157
can_msg_t * outgoing_can_msg
Pool-allocated reply frame; freed after TX.
Definition can_types.h:159
uint8_t current_tick
Snapshot of the global 100ms tick for login timing.
Definition can_types.h:161
openlcb_node_t * openlcb_node
Node currently being processed.
Definition can_types.h:156
uint8_t enumerating
Set when the handler will produce N reply frames.
Definition can_types.h:160
Definition can_types.h:209
uint16_t alias
Resolved CAN alias (0 = not yet resolved).
Definition can_types.h:212
node_id_t node_id
Listener Node ID (from protocol layer attach). 0 = unused.
Definition can_types.h:211
uint8_t verify_pending
AME sent, awaiting AMD reply.
Definition can_types.h:214
uint16_t verify_ticks
Tick snapshot when last probed or confirmed.
Definition can_types.h:213
OpenLCB virtual node.
Definition openlcb_types.h:679
State machine temporary working buffers.
Definition openlcb_types.h:705