How arjun-sadananda/temp works
1. Project type and runtime
- This is bare-metal embedded firmware for an STM32H743-class MCU, not an app/server.
- The repo is clearly a drone flight controller stack: it ingests sensors and radio control, estimates attitude/state, runs control loops, and drives motors.
2. Repo boundary: generated platform code vs application logic
- Core/ and Drivers/ are the hardware abstraction and startup layer, mostly STM32CubeMX-generated.
- Hardware/ and Modules/ are the application-specific flight stack.
- main.cpp in Core/Src is the top-level orchestration point that ties the generated peripherals to the drone logic.
3. Platform bring-up
- startup_stm32h743xx.s, STM32H743XX_FLASH.ld, and system_stm32h7xx.c define boot, memory layout, and system clock/runtime setup.
- Core/Src/stm32h7xx_hal_msp.c, gpio.c, spi.c, tim.c, usart.c, dma.c initialize the MCU peripherals used by the application.
- stm32h7xx_it.c handles interrupt entry points, so the firmware is interrupt- and DMA-driven rather than polling-only.
4. Peripheral roles in the architecture
- SPI is used for sensor communication, especially the IMU.
- USART is used for serial links such as CRSF radio control and likely debugging/telemetry.
- TIM + DMA are used for time-critical motor signaling, which matches the presence of DSHOT.
- GPIO provides chip selects, mode pins, and other discrete control lines.
5. Sensor hardware subsystem
- Hardware/IMU/icm426xx.* is a device driver for the ICM426xx IMU family.
- Hardware/OptFlow/mtf01.* is an optical-flow sensor interface.
- These modules are the primary state-input sources for estimation and stabilization.
6. Radio/command input subsystem
- Hardware/RC/crsf.* implements the CRSF protocol over serial.
- Hardware/RC/rc.* likely normalizes incoming radio channels into internal control inputs.
- This is the manual command path into the control system.
7. Motor output subsystem
- Hardware/Motor/dshot.* is the ESC output protocol layer.
- Hardware/Motor/motor.* is the higher-level motor mixer/actuator interface.
- Hardware/Motor/dump.c suggests diagnostics or captured motor-output/debug data.
- The output path is therefore abstracted: control code produces throttle/mixer commands, and the motor layer turns them into DSHOT waveform timing.
8. Estimation subsystem
- Modules/Estimator/Estimator.h and MEKF.h indicate the main estimator is a multiplicative extended Kalman filter.
- This module fuses IMU and possibly optical-flow inputs into attitude/state estimates.
- The estimator is the bridge between raw sensors and the controller layer.
9. Control subsystem
- Modules/Controller/ contains multiple control modes: Acro, Euler_Stabilize, Geometric_Stabilize, and TP_Control.
- This implies the firmware supports at least rate/acro control plus stabilized flight modes.
- The controller consumes pilot commands plus estimated state and produces desired body rates/attitude/motor corrections.
10. Math and signal-processing support
- Modules/Math/ provides vector, matrix, quaternion, and rotation primitives used by estimation and control.
- Modules/filter.c / filter.h provide additional signal conditioning.
- These are core reusable utilities, not hardware-specific code.
11. Application data flow
- Input path: IMU / optical flow / RC enter through hardware drivers and MCU peripherals.
- Processing path: estimator fuses sensor data, control law computes actuation commands, mixer maps commands to motors.
- Output path: motor module emits DSHOT over timer/DMA to the ESCs.
- Interrupts and DMA likely feed timing-sensitive acquisition/output, while main.cpp coordinates the higher-level loop.
12. Build and configuration tooling
- The project uses CMake (CMakeLists.txt, CMakePresets.json, cmake/gcc-arm-none-eabi.cmake, cmake/stm32cubemx/), so the firmware is built outside the IDE as well.
- The .ioc files show STM32CubeMX-generated configuration sources the platform layer was derived from.
- The repo also vendors STM32 HAL, CMSIS, CMSIS-DSP, and CMSIS-NN packages under Drivers/, which form the hardware and DSP foundation.
13. External/library boundaries
- STM32 HAL/CMSIS provide peripheral drivers, startup, and device headers; the flight logic stays above that boundary.
- CMSIS-DSP and CMSIS-NN are present in-tree, but the visible application code is more centered on classical flight-control math than on neural inference.
- No web, cloud, or OS service boundary is visible; this is an embedded real-time control system running directly on the MCU.
Main entry points: stm32h7xx_hal_msp.c msp init · main.cpp main · Acro.h controller · Estimator.h estimator
Components 23
Platform
MCU startup, HAL, interrupts, and peripheral setup
- main · Top-level firmware entry that wires peripherals into the flight stack
Core/Src/main.cpp - startup · Reset entry and flash memory layout
startup_stm32h743xx.s - system · System clock and low-level runtime setup
Core/Src/system_stm32h7xx.c - msp init · MCU-specific peripheral pin and clock initialization
Core/Src/stm32h7xx_hal_msp.c - interrupts · Interrupt entry points for timing- and DMA-driven operation
Core/Src/stm32h7xx_it.c - SPI · Serial bus used for sensor communication
Core/Src/spi.c - USART · Serial links for radio control and telemetry/debug
Core/Src/usart.c - TIM/DMA · Timer and DMA channels used for time-critical output and capture
Core/Src/tim.c - GPIO · Discrete control lines such as chip selects and modes
Core/Src/gpio.c
Hardware I/O
Device drivers for sensors, radio, and motors
- IMU · ICM426xx inertial sensor driver and interface
Hardware/IMU/imu.cpp - icm426xx · ICM426xx-family register-level driver
Hardware/IMU/icm426xx.cpp - opt flow · Optical-flow sensor interface
Hardware/OptFlow/mtf01.c - CRSF · Serial radio-control protocol implementation
Hardware/RC/crsf.c - RC input · Normalizes received radio channels into internal commands
Hardware/RC/rc.c - DSHOT · ESC protocol and waveform generation layer
Hardware/Motor/dshot.c - motors · High-level motor command and mixing interface
Hardware/Motor/motor.c
Flight Logic
Estimation and control layers for the drone
- MEKF · Multiplicative EKF fusing sensors into attitude/state estimates
Modules/Estimator/MEKF.h - estimator · Estimation interface between raw sensors and control
Modules/Estimator/Estimator.h - controller · Flight-mode control layer producing stabilization and rate commands
Modules/Controller/Acro.h
Support
Reusable math and signal-processing code
Connections 25
- startup → system: boot init · Startup transfers into system/runtime initialization
- system → msp init: runtime setup · System setup precedes peripheral bring-up
- msp init → SPI: configures · HAL board init configures SPI peripheral
- msp init → USART: configures · HAL board init configures USART peripheral
- msp init → TIM/DMA: configures · HAL board init configures timer/DMA for time-critical I/O
- msp init → GPIO: configures · HAL board init configures GPIO lines
- interrupts → SPI: services · Interrupts service SPI/DMA-driven sensor traffic
- interrupts → TIM/DMA: services · Interrupts service timer/DMA-driven output timing
- main → IMU: reads · Main orchestration consumes IMU data
- IMU → icm426xx: implements · IMU module is backed by the ICM426xx driver
- main → opt flow: reads · Main orchestration can consume optical-flow data
- main → CRSF: receives · Main orchestration receives radio-control frames
- CRSF → RC input: normalizes · CRSF frames are mapped into internal RC channels
- main → estimator: feeds · Sensor inputs are passed into the estimator
- estimator → MEKF: implements · Estimator interface centers on a MEKF state filter
- estimator → math: uses · State fusion relies on math primitives
- controller → math: uses · Flight control computations rely on math primitives
- controller → filter: uses · Controller uses filtering/conditioning utilities
- estimator → controller: state to control · Estimated state informs the control layer
- RC input → controller: pilot commands · Normalized radio commands drive the controller
- controller → motors: actuation · Controller outputs are mapped to motor commands
- motors → DSHOT: encodes · Motor layer encodes ESC commands as DSHOT
- DSHOT → TIM/DMA: emits · DSHOT waveform generation uses timer/DMA timing
- main → cmake: built by · Firmware is built through the CMake toolchain
- CubeMX → msp init: generates · CubeMX configuration underlies platform initialization