dal-c library

Applied engineering

Architecture

How the fifteen components depend on each other, the framework pieces (sc_sm the state-machine engine, sc_sched the cyclic scheduler, sc_pid the controller), and how the worked example wires six of them into one loop.

§ADependency graph

What builds on what

Ten components are leaf primitives with no dal-c dependency. sc_sat is the saturating-arithmetic base that three others build on; sc_fixed in turn underpins sc_pid. Nothing depends on anything outside the standard headers.

sc_sat sc_fixed sc_ratelimit sc_lut sc_pid sc_crc sc_hysteresis sc_debounce sc_ringbuf sc_sm no dal-c dependency base

§BFramework: state machine

sc_sm — the door FSM used in its tests

The engine holds one uint16_t state id. The caller supplies a flat transition table; sc_sm_dispatch does a bounded scan for the first (from, event) match, runs the row's action, and moves. Below is the exact machine from test_sc_sm.c.

CLOSED OPENING OPEN CLOSING OPEN / fwd DONE / stop CLOSE / rev DONE / stop CLOSE / rev initial

§CComposition: the worked example

examples/control_loop.c — a room-temperature loop

One raw sensor sample per cycle is buffered, averaged, and fed two ways: to a heat-demand lamp (sc_hysteresis) and to the controller. The command runs through the PID, then a slew limit, then the simulated plant. Each cycle's status bytes are checksummed.

sensor sc_ringbuf mean sc_hysteresis sc_pid sc_ratelimit heater sc_crc32 plant feedback

§DSize

Low-level requirements per component

A proxy for surface area. Every LLR has an implementation tag and at least one test; all are at 100% MC/DC.

sc_fixed21
sc_ratelimit18
sc_pid16
sc_vote14
sc_cobs13
sc_hysteresis12
sc_ringbuf12
sc_watchdog12
sc_median11
sc_sm11
sc_lut10
sc_debounce9
sc_sched9
sc_crc8
sc_sat6