Safety-first embedded firmware scaffold for a BLDC motor controller using the TI DRV8304S SPI gate driver. The repo is structured for deterministic control, explicit fault handling, and host-based unit tests.
cmake -S . -B build -DMOTORCTRL_TARGET=host
cmake --build build
ctest --test-dir build --output-on-failureThis repo includes STM32G4 HAL stubs. Replace src/hal/stm32g4 with real STM32 HAL/LL implementations.
cmake -S . -B build -DMOTORCTRL_TARGET=stm32g4
cmake --build build- PWM outputs are forced off on boot and on any fault condition.
- DRV8304S
ENABLEis driven low on faults to enter sleep. - Do not change DRV8304 PWM mode while switching. The driver enforces this.
- SDO is open-drain and requires an external pullup (5.1 kΩ recommended).
See docs/safety.md and docs/bringup.md.
include/public headerssrc/implementationtests/host unit testsdocs/bringup, safety, and assumptions.github/workflows/CI
- SPI:
SCLK,SDI,SDO(open-drain),nSCS. ENABLEpin controlled by MCU.nFAULTmonitored by MCU.- PWM inputs are 6x (INHA/INLA, INHB/INLB, INHC/INLC).
Defaults live in:
include/config/defaults.h(system-level)include/config/runtime_config.h(operator/runtime)include/config/drv8304_config.h(driver defaults)
A minimal host app is provided:
./build/motorctrl_hostThis is a stub that exercises initialization and a single control tick.