# sergegrin/grin_fly_sky architecture

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

- Interactive diagram: https://gitdiagram.com/sergegrin/grin_fly_sky
- Repository: https://github.com/sergegrin/grin_fly_sky

## Overview

This is firmware for the FlySky FS-i6 transmitter. The principal workflow is: radio input and model settings feed transmitter runtime logic, which emits the selected PPM, internal A7105/AFHDS, or external CRSF/ExpressLRS output; telemetry and configuration return through the display and menus. Other documented capabilities include model persistence, telemetry screens, and DFPlayer voice output. Edges reflect README statements and SOURCE INDEX references; unsampled protocol and runtime details are represented at subsystem level where the tree supports them.

Main entry points: [`Sources/menus.cpp`](https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/menus.cpp) (Setup and telemetry menus), [`Sources/er9x.cpp`](https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/er9x.cpp) (Transmitter core), [`Sources/crossfire/crossfire.cpp`](https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/crossfire/crossfire.cpp) (CRSF link and telemetry), [`Sources/pulses.cpp`](https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/pulses.cpp) (Pulse generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_platform["Radio platform"]
  node_board["FS-i6 board I/O<br/>[BoardI6.cpp]"]
  node_drivers["Peripheral drivers<br/>[drivers.cpp]"]
  node_device["MKL16Z4 device definitions<br/>[MKL16Z4.h]"]
  node_features["Device feature definitions<br/>[MKL16Z4_features.h]"]
  node_cmsis["Cortex-M0+ core support<br/>[core_cm0plus.h]"]
  node_cmsis_gcc["CMSIS GCC intrinsics<br/>[cmsis_gcc.h]"]
  node_device_registers["Device register selection"]
  node_system["Clock and system setup<br/>[system_MKL16Z4.c]"]
  node_startup["Cortex-M startup<br/>[startup_MKL16Z4.c]"]
end

subgraph group_runtime["Transmitter runtime"]
  node_main["Firmware entry<br/>[main.cpp]"]
  node_core["Transmitter core<br/>[er9x.cpp]"]
  node_pulses["Pulse generation<br/>[pulses.cpp]"]
  node_templates["Model templates<br/>[templates.cpp]"]
end

subgraph group_protocols["RF and telemetry"]
  node_internal_rf["A7105 RF interface<br/>[A7105_SPI.cpp]"]
  node_afhds["AFHDS protocol<br/>[AFHDS.cpp]"]
  node_afhds2a["AFHDS2A protocol<br/>[AFHDS2A_a7105.cpp]"]
  node_crsf["CRSF link and telemetry<br/>[crossfire.cpp]"]
  node_crc["CRSF CRC<br/>[crc_crsf.cpp]"]
end

subgraph group_interface["User interface"]
  node_menus["Setup and telemetry menus<br/>[menus.cpp]"]
  node_display["LCD rendering<br/>[lcd.cpp]"]
  node_elrs["ExpressLRS setup menu<br/>[elrs.cpp]"]
end

subgraph group_services["Persistence and audio"]
  node_storage[("Model and radio storage<br/>[pers.cpp]")]
  node_file["EEPROM file access<br/>[file.cpp]"]
  node_audio["Audio and voice<br/>[audio.cpp]"]
end

node_user(("Radio operator"))
node_dfplayer["DFPlayer voice module"]
node_elrs_module["External ExpressLRS TX"]
node_internal_module["Internal A7105 module"]

node_user -->|"operates"| node_menus
node_main -->|"starts"| node_core
node_core -->|"dispatches"| node_menus
node_core -->|"uses"| node_pulses
node_core -->|"updates"| node_display
node_core -->|"triggers"| node_audio
node_menus -->|"renders"| node_display
node_menus -->|"uses"| node_templates
node_menus -->|"configures"| node_pulses
node_menus -->|"opens"| node_elrs
node_board -->|"dispatches"| node_crsf
node_board -->|"provides I/O"| node_pulses
node_board -->|"provides I/O"| node_internal_rf
node_drivers -->|"supports"| node_pulses
node_drivers -->|"supports"| node_audio
node_pulses -.->|"drives"| node_internal_rf
node_internal_rf -.->|"supports"| node_afhds
node_internal_rf -->|"supports"| node_afhds2a
node_pulses -.->|"drives"| node_crsf
node_crsf -->|"exchanges frames"| node_elrs_module
node_crsf -->|"checks frames"| node_crc
node_elrs -->|"sends configuration"| node_crsf
node_crsf -->|"provides telemetry"| node_menus
node_internal_rf -->|"controls"| node_internal_module
node_core -->|"loads settings"| node_storage
node_storage -->|"uses"| node_file
node_audio -->|"drives UART"| node_dfplayer
node_device_registers -->|"selects"| node_device
node_device_registers -->|"includes"| node_features
node_device -->|"includes core"| node_cmsis
node_cmsis -->|"uses intrinsics"| node_cmsis_gcc
node_system -->|"configures"| node_device
node_startup -.->|"initializes system"| node_system
node_board -.->|"uses registers"| node_device

click node_main "https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/main.cpp"
click node_core "https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/er9x.cpp"
click node_menus "https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/menus.cpp"
click node_display "https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/lcd.cpp"
click node_board "https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/I6/BoardI6.cpp"
click node_drivers "https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/drivers.cpp"
click node_device "https://github.com/sergegrin/grin_fly_sky/blob/main/CMSIS_4/CMSIS/Include/MKL16Z4.h"
click node_features "https://github.com/sergegrin/grin_fly_sky/blob/main/CMSIS_4/CMSIS/Include/MKL16Z4_features.h"
click node_cmsis "https://github.com/sergegrin/grin_fly_sky/blob/main/CMSIS_4/CMSIS/Include/core_cm0plus.h"
click node_cmsis_gcc "https://github.com/sergegrin/grin_fly_sky/blob/main/CMSIS_4/CMSIS/Include/cmsis_gcc.h"
click node_device_registers "https://github.com/sergegrin/grin_fly_sky/blob/main/CMSIS_4/CMSIS/Include/fsl_device_registers.h"
click node_system "https://github.com/sergegrin/grin_fly_sky/blob/main/Kinetis_KL/CMSIS/Device/Source/system_MKL16Z4.c"
click node_startup "https://github.com/sergegrin/grin_fly_sky/blob/main/gcc/startup_MKL16Z4.c"
click node_pulses "https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/pulses.cpp"
click node_templates "https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/templates.cpp"
click node_internal_rf "https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/A7105_SPI.cpp"
click node_afhds "https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/AFHDS.cpp"
click node_afhds2a "https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/AFHDS2A_a7105.cpp"
click node_crsf "https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/crossfire/crossfire.cpp"
click node_crc "https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/crossfire/crc_crsf.cpp"
click node_elrs "https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/crossfire/elrs.cpp"
click node_storage "https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/pers.cpp"
click node_file "https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/file.cpp"
click node_audio "https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/audio.cpp"

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_board,node_drivers,node_device,node_features,node_cmsis,node_cmsis_gcc,node_device_registers,node_system,node_startup toneBlue
class node_main,node_core,node_pulses,node_templates toneAmber
class node_internal_rf,node_afhds,node_afhds2a,node_crsf,node_crc toneMint
class node_menus,node_display,node_elrs toneRose
class node_storage,node_file,node_audio,node_user,node_dfplayer,node_elrs_module,node_internal_module toneIndigo
```

## Components

### Radio platform

- [FS-i6 board I/O](https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/I6/BoardI6.cpp): `Sources/I6/BoardI6.cpp`
- [Peripheral drivers](https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/drivers.cpp): `Sources/drivers.cpp`
- [MKL16Z4 device definitions](https://github.com/sergegrin/grin_fly_sky/blob/main/CMSIS_4/CMSIS/Include/MKL16Z4.h): `CMSIS_4/CMSIS/Include/MKL16Z4.h`
- [Device feature definitions](https://github.com/sergegrin/grin_fly_sky/blob/main/CMSIS_4/CMSIS/Include/MKL16Z4_features.h): `CMSIS_4/CMSIS/Include/MKL16Z4_features.h`
- [Cortex-M0+ core support](https://github.com/sergegrin/grin_fly_sky/blob/main/CMSIS_4/CMSIS/Include/core_cm0plus.h): `CMSIS_4/CMSIS/Include/core_cm0plus.h`
- [CMSIS GCC intrinsics](https://github.com/sergegrin/grin_fly_sky/blob/main/CMSIS_4/CMSIS/Include/cmsis_gcc.h): `CMSIS_4/CMSIS/Include/cmsis_gcc.h`
- [Device register selection](https://github.com/sergegrin/grin_fly_sky/blob/main/CMSIS_4/CMSIS/Include/fsl_device_registers.h): `CMSIS_4/CMSIS/Include/fsl_device_registers.h`
- [Clock and system setup](https://github.com/sergegrin/grin_fly_sky/blob/main/Kinetis_KL/CMSIS/Device/Source/system_MKL16Z4.c): `Kinetis_KL/CMSIS/Device/Source/system_MKL16Z4.c`
- [Cortex-M startup](https://github.com/sergegrin/grin_fly_sky/blob/main/gcc/startup_MKL16Z4.c): `gcc/startup_MKL16Z4.c`

### Transmitter runtime

- [Firmware entry](https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/main.cpp): `Sources/main.cpp`
- [Transmitter core](https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/er9x.cpp): `Sources/er9x.cpp`
- [Pulse generation](https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/pulses.cpp): `Sources/pulses.cpp`
- [Model templates](https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/templates.cpp): `Sources/templates.cpp`

### RF and telemetry

- [A7105 RF interface](https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/A7105_SPI.cpp): `Sources/A7105_SPI.cpp`
- [AFHDS protocol](https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/AFHDS.cpp): `Sources/AFHDS.cpp`
- [AFHDS2A protocol](https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/AFHDS2A_a7105.cpp): `Sources/AFHDS2A_a7105.cpp`
- [CRSF link and telemetry](https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/crossfire/crossfire.cpp): `Sources/crossfire/crossfire.cpp`
- [CRSF CRC](https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/crossfire/crc_crsf.cpp): `Sources/crossfire/crc_crsf.cpp`

### User interface

- [Setup and telemetry menus](https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/menus.cpp): `Sources/menus.cpp`
- [LCD rendering](https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/lcd.cpp): `Sources/lcd.cpp`
- [ExpressLRS setup menu](https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/crossfire/elrs.cpp): `Sources/crossfire/elrs.cpp`

### Persistence and audio

- [Model and radio storage](https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/pers.cpp): `Sources/pers.cpp`
- [EEPROM file access](https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/file.cpp): `Sources/file.cpp`
- [Audio and voice](https://github.com/sergegrin/grin_fly_sky/blob/main/Sources/audio.cpp): `Sources/audio.cpp`

### Other components

- **Radio operator**
- **DFPlayer voice module**
- **External ExpressLRS TX**
- **Internal A7105 module**

## Connections

- Radio operator → Setup and telemetry menus: operates
- Firmware entry → Transmitter core: starts (evidence: `Sources/main.cpp`)
- Transmitter core → Setup and telemetry menus: dispatches (evidence: `Sources/er9x.cpp`)
- Transmitter core → Pulse generation: uses (evidence: `Sources/er9x.cpp`)
- Transmitter core → LCD rendering: updates (evidence: `Sources/er9x.cpp`)
- Transmitter core → Audio and voice: triggers (evidence: `Sources/er9x.cpp`)
- Setup and telemetry menus → LCD rendering: renders (evidence: `Sources/menus.cpp`)
- Setup and telemetry menus → Model templates: uses (evidence: `Sources/menus.cpp`)
- Setup and telemetry menus → Pulse generation: configures (evidence: `Sources/menus.cpp`)
- Setup and telemetry menus → ExpressLRS setup menu: opens (evidence: `Sources/menus.cpp`)
- FS-i6 board I/O → CRSF link and telemetry: dispatches (evidence: `Sources/I6/BoardI6.cpp`)
- FS-i6 board I/O → Pulse generation: provides I/O (evidence: `Sources/I6/BoardI6.cpp`)
- FS-i6 board I/O → A7105 RF interface: provides I/O (evidence: `Sources/I6/BoardI6.cpp`)
- Peripheral drivers → Pulse generation: supports (evidence: `Sources/drivers.cpp`)
- Peripheral drivers → Audio and voice: supports (evidence: `Sources/drivers.cpp`)
- Pulse generation → A7105 RF interface: drives
- A7105 RF interface → AFHDS protocol: supports
- A7105 RF interface → AFHDS2A protocol: supports (evidence: `Sources/AFHDS2A_a7105.cpp`)
- Pulse generation → CRSF link and telemetry: drives
- CRSF link and telemetry → External ExpressLRS TX: exchanges frames
- CRSF link and telemetry → CRSF CRC: checks frames (evidence: `Sources/crossfire/crossfire.cpp`)
- ExpressLRS setup menu → CRSF link and telemetry: sends configuration
- CRSF link and telemetry → Setup and telemetry menus: provides telemetry
- A7105 RF interface → Internal A7105 module: controls
- Transmitter core → Model and radio storage: loads settings (evidence: `Sources/er9x.cpp`)
- Model and radio storage → EEPROM file access: uses (evidence: `Sources/pers.cpp`)
- Audio and voice → DFPlayer voice module: drives UART
- Device register selection → MKL16Z4 device definitions: selects (evidence: `CMSIS_4/CMSIS/Include/fsl_device_registers.h`)
- Device register selection → Device feature definitions: includes (evidence: `CMSIS_4/CMSIS/Include/fsl_device_registers.h`)
- MKL16Z4 device definitions → Cortex-M0+ core support: includes core (evidence: `CMSIS_4/CMSIS/Include/MKL16Z4.h`)
- Cortex-M0+ core support → CMSIS GCC intrinsics: uses intrinsics (evidence: `CMSIS_4/CMSIS/Include/core_cm0plus.h`)
- Clock and system setup → MKL16Z4 device definitions: configures (evidence: `Kinetis_KL/CMSIS/Device/Source/system_MKL16Z4.c`)
- Cortex-M startup → Clock and system setup: initializes system
- FS-i6 board I/O → MKL16Z4 device definitions: uses registers
