Applied engineering
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
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.
§BFramework: state machine
sc_sm — the door FSM used in its testsThe 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.
§CComposition: the worked example
examples/control_loop.c — a room-temperature loopOne 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.
§DSize
A proxy for surface area. Every LLR has an implementation tag and at least one test; all are at 100% MC/DC.