Skip to content

Repository files navigation

MotorController (DRV8304S)

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.

Build (host)

cmake -S . -B build -DMOTORCTRL_TARGET=host
cmake --build build
ctest --test-dir build --output-on-failure

Build (STM32G4 reference)

This 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

Safety Notes (Read First)

  • PWM outputs are forced off on boot and on any fault condition.
  • DRV8304S ENABLE is 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.

Repository Layout

  • include/ public headers
  • src/ implementation
  • tests/ host unit tests
  • docs/ bringup, safety, and assumptions
  • .github/workflows/ CI

Wiring Assumptions (Minimum)

  • SPI: SCLK, SDI, SDO (open-drain), nSCS.
  • ENABLE pin controlled by MCU.
  • nFAULT monitored by MCU.
  • PWM inputs are 6x (INHA/INLA, INHB/INLB, INHC/INLC).

Configuration

Defaults live in:

  • include/config/defaults.h (system-level)
  • include/config/runtime_config.h (operator/runtime)
  • include/config/drv8304_config.h (driver defaults)

Quick Host Simulation

A minimal host app is provided:

./build/motorctrl_host

This is a stub that exercises initialization and a single control tick.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages