# dresnaught/swr-stm32f4-cmake architecture

> Architecture diagram of the GitHub repository dresnaught/swr-stm32f4-cmake, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dresnaught/swr-stm32f4-cmake
- Repository: https://github.com/dresnaught/swr-stm32f4-cmake

## Overview

This is STM32F401 prototype firmware and controller-board design for an RF SWR and power meter. The runtime workflow samples three detector channels, calibrates readings and computes SWR, then refreshes the LCD when readings or button states change; buttons navigate measurement and calibration menus. The README also documents the target STC8 board and planned protection features, which are hardware/product branches rather than implemented firmware here. Firmware relationships are based on the shown main, menu and LCD code plus the source index; protection and PCB details are README-documented.

Main entry points: [`Core/Src/main.c`](https://github.com/dresnaught/swr-stm32f4-cmake/blob/master/Core/Src/main.c) (Firmware Loop), [`Core/Src/menu.c`](https://github.com/dresnaught/swr-stm32f4-cmake/blob/master/Core/Src/menu.c) (Menu State and Rendering), [`Core/Src/lcd.c`](https://github.com/dresnaught/swr-stm32f4-cmake/blob/master/Core/Src/lcd.c) (I2C LCD Driver), [`Core/Src/adc.c`](https://github.com/dresnaught/swr-stm32f4-cmake/blob/master/Core/Src/adc.c) (ADC Sampling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Measurement Runtime"]
  node_main["Firmware Loop<br/>[main.c]"]
  node_adc["ADC Sampling<br/>[adc.c]"]
  node_conversion["Calibration and SWR<br/>[conversion.c]"]
end

subgraph group_ui["Display and Navigation"]
  node_buttons["Button GPIO<br/>[button.c]"]
  node_menu["Menu State and Rendering<br/>[menu.c]"]
  node_lcd["I2C LCD Driver<br/>[lcd.c]"]
end

subgraph group_platform["STM32 Platform"]
  node_systick["SysTick Timing<br/>[sytick.c]"]
  node_system["System Initialization<br/>[system_stm32f4xx.c]"]
  node_device["STM32F401 Device Definitions<br/>[stm32f401xc.h]"]
end

subgraph group_hardware["Board and Protection"]
  node_pcb["STC8 Controller PCB"]
  node_gerbers["PCB Fabrication Files"]
  node_protection["Relay Protection Circuit"]
end

node_coupler(("RF Coupler"))
node_operator(("Operator"))
node_display["Character LCD"]
node_transmitter["Transmitter PTT"]

node_coupler -.->|"provides detector signals"| node_adc
node_main -->|"initializes"| node_adc
node_main -->|"reads measurements"| node_conversion
node_conversion -.->|"samples channels"| node_adc
node_main -->|"updates and displays"| node_menu
node_operator -.->|"presses controls"| node_buttons
node_menu -->|"reads button states"| node_buttons
node_menu -->|"renders screens"| node_lcd
node_lcd -.->|"drives over I2C"| node_display
node_main -->|"initializes timing"| node_systick
node_lcd -->|"uses delays"| node_systick
node_main -->|"accesses registers"| node_device
node_system -->|"uses device definitions"| node_device
node_pcb -->|"documented fabrication outputs"| node_gerbers
node_pcb -->|"includes relay circuitry"| node_protection
node_protection -.->|"cuts off PTT"| node_transmitter

click node_main "https://github.com/dresnaught/swr-stm32f4-cmake/blob/master/Core/Src/main.c"
click node_adc "https://github.com/dresnaught/swr-stm32f4-cmake/blob/master/Core/Src/adc.c"
click node_conversion "https://github.com/dresnaught/swr-stm32f4-cmake/blob/master/Core/Src/conversion.c"
click node_buttons "https://github.com/dresnaught/swr-stm32f4-cmake/blob/master/Core/Src/button.c"
click node_menu "https://github.com/dresnaught/swr-stm32f4-cmake/blob/master/Core/Src/menu.c"
click node_lcd "https://github.com/dresnaught/swr-stm32f4-cmake/blob/master/Core/Src/lcd.c"
click node_systick "https://github.com/dresnaught/swr-stm32f4-cmake/blob/master/Core/Src/sytick.c"
click node_system "https://github.com/dresnaught/swr-stm32f4-cmake/blob/master/Core/Src/system_stm32f4xx.c"
click node_device "https://github.com/dresnaught/swr-stm32f4-cmake/blob/master/Drivers/CMSIS/Device/stm32f401xc.h"
click node_pcb "https://github.com/dresnaught/swr-stm32f4-cmake/blob/master/PCB%20and%20Schematic/SCH_Schematic1_2026-09-30.pdf"
click node_gerbers "https://github.com/dresnaught/swr-stm32f4-cmake/tree/master/PCB%20and%20Schematic/Gerber"
click node_protection "https://github.com/dresnaught/swr-stm32f4-cmake/blob/master/PCB%20and%20Schematic/SCH_Schematic1_2026-09-30.pdf"

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_adc,node_conversion toneBlue
class node_buttons,node_menu,node_lcd toneAmber
class node_systick,node_system,node_device toneMint
class node_pcb,node_gerbers,node_protection toneRose
class node_coupler,node_operator,node_display,node_transmitter toneIndigo
```

## Components

### Measurement Runtime

- [Firmware Loop](https://github.com/dresnaught/swr-stm32f4-cmake/blob/master/Core/Src/main.c): `Core/Src/main.c`
- [ADC Sampling](https://github.com/dresnaught/swr-stm32f4-cmake/blob/master/Core/Src/adc.c): `Core/Src/adc.c`
- [Calibration and SWR](https://github.com/dresnaught/swr-stm32f4-cmake/blob/master/Core/Src/conversion.c): `Core/Src/conversion.c`

### Display and Navigation

- [Button GPIO](https://github.com/dresnaught/swr-stm32f4-cmake/blob/master/Core/Src/button.c): `Core/Src/button.c`
- [Menu State and Rendering](https://github.com/dresnaught/swr-stm32f4-cmake/blob/master/Core/Src/menu.c): `Core/Src/menu.c`
- [I2C LCD Driver](https://github.com/dresnaught/swr-stm32f4-cmake/blob/master/Core/Src/lcd.c): `Core/Src/lcd.c`

### STM32 Platform

- [SysTick Timing](https://github.com/dresnaught/swr-stm32f4-cmake/blob/master/Core/Src/sytick.c): `Core/Src/sytick.c`
- [System Initialization](https://github.com/dresnaught/swr-stm32f4-cmake/blob/master/Core/Src/system_stm32f4xx.c): `Core/Src/system_stm32f4xx.c`
- [STM32F401 Device Definitions](https://github.com/dresnaught/swr-stm32f4-cmake/blob/master/Drivers/CMSIS/Device/stm32f401xc.h): `Drivers/CMSIS/Device/stm32f401xc.h`

### Board and Protection

- [STC8 Controller PCB](https://github.com/dresnaught/swr-stm32f4-cmake/blob/master/PCB%20and%20Schematic/SCH_Schematic1_2026-09-30.pdf): `PCB and Schematic/SCH_Schematic1_2026-09-30.pdf`
- [PCB Fabrication Files](https://github.com/dresnaught/swr-stm32f4-cmake/tree/master/PCB%20and%20Schematic/Gerber): `PCB and Schematic/Gerber`
- [Relay Protection Circuit](https://github.com/dresnaught/swr-stm32f4-cmake/blob/master/PCB%20and%20Schematic/SCH_Schematic1_2026-09-30.pdf): `PCB and Schematic/SCH_Schematic1_2026-09-30.pdf`

### Other components

- **RF Coupler**
- **Operator**
- **Character LCD**
- **Transmitter PTT**

## Connections

- RF Coupler → ADC Sampling: provides detector signals (evidence: `README.md`)
- Firmware Loop → ADC Sampling: initializes (evidence: `Core/Src/main.c`)
- Firmware Loop → Calibration and SWR: reads measurements (evidence: `Core/Src/main.c`)
- Calibration and SWR → ADC Sampling: samples channels (evidence: `Core/Src/conversion.c`)
- Firmware Loop → Menu State and Rendering: updates and displays (evidence: `Core/Src/main.c`)
- Operator → Button GPIO: presses controls (evidence: `README.md`)
- Menu State and Rendering → Button GPIO: reads button states (evidence: `Core/Src/menu.c`)
- Menu State and Rendering → I2C LCD Driver: renders screens (evidence: `Core/Src/menu.c`)
- I2C LCD Driver → Character LCD: drives over I2C (evidence: `README.md`)
- Firmware Loop → SysTick Timing: initializes timing (evidence: `Core/Src/main.c`)
- I2C LCD Driver → SysTick Timing: uses delays (evidence: `Core/Src/lcd.c`)
- Firmware Loop → STM32F401 Device Definitions: accesses registers (evidence: `Core/Src/main.c`)
- System Initialization → STM32F401 Device Definitions: uses device definitions (evidence: `Core/Src/system_stm32f4xx.c`)
- STC8 Controller PCB → PCB Fabrication Files: documented fabrication outputs (evidence: `README.md`)
- STC8 Controller PCB → Relay Protection Circuit: includes relay circuitry (evidence: `README.md`)
- Relay Protection Circuit → Transmitter PTT: cuts off PTT (evidence: `README.md`)
