# ckflight/ckflight-h7 architecture

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

- Interactive diagram: https://gitdiagram.com/ckflight/ckflight-h7
- Repository: https://github.com/ckflight/ckflight-h7

## Overview

CKFLIGHT H7 is bare-metal STM32H743 flight-controller firmware. Its principal workflow initializes board hardware and enabled peripherals, then runs a deterministic loop that samples receiver and motion inputs, computes control outputs, drives motors, and updates telemetry, OSD, and logging. The README also documents navigation, sensor options, USB/MSP configuration, and fault handling. The excerpts show only parts of the loop and selected implementations; dashed, uncited links mark documented capabilities whose call sites were not shown.

Main entry points: [`Core/Src/main.c`](https://github.com/ckflight/ckflight-h7/blob/main/Core/Src/main.c) (Firmware loop), [`Core/Inc/FLIGHT/CK_MIXER.c`](https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/FLIGHT/CK_MIXER.c) (Motor mixer), [`Core/Inc/MOTION/CK_GYRO.c`](https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/MOTION/CK_GYRO.c) (Gyroscope), [`Core/Inc/COMMUNICATION/USBD_CDC/CK_USBD_INTERFACE.c`](https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/COMMUNICATION/USBD_CDC/CK_USBD_INTERFACE.c) (USB CDC)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Real-time control"]
  node_mainloop["Firmware loop<br/>[main.c]"]
  node_receiver["Receiver input<br/>[CK_RECEIVER.c]"]
  node_rc["RC processing<br/>[CK_RC.c]"]
  node_adjust["Adjustments<br/>[CK_ADJUSTMENT.c]"]
  node_pid["PID control<br/>[CK_PID.c]"]
  node_mixer["Motor mixer<br/>[CK_MIXER.c]"]
  node_esc["ESC output<br/>[CK_ESC.c]"]
  node_failsafe["Failsafe / landing<br/>[CK_LAND.c]"]
  node_fault["Fault handler<br/>[CK_FAULTHANDLER.c]"]
end

subgraph group_sensing["Sensors and navigation"]
  node_imu["IMU fusion<br/>[CK_IMU.c]"]
  node_gyro["Gyroscope<br/>[CK_GYRO.c]"]
  node_acc["Accelerometer<br/>[CK_ACC.c]"]
  node_gps["GPS navigation<br/>[CK_GPS.c]"]
  node_altitude["Altitude sensing<br/>[CK_ALTITUDE.c]"]
  node_navigation["Navigation control<br/>[CK_NAVIGATION.c]"]
  node_sensorchip["Sensor drivers<br/>[CK_ICM42688P.c]"]
end

subgraph group_io["Communications and display"]
  node_usb["USB CDC"]
  node_msp["MSP protocol<br/>[CK_MSP.c]"]
  node_printer["Telemetry printer<br/>[CK_PRINTER.c]"]
  node_osd["OSD rendering<br/>[CK_OSD.c]"]
  node_osdchip["MAX7456 display<br/>[CK_MAX7456.c]"]
end

subgraph group_hardware["Hardware and persistence"]
  node_logger["Flight logging<br/>[CK_LOG.c]"]
  node_card[("SD card storage<br/>[CK_MICROCARD.c]")]
  node_boardio["Peripheral drivers<br/>[CK_SPI.c]"]
end

node_pilot(("Pilot / RC"))

node_pilot -.->|"sends input"| node_receiver
node_mainloop -->|"updates"| node_receiver
node_mainloop -->|"updates"| node_rc
node_mainloop -->|"updates"| node_adjust
node_mainloop -->|"updates"| node_gyro
node_mainloop -->|"updates"| node_acc
node_mainloop -->|"runs control"| node_pid
node_mainloop -->|"updates"| node_mixer
node_mainloop -->|"updates"| node_osd
node_mainloop -->|"updates"| node_logger
node_pid -.->|"sets output"| node_mixer
node_mixer -.->|"drives motors"| node_esc
node_gyro -->|"provides motion data"| node_imu
node_acc -->|"provides motion data"| node_imu
node_sensorchip -->|"supplies readings"| node_gyro
node_mainloop -.->|"estimates attitude"| node_imu
node_mainloop -.->|"uses GPS"| node_gps
node_mainloop -.->|"uses barometer"| node_altitude
node_mainloop -.->|"runs navigation"| node_navigation
node_mainloop -.->|"handles failsafe"| node_failsafe
node_usb -->|"carries protocol"| node_msp
node_msp -->|"writes responses"| node_usb
node_mainloop -.->|"services USB"| node_usb
node_mainloop -.->|"emits telemetry"| node_printer
node_osd -->|"renders through"| node_osdchip
node_mainloop -.->|"logs to storage"| node_card
node_logger -.->|"writes flight data"| node_card
node_boardio -->|"communicates with"| node_sensorchip
node_fault -->|"stops motors"| node_esc

click node_mainloop "https://github.com/ckflight/ckflight-h7/blob/main/Core/Src/main.c"
click node_receiver "https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/FLIGHT/CK_RECEIVER.c"
click node_rc "https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/FLIGHT/CK_RC.c"
click node_adjust "https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/FLIGHT/CK_ADJUSTMENT.c"
click node_pid "https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/FLIGHT/CK_PID.c"
click node_mixer "https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/FLIGHT/CK_MIXER.c"
click node_esc "https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/FLIGHT/CK_ESC.c"
click node_imu "https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/MOTION/CK_IMU.c"
click node_gyro "https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/MOTION/CK_GYRO.c"
click node_acc "https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/MOTION/CK_ACC.c"
click node_gps "https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/FLIGHT/CK_GPS.c"
click node_altitude "https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/FLIGHT/CK_ALTITUDE.c"
click node_navigation "https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/FLIGHT/CK_NAVIGATION.c"
click node_failsafe "https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/FLIGHT/CK_LAND.c"
click node_usb "https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/COMMUNICATION/USBD_CDC/CK_USBD_INTERFACE.c"
click node_msp "https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/COMMUNICATION/CK_MSP.c"
click node_printer "https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/COMMUNICATION/CK_PRINTER.c"
click node_osd "https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/OSD/CK_OSD.c"
click node_osdchip "https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/OSD/CK_MAX7456.c"
click node_logger "https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/FLIGHT/CK_LOG.c"
click node_card "https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/DRIVERS/CK_MICROCARD.c"
click node_boardio "https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/DRIVERS/CK_SPI.c"
click node_sensorchip "https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/SENSORS/CK_ICM42688P.c"
click node_fault "https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/FLIGHT/CK_FAULTHANDLER.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_mainloop,node_receiver,node_rc,node_adjust,node_pid,node_mixer,node_esc,node_failsafe,node_fault toneBlue
class node_imu,node_gyro,node_acc,node_gps,node_altitude,node_navigation,node_sensorchip toneAmber
class node_usb,node_msp,node_printer,node_osd,node_osdchip toneMint
class node_logger,node_card,node_boardio toneRose
class node_pilot toneIndigo
```

## Components

### Real-time control

- [Firmware loop](https://github.com/ckflight/ckflight-h7/blob/main/Core/Src/main.c): `Core/Src/main.c`
- [Receiver input](https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/FLIGHT/CK_RECEIVER.c): `Core/Inc/FLIGHT/CK_RECEIVER.c`
- [RC processing](https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/FLIGHT/CK_RC.c): `Core/Inc/FLIGHT/CK_RC.c`
- [Adjustments](https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/FLIGHT/CK_ADJUSTMENT.c): `Core/Inc/FLIGHT/CK_ADJUSTMENT.c`
- [PID control](https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/FLIGHT/CK_PID.c): `Core/Inc/FLIGHT/CK_PID.c`
- [Motor mixer](https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/FLIGHT/CK_MIXER.c): `Core/Inc/FLIGHT/CK_MIXER.c`
- [ESC output](https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/FLIGHT/CK_ESC.c): `Core/Inc/FLIGHT/CK_ESC.c`
- [Failsafe / landing](https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/FLIGHT/CK_LAND.c): `Core/Inc/FLIGHT/CK_LAND.c`
- [Fault handler](https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/FLIGHT/CK_FAULTHANDLER.c): `Core/Inc/FLIGHT/CK_FAULTHANDLER.c`

### Sensors and navigation

- [IMU fusion](https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/MOTION/CK_IMU.c): `Core/Inc/MOTION/CK_IMU.c`
- [Gyroscope](https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/MOTION/CK_GYRO.c): `Core/Inc/MOTION/CK_GYRO.c`
- [Accelerometer](https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/MOTION/CK_ACC.c): `Core/Inc/MOTION/CK_ACC.c`
- [GPS navigation](https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/FLIGHT/CK_GPS.c): `Core/Inc/FLIGHT/CK_GPS.c`
- [Altitude sensing](https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/FLIGHT/CK_ALTITUDE.c): `Core/Inc/FLIGHT/CK_ALTITUDE.c`
- [Navigation control](https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/FLIGHT/CK_NAVIGATION.c): `Core/Inc/FLIGHT/CK_NAVIGATION.c`
- [Sensor drivers](https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/SENSORS/CK_ICM42688P.c): `Core/Inc/SENSORS/CK_ICM42688P.c`

### Communications and display

- [USB CDC](https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/COMMUNICATION/USBD_CDC/CK_USBD_INTERFACE.c): `Core/Inc/COMMUNICATION/USBD_CDC/CK_USBD_INTERFACE.c`
- [MSP protocol](https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/COMMUNICATION/CK_MSP.c): `Core/Inc/COMMUNICATION/CK_MSP.c`
- [Telemetry printer](https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/COMMUNICATION/CK_PRINTER.c): `Core/Inc/COMMUNICATION/CK_PRINTER.c`
- [OSD rendering](https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/OSD/CK_OSD.c): `Core/Inc/OSD/CK_OSD.c`
- [MAX7456 display](https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/OSD/CK_MAX7456.c): `Core/Inc/OSD/CK_MAX7456.c`

### Hardware and persistence

- [Flight logging](https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/FLIGHT/CK_LOG.c): `Core/Inc/FLIGHT/CK_LOG.c`
- [SD card storage](https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/DRIVERS/CK_MICROCARD.c): `Core/Inc/DRIVERS/CK_MICROCARD.c`
- [Peripheral drivers](https://github.com/ckflight/ckflight-h7/blob/main/Core/Inc/DRIVERS/CK_SPI.c): `Core/Inc/DRIVERS/CK_SPI.c`

### Other components

- **Pilot / RC**

## Connections

- Pilot / RC → Receiver input: sends input
- Firmware loop → Receiver input: updates (evidence: `Core/Src/main.c`)
- Firmware loop → RC processing: updates (evidence: `Core/Src/main.c`)
- Firmware loop → Adjustments: updates (evidence: `Core/Src/main.c`)
- Firmware loop → Gyroscope: updates (evidence: `Core/Src/main.c`)
- Firmware loop → Accelerometer: updates (evidence: `Core/Src/main.c`)
- Firmware loop → PID control: runs control (evidence: `Core/Src/main.c`)
- Firmware loop → Motor mixer: updates (evidence: `Core/Src/main.c`)
- Firmware loop → OSD rendering: updates (evidence: `Core/Src/main.c`)
- Firmware loop → Flight logging: updates (evidence: `Core/Src/main.c`)
- PID control → Motor mixer: sets output
- Motor mixer → ESC output: drives motors
- Gyroscope → IMU fusion: provides motion data (evidence: `Core/Inc/MOTION/CK_IMU.c`)
- Accelerometer → IMU fusion: provides motion data (evidence: `Core/Inc/MOTION/CK_IMU.c`)
- Sensor drivers → Gyroscope: supplies readings (evidence: `Core/Inc/SENSORS/CK_ICM42688P.c`)
- Firmware loop → IMU fusion: estimates attitude
- Firmware loop → GPS navigation: uses GPS
- Firmware loop → Altitude sensing: uses barometer
- Firmware loop → Navigation control: runs navigation
- Firmware loop → Failsafe / landing: handles failsafe
- USB CDC → MSP protocol: carries protocol (evidence: `Core/Inc/COMMUNICATION/CK_MSP.c`)
- MSP protocol → USB CDC: writes responses (evidence: `Core/Inc/COMMUNICATION/CK_MSP.c`)
- Firmware loop → USB CDC: services USB
- Firmware loop → Telemetry printer: emits telemetry
- OSD rendering → MAX7456 display: renders through (evidence: `Core/Inc/OSD/CK_MAX7456.c`)
- Firmware loop → SD card storage: logs to storage
- Flight logging → SD card storage: writes flight data
- Peripheral drivers → Sensor drivers: communicates with (evidence: `Core/Inc/SENSORS/CK_ICM42688P.c`)
- Fault handler → ESC output: stops motors (evidence: `Core/Inc/FLIGHT/CK_FAULTHANDLER.c`)
