OpenLcbCLib 1.0 Alpha
OpenSource C Library to create OpenLcb/Lcc Nodes
Loading...
Searching...
No Matches
can_main_statemachine.h
Go to the documentation of this file.
1
34// This is a guard condition so that contents of this file are not included
35// more than once.
36#ifndef __DRIVERS_CANBUS_CAN_MAIN_STATEMACHINE__
37#define __DRIVERS_CANBUS_CAN_MAIN_STATEMACHINE__
38
39#include <stdbool.h>
40#include <stdint.h>
41
42#include "can_types.h"
43
44#ifdef __cplusplus
45extern "C" {
46#endif /* __cplusplus */
47
57 typedef struct {
58
60 void (*lock_shared_resources)(void);
61
63 void (*unlock_shared_resources)(void);
64
66 bool (*send_can_message)(can_msg_t *msg);
67
69 openlcb_node_t *(*openlcb_node_get_first)(uint8_t key);
70
72 openlcb_node_t *(*openlcb_node_get_next)(uint8_t key);
73
75 openlcb_node_t *(*openlcb_node_find_by_alias)(uint16_t alias);
76
78 void (*login_statemachine_run)(can_statemachine_info_t *can_statemachine_info);
79
81 alias_mapping_info_t *(*alias_mapping_get_alias_mapping_info)(void);
82
84 void (*alias_mapping_unregister)(uint16_t alias);
85
87 uint8_t (*get_current_tick)(void);
88
90 bool (*handle_duplicate_aliases)(void);
91
93 bool (*handle_outgoing_can_message)(void);
94
96 bool (*handle_login_outgoing_can_message)(void);
97
99 bool (*handle_try_enumerate_first_node)(void);
100
102 bool (*handle_try_enumerate_next_node)(void);
103
105 bool (*handle_listener_verification)(void);
106
108
109
125 extern void CanMainStatemachine_initialize(const interface_can_main_statemachine_t *interface_can_main_statemachine);
126
127
139 extern void CanMainStateMachine_run(void);
140
141
153
154
166
167
178
179
192
193
204
205
216
217
229
230#ifdef __cplusplus
231}
232#endif /* __cplusplus */
233
234#endif /* __DRIVERS_CANBUS_CAN_MAIN_STATEMACHINE__ */
bool CanMainStatemachine_handle_try_enumerate_next_node(void)
Continues enumeration and processes the next node.
Definition can_main_statemachine.c:326
void CanMainStatemachine_initialize(const interface_can_main_statemachine_t *interface_can_main_statemachine)
Registers the dependency-injection interface and prepares internal buffers.
Definition can_main_statemachine.c:84
bool CanMainStatemachine_handle_duplicate_aliases(void)
Scans the alias table, unregisters duplicates, and resets affected nodes.
Definition can_main_statemachine.c:192
can_statemachine_info_t * CanMainStateMachine_get_can_statemachine_info(void)
Returns a pointer to the internal state machine context.
Definition can_main_statemachine.c:178
bool CanMainStatemachine_handle_outgoing_can_message(void)
Pops one message from the outgoing CAN FIFO and attempts transmission.
Definition can_main_statemachine.c:226
void CanMainStateMachine_run(void)
Executes one iteration of the main CAN state machine.
Definition can_main_statemachine.c:406
bool CanMainStatemachine_handle_listener_verification(void)
Probes one listener alias for staleness and queues an AME if due.
Definition can_main_statemachine.c:361
bool CanMainStatemachine_handle_login_outgoing_can_message(void)
Attempts to transmit the pending login frame (CID, RID, or AMD).
Definition can_main_statemachine.c:262
bool CanMainStatemachine_handle_try_enumerate_first_node(void)
Gets the first node and processes it through its appropriate state machine.
Definition can_main_statemachine.c:289
Type definitions and constants for the CAN transport layer.
Definition can_types.h:190
Definition can_types.h:118
Definition can_types.h:155
Dependency-injection interface for the CAN main state machine.
Definition can_main_statemachine.h:57
OpenLCB virtual node.
Definition openlcb_types.h:679

Copyright (c) 2026 Jim Kueneman all rights reserved. See the License