Kbox-UniStack Docs

Peripheral Interfaces

The dependency-injected I/Base/Hal peripheral contracts that form the portability boundary between the MCU-agnostic core and a concrete platform.

The I / Base / Hal pattern

The stack splits every peripheral into three layers:

  • I<X> — the pure abstract interface. It is what the core depends on: the core holds an I<X>& reference and never knows the concrete type.
  • Base<X> — optional shared logic implemented once, in the core, on top of the interface (queueing, timing, state). You subclass it so you only write the hardware-touching parts.
  • Hal<X> — the concrete platform implementation (register/HAL access). This is the only layer that is platform-specific, and it is documented separately under the STM32 platform section.

This is the portability boundary: the prebuilt core is compiled against the I<X> interfaces only. To bring the stack to a new MCU you implement these interfaces (reusing Base<X> where it exists) — you never touch core source. See Porting to a New Platform.

The interfaces

All headers live under dist/include/Stack/Peripheral/<Name>/.

What the core requires

The core never instantiates a peripheral. You construct the concrete implementations and inject them into the factory. The standard (non-secure) MakeStack takes six of them directly as references, plus a KnxFlashLayout& built from your IFlash& base flash:

IKnxStack& MakeStack(KnxStackStorage& storage, StackParameters& stackParameters,
                     IBusDriver& busDriver, IWatchDog& watchDog, ILed& knxLed,
                     IClock& clock, ITransmitter& transmitter, IButton& button,
                     KnxFlashLayout& layout);

That covers seven peripheral interfaces in total: IBusDriver, IWatchDog, ILed, IClock, ITransmitter, IButton are passed straight through; IFlash is passed indirectly — you construct one IFlash& base flash region and hand it to MakeFlashLayout() first, which returns the KnxFlashLayout& that MakeStack (and, in Secure mode, MakeSecure) actually consume. See Constructing the Stack · MakeFlashLayout. A second MakeStack overload adds an ISecurity& for the KNX Data Secure path.

The stack object itself is placement-new'd into caller-owned static storage (KnxStackStorage) — no heap. See Constructing the Stack.

Next steps