# atessahin/stm32-flight-controller-freertos architecture

> Architecture diagram of the GitHub repository atessahin/stm32-flight-controller-freertos, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/atessahin/stm32-flight-controller-freertos
- Repository: https://github.com/atessahin/stm32-flight-controller-freertos

## Overview

This firmware polls motion and barometric data, estimates attitude, and displays telemetry on an STM32F4. The documented runtime is a high-priority 250 Hz sensor task feeding a fusion task and then a slower display task; `main.c` creates those tasks and their queues. Source paths identify a BMP280 driver, while the README calls the barometer BME280, so the graph uses the implementation’s name. The sampled excerpts do not show all task timing and filtering details; those documented capabilities are represented at the task level.

Main entry points: [`Core/Src/main.c`](https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/main.c) (Task orchestration), [`Core/Src/drivers/i2c_bus.c`](https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/drivers/i2c_bus.c) (Bare-metal I2C), [`Core/Src/drivers/mpu6050.c`](https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/drivers/mpu6050.c) (MPU6050 driver), [`Core/Src/drivers/bmp280.c`](https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/drivers/bmp280.c) (BMP280 driver)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime workflow"]
  node_main["Task orchestration<br/>[main.c]"]
  node_sensor_task["Sensor task<br/>[main.c]"]
  node_raw_queue["Raw data queue<br/>[main.c]"]
  node_fusion_task["Fusion task<br/>[main.c]"]
  node_flight_core["Attitude estimation<br/>[flight_core.c]"]
  node_display_queue["Display queue<br/>[main.c]"]
end

subgraph group_sensors["Sensor acquisition"]
  node_mpu_driver["MPU6050 driver<br/>[mpu6050.c]"]
  node_bmp_driver["BMP280 driver<br/>[bmp280.c]"]
end

subgraph group_hardware["Board and bus"]
  node_i2c_bus["Bare-metal I2C<br/>[i2c_bus.c]"]
  node_i2c_mutex["I2C mutex<br/>[main.c]"]
  node_board_init["Board initialization<br/>[board_init.c]"]
  node_system_clock["Clock configuration<br/>[system_clock.c]"]
end

subgraph group_output["Telemetry output"]
  node_display_task["Display task<br/>[main.c]"]
  node_oled_driver["SSD1306 driver<br/>[ssd1306.c]"]
end

node_operator(("Flight controller user"))
node_imu(("MPU6050 IMU"))
node_barometer(("BMP280 barometer"))
node_oled(("OLED screen"))

node_operator -->|"starts firmware"| node_main
node_main -->|"initializes board"| node_board_init
node_board_init -->|"configures clock"| node_system_clock
node_main -->|"creates task"| node_sensor_task
node_main -->|"creates task"| node_fusion_task
node_main -->|"creates task"| node_display_task
node_main -->|"creates queue"| node_raw_queue
node_main -->|"creates queue"| node_display_queue
node_main -->|"creates mutex"| node_i2c_mutex
node_sensor_task -->|"locks bus"| node_i2c_mutex
node_display_task -->|"locks bus"| node_i2c_mutex
node_sensor_task -->|"reads motion"| node_mpu_driver
node_sensor_task -->|"reads altitude"| node_bmp_driver
node_mpu_driver -->|"reads registers"| node_i2c_bus
node_bmp_driver -->|"reads registers"| node_i2c_bus
node_i2c_bus -->|"communicates"| node_imu
node_i2c_bus -->|"communicates"| node_barometer
node_sensor_task -->|"sends samples"| node_raw_queue
node_raw_queue -->|"delivers samples"| node_fusion_task
node_fusion_task -->|"updates attitude"| node_flight_core
node_fusion_task -->|"sends estimate"| node_display_queue
node_display_queue -->|"delivers telemetry"| node_display_task
node_display_task -->|"renders telemetry"| node_oled_driver
node_oled_driver -->|"writes display"| node_i2c_bus
node_i2c_bus -->|"communicates"| node_oled

click node_main "https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/main.c"
click node_sensor_task "https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/main.c"
click node_raw_queue "https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/main.c"
click node_fusion_task "https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/main.c"
click node_flight_core "https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/flight_core.c"
click node_display_queue "https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/main.c"
click node_display_task "https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/main.c"
click node_mpu_driver "https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/drivers/mpu6050.c"
click node_bmp_driver "https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/drivers/bmp280.c"
click node_i2c_bus "https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/drivers/i2c_bus.c"
click node_i2c_mutex "https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/main.c"
click node_board_init "https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/board/board_init.c"
click node_system_clock "https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/board/system_clock.c"
click node_oled_driver "https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/ssd1306.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_sensor_task,node_raw_queue,node_fusion_task,node_flight_core,node_display_queue,node_operator,node_oled toneBlue
class node_mpu_driver,node_bmp_driver toneAmber
class node_i2c_bus,node_i2c_mutex,node_board_init,node_system_clock toneMint
class node_display_task,node_oled_driver toneRose
class node_imu,node_barometer toneIndigo
```

## Components

### Runtime workflow

- [Task orchestration](https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/main.c): `Core/Src/main.c`
- [Sensor task](https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/main.c): `Core/Src/main.c`
- [Raw data queue](https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/main.c): `Core/Src/main.c`
- [Fusion task](https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/main.c): `Core/Src/main.c`
- [Attitude estimation](https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/flight_core.c): `Core/Src/flight_core.c`
- [Display queue](https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/main.c): `Core/Src/main.c`

### Sensor acquisition

- [MPU6050 driver](https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/drivers/mpu6050.c): `Core/Src/drivers/mpu6050.c`
- [BMP280 driver](https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/drivers/bmp280.c): `Core/Src/drivers/bmp280.c`

### Board and bus

- [Bare-metal I2C](https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/drivers/i2c_bus.c): `Core/Src/drivers/i2c_bus.c`
- [I2C mutex](https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/main.c): `Core/Src/main.c`
- [Board initialization](https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/board/board_init.c): `Core/Src/board/board_init.c`
- [Clock configuration](https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/board/system_clock.c): `Core/Src/board/system_clock.c`

### Telemetry output

- [Display task](https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/main.c): `Core/Src/main.c`
- [SSD1306 driver](https://github.com/atessahin/stm32-flight-controller-freertos/blob/main/Core/Src/ssd1306.c): `Core/Src/ssd1306.c`

### Other components

- **Flight controller user**
- **MPU6050 IMU**
- **BMP280 barometer**
- **OLED screen**

## Connections

- Flight controller user → Task orchestration: starts firmware
- Task orchestration → Board initialization: initializes board
- Board initialization → Clock configuration: configures clock
- Task orchestration → Sensor task: creates task
- Task orchestration → Fusion task: creates task
- Task orchestration → Display task: creates task
- Task orchestration → Raw data queue: creates queue
- Task orchestration → Display queue: creates queue
- Task orchestration → I2C mutex: creates mutex
- Sensor task → I2C mutex: locks bus
- Display task → I2C mutex: locks bus
- Sensor task → MPU6050 driver: reads motion
- Sensor task → BMP280 driver: reads altitude
- MPU6050 driver → Bare-metal I2C: reads registers
- BMP280 driver → Bare-metal I2C: reads registers
- Bare-metal I2C → MPU6050 IMU: communicates
- Bare-metal I2C → BMP280 barometer: communicates
- Sensor task → Raw data queue: sends samples
- Raw data queue → Fusion task: delivers samples
- Fusion task → Attitude estimation: updates attitude
- Fusion task → Display queue: sends estimate
- Display queue → Display task: delivers telemetry
- Display task → SSD1306 driver: renders telemetry
- SSD1306 driver → Bare-metal I2C: writes display
- Bare-metal I2C → OLED screen: communicates
