# vedderb/bldc architecture

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

- Interactive diagram: https://gitdiagram.com/vedderb/bldc
- Repository: https://github.com/vedderb/bldc

## Overview

VESC is embedded firmware for DC, BLDC, and FOC motor controllers. At boot, main initializes motor control, command handling, and communications; configured applications provide controller inputs, while the motor-control implementation drives the hardware. Commands and configuration are also exposed to external tools, including firmware upload over USB. The tree and excerpts support the boot, application-selection, and FOC paths; many other capabilities are visible only from the file tree or README, so their internal links are omitted rather than inferred.

Main entry points: [`main.c`](https://github.com/vedderb/bldc/blob/master/main.c) (Boot and runtime), [`motor`](https://github.com/vedderb/bldc/tree/master/motor) (Motor interface), [`applications/app.c`](https://github.com/vedderb/bldc/blob/master/applications/app.c) (App selection), [`comm/comm_usb.c`](https://github.com/vedderb/bldc/blob/master/comm/comm_usb.c) (USB transport)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Firmware runtime"]
  node_main["Boot and runtime<br/>[main.c]"]
  node_config["Configuration<br/>[conf_general.c]"]
  node_eeprom["EEPROM storage<br/>[eeprom.c]"]
  node_flash["Flash operations<br/>[flash_helper.c]"]
end

subgraph group_control["Motor control"]
  node_motor_api["Motor interface"]
  node_foc["FOC control<br/>[mcpwm_foc.c]"]
end

subgraph group_interfaces["Inputs and communications"]
  node_commands["Command processing<br/>[commands.c]"]
  node_usb["USB transport<br/>[comm_usb.c]"]
  node_can["CAN transport<br/>[comm_can.c]"]
  node_packet["Packet framing<br/>[packet.c]"]
  node_apps["App selection<br/>[app.c]"]
  node_app_inputs["Controller inputs"]
end

subgraph group_platform["Hardware and sensing"]
  node_encoder["Encoder support<br/>[encoder.c]"]
  node_imu["IMU support"]
  node_hardware["Board hardware"]
  node_stm32_hal["STM32 HAL<br/>[hal]"]
end

subgraph group_extensions["Firmware extensions"]
  node_bms["Battery management<br/>[bms.c]"]
  node_lisp["LispBM extensions"]
end

node_bootloader(("SWD debugger"))
node_vesc_tool(("VESC Tool"))

node_main -->|"initializes"| node_commands
node_main -->|"initializes"| node_motor_api
node_main -->|"initializes"| node_usb
node_main -->|"erases code"| node_flash
node_main -.->|"loads settings"| node_config
node_main -->|"initializes UART app"| node_apps
node_apps -->|"starts selected app"| node_app_inputs
node_motor_api -.->|"delegates control"| node_foc
node_vesc_tool -.->|"uploads firmware"| node_usb
node_bootloader -.->|"enables flashing"| node_main

click node_main "https://github.com/vedderb/bldc/blob/master/main.c"
click node_config "https://github.com/vedderb/bldc/blob/master/conf_general.c"
click node_commands "https://github.com/vedderb/bldc/blob/master/comm/commands.c"
click node_usb "https://github.com/vedderb/bldc/blob/master/comm/comm_usb.c"
click node_can "https://github.com/vedderb/bldc/blob/master/comm/comm_can.c"
click node_packet "https://github.com/vedderb/bldc/blob/master/comm/packet.c"
click node_apps "https://github.com/vedderb/bldc/blob/master/applications/app.c"
click node_app_inputs "https://github.com/vedderb/bldc/tree/master/applications"
click node_motor_api "https://github.com/vedderb/bldc/tree/master/motor"
click node_foc "https://github.com/vedderb/bldc/blob/master/motor/mcpwm_foc.c"
click node_encoder "https://github.com/vedderb/bldc/blob/master/encoder/encoder.c"
click node_imu "https://github.com/vedderb/bldc/tree/master/imu"
click node_hardware "https://github.com/vedderb/bldc/tree/master/hwconf"
click node_stm32_hal "https://github.com/vedderb/bldc/tree/master/ChibiOS_3.0.5/os/hal"
click node_eeprom "https://github.com/vedderb/bldc/blob/master/driver/eeprom.c"
click node_flash "https://github.com/vedderb/bldc/blob/master/flash_helper.c"
click node_bms "https://github.com/vedderb/bldc/blob/master/bms.c"
click node_lisp "https://github.com/vedderb/bldc/blob/master/lispBM/lispif_vesc_extensions.c"

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_main,node_config,node_eeprom,node_flash toneBlue
class node_motor_api,node_foc toneAmber
class node_commands,node_usb,node_can,node_packet,node_apps,node_app_inputs toneMint
class node_encoder,node_imu,node_hardware,node_stm32_hal toneRose
class node_bms,node_lisp,node_bootloader,node_vesc_tool toneIndigo
```

## Components

### Firmware runtime

- [Boot and runtime](https://github.com/vedderb/bldc/blob/master/main.c): `main.c`
- [Configuration](https://github.com/vedderb/bldc/blob/master/conf_general.c): `conf_general.c`
- [EEPROM storage](https://github.com/vedderb/bldc/blob/master/driver/eeprom.c): `driver/eeprom.c`
- [Flash operations](https://github.com/vedderb/bldc/blob/master/flash_helper.c): `flash_helper.c`

### Motor control

- [Motor interface](https://github.com/vedderb/bldc/tree/master/motor): `motor`
- [FOC control](https://github.com/vedderb/bldc/blob/master/motor/mcpwm_foc.c): `motor/mcpwm_foc.c`

### Inputs and communications

- [Command processing](https://github.com/vedderb/bldc/blob/master/comm/commands.c): `comm/commands.c`
- [USB transport](https://github.com/vedderb/bldc/blob/master/comm/comm_usb.c): `comm/comm_usb.c`
- [CAN transport](https://github.com/vedderb/bldc/blob/master/comm/comm_can.c): `comm/comm_can.c`
- [Packet framing](https://github.com/vedderb/bldc/blob/master/comm/packet.c): `comm/packet.c`
- [App selection](https://github.com/vedderb/bldc/blob/master/applications/app.c): `applications/app.c`
- [Controller inputs](https://github.com/vedderb/bldc/tree/master/applications): `applications`

### Hardware and sensing

- [Encoder support](https://github.com/vedderb/bldc/blob/master/encoder/encoder.c): `encoder/encoder.c`
- [IMU support](https://github.com/vedderb/bldc/tree/master/imu): `imu`
- [Board hardware](https://github.com/vedderb/bldc/tree/master/hwconf): `hwconf`
- [STM32 HAL](https://github.com/vedderb/bldc/tree/master/ChibiOS_3.0.5/os/hal): `ChibiOS_3.0.5/os/hal`

### Firmware extensions

- [Battery management](https://github.com/vedderb/bldc/blob/master/bms.c): `bms.c`
- [LispBM extensions](https://github.com/vedderb/bldc/blob/master/lispBM/lispif_vesc_extensions.c): `lispBM/lispif_vesc_extensions.c`

### Other components

- **SWD debugger**
- **VESC Tool**

## Connections

- Boot and runtime → Command processing: initializes (evidence: `main.c`)
- Boot and runtime → Motor interface: initializes (evidence: `main.c`)
- Boot and runtime → USB transport: initializes (evidence: `main.c`)
- Boot and runtime → Flash operations: erases code (evidence: `main.c`)
- Boot and runtime → Configuration: loads settings
- Boot and runtime → App selection: initializes UART app (evidence: `main.c`)
- App selection → Controller inputs: starts selected app (evidence: `applications/app.c`)
- Motor interface → FOC control: delegates control (evidence: `motor/mcpwm_foc.c`)
- VESC Tool → USB transport: uploads firmware
- SWD debugger → Boot and runtime: enables flashing
