# egzumer/uv-k5-firmware-custom architecture

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

- Interactive diagram: https://gitdiagram.com/egzumer/uv-k5-firmware-custom
- Repository: https://github.com/egzumer/uv-k5-firmware-custom

## Overview

This is embedded custom firmware for Quansheng UV-K5/K6/5R handheld transceivers. The principal workflow is user key/PTT input handled by the application loop, which selects radio behavior and drives receive/transmit operation and the LCD; scanning, channel operation, and optional radio modes add distinct workflows. The README documents broader customizations and optional features. Source excerpts are partial, so links for unsampled feature modules are limited to documented behavior and the paths present in the tree.

Main entry points: [`app/app.c`](https://github.com/egzumer/uv-k5-firmware-custom/blob/main/app/app.c) (Application loop), [`app/action.c`](https://github.com/egzumer/uv-k5-firmware-custom/blob/main/app/action.c) (Key actions), [`app/common.c`](https://github.com/egzumer/uv-k5-firmware-custom/blob/main/app/common.c) (Radio control), [`main.c`](https://github.com/egzumer/uv-k5-firmware-custom/blob/main/main.c) (Startup and loop)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Firmware runtime"]
  node_main["Startup and loop<br/>[main.c]"]
  node_app["Application loop<br/>[app.c]"]
  node_actions["Key actions<br/>[action.c]"]
end

subgraph group_radio["Radio features"]
  node_scanner["Frequency scanning<br/>[scanner.c]"]
  node_channel_scan["Channel scanning<br/>[chFrScanner.c]"]
  node_spectrum["Spectrum analyzer<br/>[spectrum.c]"]
  node_fm["FM radio<br/>[fm.c]"]
  node_dtmf["DTMF calling<br/>[dtmf.c]"]
  node_aircopy["Radio aircopy<br/>[aircopy.c]"]
  node_radio_core["Radio control<br/>[common.c]"]
end

subgraph group_interface["User interface"]
  node_menu["Settings menu<br/>[menu.c]"]
  node_display["Main display<br/>[main.c]"]
end

subgraph group_hardware["Hardware layer"]
  node_bk4819["BK4819 transceiver<br/>[bk4819.c]"]
  node_keyboard["Key scanner<br/>[keyboard.c]"]
  node_lcd["LCD controller<br/>[st7565.c]"]
  node_settings_store[("EEPROM settings<br/>[eeprom.c]")]
  node_uart["UART interface<br/>[uart.c]"]
end

node_user(("Radio user"))
node_transceiver(("UV-Kx radio"))
node_pc(("PC configuration"))

node_user -->|"presses keys"| node_keyboard
node_keyboard -->|"key events"| node_app
node_main -->|"runs loop"| node_app
node_app -->|"dispatches keys"| node_actions
node_app -->|"controls radio"| node_radio_core
node_app -->|"updates screen"| node_display
node_app -->|"services scan"| node_scanner
node_app -->|"services scan"| node_channel_scan
node_actions -->|"opens menu"| node_menu
node_actions -->|"activates analyzer"| node_spectrum
node_app -->|"restores FM mode"| node_fm
node_app -->|"handles calling"| node_dtmf
node_radio_core -->|"configures transceiver"| node_bk4819
node_radio_core -->|"controls RF"| node_transceiver
node_display -->|"renders display"| node_lcd
node_main -->|"loads settings"| node_settings_store
node_pc -.->|"configures radio"| node_uart
node_app -.->|"supports transfer"| node_aircopy

click node_main "https://github.com/egzumer/uv-k5-firmware-custom/blob/main/main.c"
click node_app "https://github.com/egzumer/uv-k5-firmware-custom/blob/main/app/app.c"
click node_actions "https://github.com/egzumer/uv-k5-firmware-custom/blob/main/app/action.c"
click node_menu "https://github.com/egzumer/uv-k5-firmware-custom/blob/main/app/menu.c"
click node_display "https://github.com/egzumer/uv-k5-firmware-custom/blob/main/ui/main.c"
click node_scanner "https://github.com/egzumer/uv-k5-firmware-custom/blob/main/app/scanner.c"
click node_channel_scan "https://github.com/egzumer/uv-k5-firmware-custom/blob/main/app/chFrScanner.c"
click node_spectrum "https://github.com/egzumer/uv-k5-firmware-custom/blob/main/app/spectrum.c"
click node_fm "https://github.com/egzumer/uv-k5-firmware-custom/blob/main/app/fm.c"
click node_dtmf "https://github.com/egzumer/uv-k5-firmware-custom/blob/main/app/dtmf.c"
click node_aircopy "https://github.com/egzumer/uv-k5-firmware-custom/blob/main/app/aircopy.c"
click node_radio_core "https://github.com/egzumer/uv-k5-firmware-custom/blob/main/app/common.c"
click node_bk4819 "https://github.com/egzumer/uv-k5-firmware-custom/blob/main/driver/bk4819.c"
click node_keyboard "https://github.com/egzumer/uv-k5-firmware-custom/blob/main/driver/keyboard.c"
click node_lcd "https://github.com/egzumer/uv-k5-firmware-custom/blob/main/driver/st7565.c"
click node_settings_store "https://github.com/egzumer/uv-k5-firmware-custom/blob/main/driver/eeprom.c"
click node_uart "https://github.com/egzumer/uv-k5-firmware-custom/blob/main/app/uart.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_app,node_actions,node_user toneBlue
class node_scanner,node_channel_scan,node_spectrum,node_fm,node_dtmf,node_aircopy,node_radio_core toneAmber
class node_menu,node_display toneMint
class node_bk4819,node_keyboard,node_lcd,node_settings_store,node_uart toneRose
class node_transceiver,node_pc toneIndigo
```

## Components

### Firmware runtime

- [Startup and loop](https://github.com/egzumer/uv-k5-firmware-custom/blob/main/main.c): `main.c`
- [Application loop](https://github.com/egzumer/uv-k5-firmware-custom/blob/main/app/app.c): `app/app.c`
- [Key actions](https://github.com/egzumer/uv-k5-firmware-custom/blob/main/app/action.c): `app/action.c`

### Radio features

- [Frequency scanning](https://github.com/egzumer/uv-k5-firmware-custom/blob/main/app/scanner.c): `app/scanner.c`
- [Channel scanning](https://github.com/egzumer/uv-k5-firmware-custom/blob/main/app/chFrScanner.c): `app/chFrScanner.c`
- [Spectrum analyzer](https://github.com/egzumer/uv-k5-firmware-custom/blob/main/app/spectrum.c): `app/spectrum.c`
- [FM radio](https://github.com/egzumer/uv-k5-firmware-custom/blob/main/app/fm.c): `app/fm.c`
- [DTMF calling](https://github.com/egzumer/uv-k5-firmware-custom/blob/main/app/dtmf.c): `app/dtmf.c`
- [Radio aircopy](https://github.com/egzumer/uv-k5-firmware-custom/blob/main/app/aircopy.c): `app/aircopy.c`
- [Radio control](https://github.com/egzumer/uv-k5-firmware-custom/blob/main/app/common.c): `app/common.c`

### User interface

- [Settings menu](https://github.com/egzumer/uv-k5-firmware-custom/blob/main/app/menu.c): `app/menu.c`
- [Main display](https://github.com/egzumer/uv-k5-firmware-custom/blob/main/ui/main.c): `ui/main.c`

### Hardware layer

- [BK4819 transceiver](https://github.com/egzumer/uv-k5-firmware-custom/blob/main/driver/bk4819.c): `driver/bk4819.c`
- [Key scanner](https://github.com/egzumer/uv-k5-firmware-custom/blob/main/driver/keyboard.c): `driver/keyboard.c`
- [LCD controller](https://github.com/egzumer/uv-k5-firmware-custom/blob/main/driver/st7565.c): `driver/st7565.c`
- [EEPROM settings](https://github.com/egzumer/uv-k5-firmware-custom/blob/main/driver/eeprom.c): `driver/eeprom.c`
- [UART interface](https://github.com/egzumer/uv-k5-firmware-custom/blob/main/app/uart.c): `app/uart.c`

### Other components

- **Radio user**
- **UV-Kx radio**
- **PC configuration**

## Connections

- Radio user → Key scanner: presses keys
- Key scanner → Application loop: key events
- Startup and loop → Application loop: runs loop
- Application loop → Key actions: dispatches keys
- Application loop → Radio control: controls radio
- Application loop → Main display: updates screen
- Application loop → Frequency scanning: services scan
- Application loop → Channel scanning: services scan
- Key actions → Settings menu: opens menu
- Key actions → Spectrum analyzer: activates analyzer
- Application loop → FM radio: restores FM mode
- Application loop → DTMF calling: handles calling
- Radio control → BK4819 transceiver: configures transceiver
- Radio control → UV-Kx radio: controls RF
- Main display → LCD controller: renders display
- Startup and loop → EEPROM settings: loads settings
- PC configuration → UART interface: configures radio
- Application loop → Radio aircopy: supports transfer
