How lyallulric/stacked-smolslime works
Project type and purpose
• This is an embedded firmware project built on the Zephyr RTOS.
• It targets various Nordic nRF boards (nRF52840, nRF52833, etc.) and implements sensor reading, sensor-fusion algorithms (Motionsense, VQF, XioFusion), and a connection layer (ESB radio or RTT console) to forward data.
High-level layers / top-level components
A. Hardware (Board & Sensors)
B. Zephyr RTOS (Kernel + HAL)
C. Firmware Application
1. System Services
2. Sensor Subsystem
3. Fusion Engine
4. Connection / Communication
5. Utilities
Detailed breakdown of components
A. Hardware layer
• Microcontroller (nRF52840, nRF5340, etc.)
• On-board peripherals (I²C, SPI, GPIO)
• External sensors:
– IMUs (LSM6DSM, ICM42688, BMI270, etc.)
– Magnetometers (BMM150, AK09940, MMC5983MA, etc.)
• LEDs, battery monitor, power management
B. Zephyr RTOS
• Kernel scheduler, device driver framework
• HAL/drivers auto-generated via DTS and board overlays
• Kconfig-based configuration (prj.conf + board_defconfig)
C. Application layer
1. System Services (src/system)
– power.c / battery.c / led.c / status.c
– Manages power states, LED indications, status logs
2. Sensor Subsystem (src/sensor)
– interface.c / scan.c / scan_spi.c
– Sensor “drivers” organized by category: imu/, mag/, magneto/
– Exposes uniform API to read raw sensor data
3. Fusion Engine (src/sensor/fusion)
• motionsense/
• vqf/
• xiofusion/
– Each folder implements one fusion algorithm, consuming raw accel/gyro/mag and producing orientation estimates
4. Connection / Communication (src/connection)
– esb.c / esb.h: Nordic ESB radio protocol to send packets wirelessly
– timer.c: scheduling radio transmissions
– console.c / rtt_console.h: SWO or RTT logging to host
5. Utilities (src/util.c)
– common helper routines, macros, data conversions
Data-flow and interactions
• Raw data path:
Hardware Sensors → Zephyr device drivers (I²C/SPI) → Sensor Subsystem → Fusion Engine → Connection layer → Host
• Control/config path:
Kconfig & DTS → Zephyr build system → Generated firmware image → Flash to board
• System monitoring:
System Services ↔ Hardware (battery, LEDs)
System Services → Console
Architectural patterns & design principles
• Layered architecture (hardware abstraction via Zephyr)
• Modular C code: separation into connection, sensor, fusion, system subfolders
• Plugin-style fusion engines: interchangeable modules selected at compile-time via Kconfig
• Board-agnostic code: board definitions, overlays, and DTS files isolate hardware specifics