# am32-firmware/am32 architecture

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

- Interactive diagram: https://gitdiagram.com/am32-firmware/am32
- Repository: https://github.com/am32-firmware/am32

## Overview

AM32 is embedded ESC firmware for brushless motors, with MCU-specific hardware support and a shared control application. The principal workflow is that a flight controller or configurator supplies throttle/control input; the firmware processes it and drives the motor, while ESC telemetry can be returned. The README also documents firmware updating, crawler-oriented builds, and multiple input protocols. The shared entry point and target configuration are identified in source excerpts; many feature-specific implementation links are based on documented capabilities because their source was not sampled.

Main entry points: [`Src/main.c`](https://github.com/am32-firmware/am32/blob/main/Src/main.c) (ESC firmware), [`Src/dshot.c`](https://github.com/am32-firmware/am32/blob/main/Src/dshot.c) (DShot protocol), [`Mcu`](https://github.com/am32-firmware/am32/tree/main/Mcu) (Servo PWM input), [`Src/DroneCAN/DroneCAN.c`](https://github.com/am32-firmware/am32/blob/main/Src/DroneCAN/DroneCAN.c) (DroneCAN support)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Firmware control"]
  node_firmware["ESC firmware<br/>[main.c]"]
  node_motor_control["Motor control<br/>[main.c]"]
  node_startup["Sinusoidal startup<br/>[main.c]"]
  node_pwm_frequency["PWM frequency<br/>[main.c]"]
  node_crawler["Crawler support"]
end

subgraph group_protocols["Control and telemetry"]
  node_dshot["DShot protocol<br/>[dshot.c]"]
  node_servo_pwm["Servo PWM input"]
  node_telemetry["KISS telemetry"]
  node_dronecan["DroneCAN support<br/>[DroneCAN.c]"]
end

subgraph group_hardware["MCU hardware"]
  node_peripherals["MCU peripherals<br/>[peripherals.c]"]
  node_adc["ADC sampling<br/>[ADC.c]"]
  node_comparator["Commutation sensing<br/>[comparator.c]"]
  node_phaseouts["Phase outputs<br/>[phaseouts.c]"]
end

subgraph group_configuration["Configuration and updates"]
  node_target_config["Target configuration<br/>[targets.h]"]
  node_serial_update["Serial update"]
  node_passthrough_update["Passthrough update"]
  node_arduino_update["Arduino update"]
  node_eeprom[("Settings storage<br/>[eeprom.c]")]
end

node_flight_controller(("Flight controller"))
node_configurator(("Configurator"))
node_motor(("Brushless motor"))

node_flight_controller -->|"sends DShot"| node_dshot
node_flight_controller -->|"sends servo PWM"| node_servo_pwm
node_dshot -->|"provides input"| node_firmware
node_servo_pwm -->|"provides input"| node_firmware
node_firmware -->|"controls"| node_motor_control
node_motor_control -->|"drives"| node_motor
node_firmware -->|"supports startup"| node_startup
node_firmware -->|"varies frequency"| node_pwm_frequency
node_firmware -->|"provides telemetry"| node_telemetry
node_telemetry -->|"reports ESC data"| node_flight_controller
node_firmware -.->|"initializes peripherals"| node_peripherals
node_firmware -.->|"uses target settings"| node_target_config
node_firmware -.->|"samples inputs"| node_adc
node_firmware -.->|"uses commutation sensing"| node_comparator
node_firmware -.->|"controls phases"| node_phaseouts
node_firmware -.->|"loads settings"| node_eeprom
node_configurator -->|"updates firmware"| node_passthrough_update
node_configurator -->|"updates firmware"| node_serial_update
node_configurator -->|"updates firmware"| node_arduino_update
node_passthrough_update -->|"installs firmware"| node_firmware
node_serial_update -->|"installs firmware"| node_firmware
node_arduino_update -->|"installs firmware"| node_firmware
node_firmware -.->|"supports CAN"| node_dronecan
node_firmware -->|"supports crawler builds"| node_crawler

click node_firmware "https://github.com/am32-firmware/am32/blob/main/Src/main.c"
click node_target_config "https://github.com/am32-firmware/am32/blob/main/Inc/targets.h"
click node_dshot "https://github.com/am32-firmware/am32/blob/main/Src/dshot.c"
click node_servo_pwm "https://github.com/am32-firmware/am32/tree/main/Mcu"
click node_telemetry "https://github.com/am32-firmware/am32/tree/main/Mcu"
click node_serial_update "https://github.com/am32-firmware/am32/tree/main/Mcu"
click node_passthrough_update "https://github.com/am32-firmware/am32/tree/main/Mcu"
click node_arduino_update "https://github.com/am32-firmware/am32/tree/main/Mcu"
click node_motor_control "https://github.com/am32-firmware/am32/blob/main/Src/main.c"
click node_startup "https://github.com/am32-firmware/am32/blob/main/Src/main.c"
click node_pwm_frequency "https://github.com/am32-firmware/am32/blob/main/Src/main.c"
click node_peripherals "https://github.com/am32-firmware/am32/blob/main/Mcu/f051/Src/peripherals.c"
click node_adc "https://github.com/am32-firmware/am32/blob/main/Mcu/f051/Src/ADC.c"
click node_comparator "https://github.com/am32-firmware/am32/blob/main/Mcu/f051/Src/comparator.c"
click node_phaseouts "https://github.com/am32-firmware/am32/blob/main/Mcu/f051/Src/phaseouts.c"
click node_eeprom "https://github.com/am32-firmware/am32/blob/main/Mcu/f051/Src/eeprom.c"
click node_dronecan "https://github.com/am32-firmware/am32/blob/main/Src/DroneCAN/DroneCAN.c"
click node_crawler "https://github.com/am32-firmware/am32/tree/main/Mcu"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_firmware,node_motor_control,node_startup,node_pwm_frequency,node_crawler toneBlue
class node_dshot,node_servo_pwm,node_telemetry,node_dronecan toneAmber
class node_peripherals,node_adc,node_comparator,node_phaseouts toneMint
class node_target_config,node_serial_update,node_passthrough_update,node_arduino_update,node_eeprom toneRose
class node_flight_controller,node_configurator,node_motor toneIndigo
```

## Components

### Firmware control

- [ESC firmware](https://github.com/am32-firmware/am32/blob/main/Src/main.c): `Src/main.c`
- [Motor control](https://github.com/am32-firmware/am32/blob/main/Src/main.c): `Src/main.c`
- [Sinusoidal startup](https://github.com/am32-firmware/am32/blob/main/Src/main.c): `Src/main.c`
- [PWM frequency](https://github.com/am32-firmware/am32/blob/main/Src/main.c): `Src/main.c`
- [Crawler support](https://github.com/am32-firmware/am32/tree/main/Mcu): `Mcu`

### Control and telemetry

- [DShot protocol](https://github.com/am32-firmware/am32/blob/main/Src/dshot.c): `Src/dshot.c`
- [Servo PWM input](https://github.com/am32-firmware/am32/tree/main/Mcu): `Mcu`
- [KISS telemetry](https://github.com/am32-firmware/am32/tree/main/Mcu): `Mcu`
- [DroneCAN support](https://github.com/am32-firmware/am32/blob/main/Src/DroneCAN/DroneCAN.c): `Src/DroneCAN/DroneCAN.c`

### MCU hardware

- [MCU peripherals](https://github.com/am32-firmware/am32/blob/main/Mcu/f051/Src/peripherals.c): `Mcu/f051/Src/peripherals.c`
- [ADC sampling](https://github.com/am32-firmware/am32/blob/main/Mcu/f051/Src/ADC.c): `Mcu/f051/Src/ADC.c`
- [Commutation sensing](https://github.com/am32-firmware/am32/blob/main/Mcu/f051/Src/comparator.c): `Mcu/f051/Src/comparator.c`
- [Phase outputs](https://github.com/am32-firmware/am32/blob/main/Mcu/f051/Src/phaseouts.c): `Mcu/f051/Src/phaseouts.c`

### Configuration and updates

- [Target configuration](https://github.com/am32-firmware/am32/blob/main/Inc/targets.h): `Inc/targets.h`
- [Serial update](https://github.com/am32-firmware/am32/tree/main/Mcu): `Mcu`
- [Passthrough update](https://github.com/am32-firmware/am32/tree/main/Mcu): `Mcu`
- [Arduino update](https://github.com/am32-firmware/am32/tree/main/Mcu): `Mcu`
- [Settings storage](https://github.com/am32-firmware/am32/blob/main/Mcu/f051/Src/eeprom.c): `Mcu/f051/Src/eeprom.c`

### Other components

- **Flight controller**
- **Configurator**
- **Brushless motor**

## Connections

- Flight controller → DShot protocol: sends DShot
- Flight controller → Servo PWM input: sends servo PWM
- DShot protocol → ESC firmware: provides input
- Servo PWM input → ESC firmware: provides input (evidence: `Src/main.c`)
- ESC firmware → Motor control: controls (evidence: `Src/main.c`)
- Motor control → Brushless motor: drives
- ESC firmware → Sinusoidal startup: supports startup (evidence: `Src/main.c`)
- ESC firmware → PWM frequency: varies frequency (evidence: `Src/main.c`)
- ESC firmware → KISS telemetry: provides telemetry (evidence: `Src/main.c`)
- KISS telemetry → Flight controller: reports ESC data
- ESC firmware → MCU peripherals: initializes peripherals
- ESC firmware → Target configuration: uses target settings (evidence: `Src/main.c`)
- ESC firmware → ADC sampling: samples inputs
- ESC firmware → Commutation sensing: uses commutation sensing
- ESC firmware → Phase outputs: controls phases
- ESC firmware → Settings storage: loads settings
- Configurator → Passthrough update: updates firmware
- Configurator → Serial update: updates firmware
- Configurator → Arduino update: updates firmware
- Passthrough update → ESC firmware: installs firmware (evidence: `Src/main.c`)
- Serial update → ESC firmware: installs firmware (evidence: `Src/main.c`)
- Arduino update → ESC firmware: installs firmware (evidence: `Src/main.c`)
- ESC firmware → DroneCAN support: supports CAN
- ESC firmware → Crawler support: supports crawler builds (evidence: `Src/main.c`)
