# notfastenuf/nfe_silverware architecture

> Architecture diagram of the GitHub repository notfastenuf/nfe_silverware, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/notfastenuf/nfe_silverware
- Repository: https://github.com/notfastenuf/nfe_silverware

## Overview

##### Project type and purpose
- This is an embedded firmware project (“SilverWare – BoldClash BWHOOP B-03 version”) targeting an STM32F0 microcontroller on a micro-quadcopter flight controller board (Bwhoop/E011/H8mini).
- Purpose: read sensors (IMU), decode RC input, run control loops (PID, filters), drive motors (PWM/DShot), manage features (arming, failsafe, telemetry), and expose configuration and telemetry interfaces (BLE, serial).

##### File structure
- Top-level directories:
- Libraries – CMSIS core headers, ST StdPeriph drivers for all STM32F0 peripherals (GPIO, SPI, I2C, ADC, TIM, USART, etc.)
- Silverware – application code: main.c, control loops, sensor drivers (drv_adc, drv_spi, imu), RC protocols (rx_*.c), motor drivers (drv_pwm, drv_dshot), feature modules (buzzer, gestures, telemetry)
- Utilities – board support files (pin-mapping and configuration for Nucleo, evaluation boards, stm32f0xx_conf.h, system_stm32f0xx.c)
- gcc – alternate build system (Makefile, linker script, flash script)
- bin – prebuilt firmware images
- docs, INSTALL.md, README.md, Makefile, .travis.yml – documentation and CI/build integration

- Key architectural patterns:
- Hardware Abstraction Layer using CMSIS + StdPeriph drivers
- Modular drivers for each peripheral and protocol
- Layered control: sensor acquisition → state estimation/filters → PID control → actuator output
- Compile-time configuration via config.h and pid.c

##### Insights from the README
- Multiple build targets: Keil µVision IDE or GCC/Make
- Configurable hardware selection via config.h
- Gesture-based on-flight reconfiguration (PID tuning, binding, accel calibration)
- Multi-protocol RC support (Bayang, SBUS, DSM, CRSF, etc.) and optional analog AUX channels
- Telemetry output via BLE (“SilverVISE” Android app) or serial passthrough (4-way interface)

##### Detailed coverage
- ConfigModule → compiles into Driver and Control modules
- HAL → consumed by all Drivers
- Build System → codebase → binary
- Avoid over-aggregation; split by function and protocol variation to capture architectural breadth

## Diagram (Mermaid)

```mermaid
graph TB
    %% Hardware & HAL Layer
    subgraph "Hardware & HAL" 
        MCU["STM32F0 Microcontroller"]:::hardware
        HAL["CMSIS + StdPeriph Drivers"]:::software
    end

    %% Drivers Layer
    subgraph "Peripheral Drivers" 
        SD["Sensor Drivers"]:::software
        RC["RC Receiver Protocols"]:::software
        MD["Motor Output Drivers"]:::software
        GC["Gestures & Config Module"]:::software
        TS["Telemetry & Serial Interfaces"]:::software
        UT["Utilities (LED, Buzzer, Failsafe)"]:::software
    end

    %% Control Logic
    subgraph "Control Logic" 
        FLT["Filter Module"]:::software
        PID["PID Controllers"]:::software
        CTL["Core Control Logic"]:::software
    end

    %% Build System
    subgraph "Build System & Toolchain" 
        BM["Makefile (Top-level)"]:::tool
        GCC["GCC/Make & Linker"]:::tool
        KEIL["Keil µVision"]:::tool
        BIN["Binary Image"]:::tool
        STLINK["ST-Link Flash"]:::tool
    end

    %% External Interfaces
    subgraph "External Interfaces" 
        IMU["IMU Sensor (SPI/I²C)"]:::hardware
        ADC_EXT["Battery Voltage ADC"]:::hardware
        RC_HW["RC Receiver"]:::hardware
        ESC["ESC Motors"]:::hardware
        BLE["BLE Module"]:::hardware
        SERIAL_EXT["Serial Host"]:::hardware
    end

    %% Relationships
    IMU -->|raw data| SD
    ADC_EXT -->|voltage| SD
    RC_HW -->|signal| RC
    SD -->|sensor data| FLT
    RC -->|pilot commands| CTL
    FLT -->|filtered state| PID
    PID -->|motor setpoints| CTL
    CTL -->|PWM/DShot commands| MD
    CTL -->|state/volt data| TS
    GC -->|config flags| CTL
    UT -->|failsafe/arming| CTL
    TS -->|telemetry| BLE
    TS -->|serial data| SERIAL_EXT
    MD -->|drive| ESC
    HAL --> SD & RC & MD & UT & TS
    MCU --> HAL
    BM -->|invoke| GCC & KEIL
    GCC & KEIL -->|compile/link| BIN
    BIN -->|flash| STLINK
    STLINK --> MCU

    %% Click Events
    click MCU "https://github.com/notfastenuf/nfe_silverware/tree/master/Libraries/CMSIS/Device/ST/STM32F0xx"
    click HAL "https://github.com/notfastenuf/nfe_silverware/tree/master/Libraries/STM32F0xx_StdPeriph_Driver"
    click SD "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/imu.c"
    click SD "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/drv_adc.c"
    click SD "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/drv_i2c.c"
    click SD "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/drv_hw_i2c.c"
    click SD "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/drv_softi2c.c"
    click SD "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/drv_spi.c"
    click SD "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/drv_spi_3wire.c"
    click SD "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/drv_spi_none.c"
    click RC "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/rx_bayang_protocol.c"
    click RC "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/rx_bayang_protocol_ble.c"
    click RC "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/rx_bayang_protocol_telemetry.c"
    click RC "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/rx_bayang_protocol_telemetry_autobind.c"
    click RC "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/rx_sbus.c"
    click RC "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/rx_dsm.c"
    click RC "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/rx_crsf.c"
    click RC "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/rx_ibus.c"
    click RC "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/rx_cg023_protocol.c"
    click RC "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/rx_cx10blue_protocol.c"
    click RC "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/rx_h7_protocol.c"
    click RC "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/rx_template.c"
    click FLT "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/filter.cpp"
    click PID "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/angle_pid.c"
    click PID "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/pid.c"
    click CTL "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/control.c"
    click MD "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/drv_pwm.c"
    click MD "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/drv_dshot.c"
    click MD "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/drv_dshot_dma.c"
    click MD "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/drv_esc.c"
    click GC "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/gesture_detect.c"
    click GC "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/gestures.c"
    click GC "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/config.h"
    click TS "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/serial_4way.c"
    click TS "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/serial_4way_impl.h"
    click TS "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/serial_4way_avrootloader.c"
    click TS "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/serial_4way_stk500v2.c"
    click TS "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/rx_bayang_ble_app.c"
    click UT "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/buzzer.c"
    click UT "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/led.c"
    click UT "https://github.com/notfastenuf/nfe_silverware/blob/master/Silverware/src/util.c"
    click BM "https://github.com/notfastenuf/nfe_silverware/tree/master/Makefile"
    click GCC "https://github.com/notfastenuf/nfe_silverware/tree/master/gcc/Makefile"
    click GCC "https://github.com/notfastenuf/nfe_silverware/blob/master/gcc/flash.ld"
    click GCC "https://github.com/notfastenuf/nfe_silverware/blob/master/gcc/progStLink.sh"
    click STLINK "https://github.com/notfastenuf/nfe_silverware/blob/master/Utilities/system_stm32f0xx.c"
    click STLINK "https://github.com/notfastenuf/nfe_silverware/blob/master/Utilities/stm32f0xx_conf.h"
    click STLINK "https://github.com/notfastenuf/nfe_silverware/blob/master/Utilities/STM32_Nucleo/stm32f0xx_nucleo.c"
    click STLINK "https://github.com/notfastenuf/nfe_silverware/blob/master/Utilities/STM32_Nucleo/stm32f0xx_nucleo.h"

    %% Styles
    classDef hardware fill:#ADD8E6,stroke:#000
    classDef software fill:#90EE90,stroke:#000
    classDef tool fill:#FFA500,stroke:#000
```
