How berknylm/embedlink works
1. What this repo is
EmbedLink is an STM32 embedded firmware stack built around RTOS-compatible serial communication and background processing of sensor/GPS data. The codebase is centered on a quadcopter/robotics use case: reading hardware sensors, estimating state, running control modes, and exposing communication links for configuration/telemetry.
2. Top-level layering
The repository is organized in a clear hardware-to-application stack:
- Src/Hal: MCU peripheral abstraction
- Lib: vendor chip libraries for specific sensors/radios/GPS parsers
- Src/Drivers: device-facing drivers that wrap the libraries into uniform subsystem APIs
- Src/Modules: reusable functional building blocks like ESC, RC, battery, LEDs, telemetry
- Src/Application: quadcopter-specific coordination, control modes, and communication logic
- Src/Codex: shared math, event, queue, stream, and navigation utilities plus the program entry point
3. Hardware abstraction boundary
Src/Hal contains the low-level interfaces for GPIO, I2C, SPI, UART, USB, ADC, PWM, IRQ, and RTOS integration. This is the boundary between the firmware and the STM32 peripherals. Everything above this layer depends on these abstractions rather than talking to registers directly.
4. Device libraries and sensor support
Lib/ contains chip-specific implementations for common embedded parts: IMUs (bmi08, bno055, icm20948, mpu6500), barometers (bmp3, bmp5, ms5611, icp20100), GPS/NMEA/UBlox, radio (rf24), and power sensing (ina219). These are not the application logic; they are the vendor/protocol-level drivers consumed by the higher layers.
5. Unified driver layer
Src/Drivers normalizes those vendor libraries into subsystem interfaces:
- Sensor: specific sensor adapters such as BMI088, BMP388/BMP581, BNO055, HMC5883L, ICM20948, ICP20100, MPU6500
- Navigator: GPS-focused adapters for Neo-M8N and ZED-F9P
- Estimator: complementary and Kalman-filter-based state estimation
- Telemetry: radio transport adapters for RF24 and RF52
- Memory: persistent storage, including external EEPROM support
This layer is where heterogeneous hardware gets converted into a consistent internal API.
6. State estimation and navigation flow
Sensor data and navigation data are processed in the estimator/navigation path. The presence of estimator_cf and estimator_kf, plus navigation, kinematics, and math utilities in Src/Codex, indicates a pipeline that turns raw sensor/GPS samples into fused attitude, position, velocity, and related kinematic state. This is one of the core architectural flows in the repo.
7. Flight/control application layer
Src/Application/QMode contains control strategies:
- control_attitude
- control_height
- control_navigation
- quadmode
This is the decision layer that turns estimated state and operator commands into control outputs. It is quadcopter-specific and sits above the generic drivers/estimator stack.
8. Vehicle coordination and configuration
Src/Application/quadcopter.*, quadcal.*, and quadconfig.h appear to hold vehicle-level orchestration, calibration, and compile-time tuning. This layer likely binds together sensors, estimation, RC input, mode selection, and output mixing for the actual aircraft configuration.
9. Operator communication and command handling
Src/Application/QCom (rccom, uavcom, uavexe) is the command/communication interface used for serial exchange with external tools or controllers. Combined with the README’s emphasis on serial communication, this is likely the primary user-facing control boundary for configuration, diagnostics, and command execution.
10. Reusable runtime/core utilities
Src/Codex is a shared utility/runtime layer containing:
- event, queue, list, and stream primitives
- matrix and math types/functions
- kinematics and navigation helpers
- executer and main
This looks like the framework core that underpins asynchronous processing, message passing, and math-heavy computations.
11. Support modules for the platform
Src/Modules contains operational subsystems that are not directly part of the flight control loop but are essential to the product:
- Battery monitoring
- Esc motor output
- RC receiver interface
- Signal LEDs and LED sequencing
- Debug timing/watch utilities
- Northlib internal communication/protocol support
These modules connect the high-level vehicle logic to real-world peripherals and user feedback.
12. Main data paths to draw
The most important architecture flows are:
- Sensors/GPS → Drivers → Estimator/Navigation → QMode control → ESC/PWM
- RC / serial commands → QCom / RC modules → mode selection and parameters
- Telemetry/USB/UART → external host or radio link
- Battery/diagnostics → signaling and safety-related behavior
These are the paths most worth highlighting in a diagram.
13. Concurrency and runtime
The repository is explicitly RTOS-aware, so the system is likely split into background tasks or event-driven loops rather than a single blocking control loop. The presence of queues, events, streams, IRQ handling, and separate subsystem modules suggests asynchronous acquisition, estimation, communication, and actuation.
14. How to frame the architecture
For diagramming, treat this repo as an embedded UAV firmware platform with four vertical slices: hardware abstraction, device drivers, core computation, and application/control logic. The key boundary is between reusable platform code and the quadcopter-specific application layer, with telemetry/RC/serial forming the external interaction boundary.
Main entry points: quadcopter.c Quadcopter · gpio.c HAL IO · ublox.c GPS & radio · sensor.c Sensor drv
Components 22
HAL
MCU peripheral and RTOS boundary
- HAL IO · GPIO, UART, SPI, I2C, ADC, PWM, USB, IRQ, and RTOS-facing peripheral layer
Src/Hal/gpio.c
Libraries
Vendor sensor, radio, and protocol code
- IMU libs · Raw device libraries for inertial sensors and motion chips
Lib/bmi08/bmi08a.c - Baro libs · Pressure and altitude sensor libraries
Lib/bmp3/bmp3.c - GPS & radio · NMEA/Ublox GPS parsing plus RF24 radio support
Lib/ublox/ublox.c - Power libs · Power sensing and other peripheral vendor drivers
Lib/ina219/ina219.c
Drivers
Unified hardware adapters
- Sensor drv · Normalizes IMU, barometer, and compass hardware into subsystem sensor APIs
Src/Drivers/Sensor/sensor.c - Navigator drv · GPS receiver adapters and navigation input normalization
Src/Drivers/Navigator/navigator.c - Estimator drv · Complementary and Kalman estimation wrappers
Src/Drivers/Estimator/estimator.c - Telemetry drv · Radio transport adapters for telemetry links
Src/Drivers/Telemetry/telemetry.c - Memory drv · Persistent storage and external EEPROM support
Src/Drivers/Memory/memory.c
Core
Shared runtime, math, and program entry
- Entry point · Program entry and top-level boot orchestration
Src/Codex/main.c - Executer · Asynchronous task and message execution core
Src/Codex/executer.c - Math core · Matrices, kinematics, and navigation support functions
Src/Codex/kinematics.c - Events · Events, queues, lists, and streams used for background processing
Src/Codex/xevent.c
Modules
Reusable platform subsystems
- RC module · Radio control receiver interface and signal handling
Src/Modules/RC/rc_interface.c - ESC module · Motor/ESC actuation layer
Src/Modules/Esc/esc.c - Battery · Battery sensing and power-state monitoring
Src/Modules/Battery/battery.c - Signals · LEDs and blink sequencing for user feedback
Src/Modules/Signal/ledseq.c - Northlib · Internal communication and protocol support utilities
Src/Modules/Northlib/northcom.c
Application
Quadcopter-specific coordination and control
- Quadcopter · Vehicle-level integration, calibration, and configuration
Src/Application/quadcopter.c - QMode · Attitude, height, and navigation control strategies
Src/Application/QMode/quadmode.c - QCom · Serial command, configuration, and operator communication
Src/Application/QCom/uavcom.c
Connections 22
- Entry point → Executer: starts runtime · Boot entry hands control to the background execution core
- Executer → Quadcopter: orchestrates · Runtime dispatch drives the vehicle application
- HAL IO → IMU libs: bus access · Vendor sensor libraries depend on MCU peripheral access
- HAL IO → Baro libs: bus access · Pressure sensors are accessed through HAL buses
- HAL IO → GPS & radio: serial/spi · GPS and radio libraries use UART/SPI and timing support
- HAL IO → Power libs: i2c/adc · Power sensing libraries rely on HAL peripherals
- IMU libs → Sensor drv: feeds · Raw IMU libraries are wrapped by sensor adapters
- Baro libs → Sensor drv: feeds · Barometer libraries are wrapped by sensor adapters
- GPS & radio → Navigator drv: feeds · GPS parsing and receiver libraries feed navigation adapters
- GPS & radio → Telemetry drv: feeds · Radio protocol code supports telemetry transport
- Sensor drv → Estimator drv: state input · Sensor outputs are consumed by state estimation
- Navigator drv → Math core: navigation data · GPS/navigation information flows into shared math and kinematics
- Math core → Estimator drv: fusion math · Kinematics and math utilities support estimation
- Estimator drv → QMode: estimated state · Fused attitude and motion state drives control modes
- RC module → QCom: operator input · Receiver input and command handling meet at the communication boundary
- QCom → Quadcopter: configures · Command interface configures and controls the vehicle layer
- Quadcopter → QMode: selects mode · Vehicle orchestration selects and wires active control mode
- QMode → ESC module: actuates · Control outputs are converted to motor/ESC commands
- Battery → Quadcopter: safety input · Battery state influences vehicle orchestration and safety behavior
- Signals → Quadcopter: status output · LED signaling reflects system and flight status
- Northlib → QCom: internal protocol · Northlib provides shared communication plumbing for the command layer
- Memory drv → Quadcopter: persistent state · Stored parameters and calibration data support the vehicle layer