OpenLcbCLib 1.0 Alpha
OpenSource C Library to create OpenLcb/Lcc Nodes
Loading...
Searching...
No Matches
openlcb_config.c File Reference

Library-internal wiring module for config facade. More...

Functions

uint8_t OpenLcb_get_global_100ms_tick (void)
 Returns the current value of the global 100ms tick counter.
 
void OpenLcb_initialize (const openlcb_config_t *config)
 Initializes the entire OpenLCB stack from the user configuration.
 
openlcb_node_tOpenLcb_create_node (node_id_t node_id, const node_parameters_t *parameters)
 Allocates a node slot and assigns its ID and parameters.
 
void OpenLcb_run (void)
 Runs one iteration of all state machines and periodic services.
 
void OpenLcb_100ms_timer_tick (void)
 Increments the global 100ms tick counter. This is the ONLY action performed by the timer interrupt — all real work runs in the main loop.
 

Detailed Description

Library-internal wiring module for config facade.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Reads from openlcb_config_t and compile-time feature guards (OPENLCB_COMPILE_*), builds internal interface structs, and calls all Module_initialize() functions in the correct order.

Author
Jim Kueneman
Date
4 Mar 2026

Function Documentation

◆ OpenLcb_get_global_100ms_tick()

uint8_t OpenLcb_get_global_100ms_tick ( void )

Returns the current value of the global 100ms tick counter.

Used by wiring code (openlcb_config.c, can_config.c) to read the clock and inject it into modules via parameters or interface function pointers. Individual modules should NOT call this directly — they receive the tick through their function parameters or interface.

Returns
Current tick count (wraps at 255).

◆ OpenLcb_initialize()

void OpenLcb_initialize ( const openlcb_config_t * config)

Initializes the entire OpenLCB stack from the user configuration.

Initializes the entire OpenLCB stack with one call.

Algorithm:

  1. Store config pointer
  2. Initialize buffer infrastructure (store, list, FIFO)
  3. Build all internal interface structs from user config and compile flags
  4. Initialize all compiled-in protocol modules in dependency order
* @param config Pointer to the @ref openlcb_config_t to use
* 

◆ OpenLcb_create_node()

openlcb_node_t * OpenLcb_create_node ( node_id_t node_id,
const node_parameters_t * parameters )

Allocates a node slot and assigns its ID and parameters.

Allocates and registers a new node on the OpenLCB network.

* @param node_id     Unique 48-bit @ref node_id_t for the new node
* @param parameters  Pointer to @ref node_parameters_t (SNIP, protocol flags, events)
* 
Returns
Pointer to the allocated openlcb_node_t, or NULL if no slots available

◆ OpenLcb_run()

void OpenLcb_run ( void )

Runs one iteration of all state machines and periodic services.

Runs one iteration of all state machines.

◆ OpenLcb_100ms_timer_tick()

void OpenLcb_100ms_timer_tick ( void )

Increments the global 100ms tick counter. This is the ONLY action performed by the timer interrupt — all real work runs in the main loop.

Increments the global 100ms tick counter.


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