Complete reference for all source files in the NanoVNA-H firmware.
| File | Lines | Purpose |
|---|
main.c | ~3100 | Entry point, sweep loop, shell commands, calibration |
nanovna.h | ~1450 | Central header with all defines, structs, feature flags |
common.c | ~200 | String parsing, utility functions |
The main source file contains:
- Shell command implementations (40+ commands)
- Sweep thread and measurement loop
- Calibration routines (SOLT, enhanced response)
- Frequency and bandwidth management
- USB CDC command processing
| File | Lines | Purpose |
|---|
ui.c | ~2800 | Touch UI, menu system, keyboard input |
plot.c | ~1400 | Trace rendering, grid, markers, cell-based redraw |
lcd.c | ~800 | LCD driver, SPI communication, SD card interface |
ui.c implements:
- Hierarchical menu tree (menu_top, menu_display, menu_marker, etc.)
- Touch event processing and calibration
- On-screen keyboard for numeric/text input
- Lever (rotary encoder) handling
plot.c implements:
- Cell-based dirty-region rendering (64x32 pixel cells)
- 30 trace type calculations and display
- Smith chart and polar plot rendering
- Marker display and search functions
| File | Lines | Purpose |
|---|
dsp.c | ~300 | DSP processing, CM4 instructions (F303) |
vna_math.c | ~400 | Math tables, FFT, trigonometric functions |
vna_math.h | ~100 | Math function declarations |
Audio Samples (I2S) → DFT/FFT → Gamma Calculation → Calibration → Display
dsp.c contains:
- Sin/cos lookup tables for DFT
- Sample accumulation and averaging
- Cortex-M4 DSP instruction wrappers (F303 only)
vna_math.c contains:
- 512-entry sin/cos table (when
__VNA_USE_MATH_TABLES__ enabled)
- FFT implementation for time domain
- Fast math approximations (
__USE_VNA_MATH__)
| File | Lines | Purpose |
|---|
si5351.c | ~600 | Si5351/MS5351 frequency synthesizer driver |
tlv320aic3204.c | ~300 | TLV320AIC3204 audio codec driver |
hardware.c | ~400 | ADC, I2C, RTC, flash, GPIO abstraction |
hardware.h | ~330 | Hardware interface declarations |
| Function | Purpose |
|---|
si5351_init() | Initialize synthesizer, detect variant |
si5351_set_frequency() | Set output frequency with PLL calculation |
si5351_set_power() | Set output drive strength |
si5351_reset_pll() | Reset PLL for frequency changes |
| Function | Purpose |
|---|
tlv320aic3204_init() | Initialize codec, configure I2S |
tlv320aic3204_select() | Switch between CH0/CH1 measurement |
tlv320aic3204_set_gain() | Set analog gain for signal level |
| File | Lines | Purpose |
|---|
data_storage.c | ~200 | Flash read/write for calibration and config |
flash.c | ~150 | Low-level flash erase and program |
| Function | Purpose |
|---|
caldata_save() | Save calibration to flash slot |
caldata_recall() | Load calibration from flash slot |
config_save() | Save device configuration |
config_recall() | Load device configuration |
clear_all_config_prop_data() | Factory reset |
| File | Lines | Purpose |
|---|
usbcfg.c | ~250 | USB CDC configuration and descriptors |
Implements USB CDC (Communications Device Class) for virtual COM port.
| File | Size | Description |
|---|
fonts/Font5x7.c | 2 KB | Small font for status text |
fonts/Font6x10.c | 3 KB | Normal font (F072 default) |
fonts/Font7x11b.c | 4 KB | Bold font (F303 default) |
fonts/Font11x14.c | 8 KB | Large font for headers |
fonts/numfont16x22.c | 6 KB | Numeric keypad glyphs |
| File | Purpose |
|---|
FatFs/ff.c | FAT filesystem implementation |
FatFs/ffunicode.c | Unicode support for filenames |
FatFs/ff.h | FatFS API declarations |
FatFs/ffconf.h | FatFS configuration |
FatFs/diskio.h | Disk I/O interface |
| File | Purpose |
|---|
NANOVNA_STM32_F072/board.h | GPIO pin definitions |
NANOVNA_STM32_F072/board.c | Board initialization |
NANOVNA_STM32_F072/board.mk | Build configuration |
NANOVNA_STM32_F072/STM32F072xB.ld | Linker script |
NANOVNA_STM32_F072/halconf.h | HAL configuration |
NANOVNA_STM32_F072/mcuconf.h | MCU peripheral configuration |
NANOVNA_STM32_F072/chconf.h | ChibiOS configuration |
| File | Purpose |
|---|
NANOVNA_STM32_F303/board.h | GPIO pin definitions |
NANOVNA_STM32_F303/board.c | Board initialization |
NANOVNA_STM32_F303/board.mk | Build configuration |
NANOVNA_STM32_F303/STM32F303xC.ld | Linker script |
NANOVNA_STM32_F303/halconf.h | HAL configuration |
NANOVNA_STM32_F303/mcuconf.h | MCU peripheral configuration |
NANOVNA_STM32_F303/chconf.h | ChibiOS configuration |
The ChibiOS directory contains the real-time operating system. Key components used:
| Component | Purpose |
|---|
os/rt/ | Real-time kernel |
os/hal/ | Hardware abstraction layer |
os/hal/ports/STM32/ | STM32-specific HAL |
os/common/startup/ | Startup code |
os/hal/lib/streams/ | Stream I/O (used for shell) |
| File | Purpose |
|---|
Makefile | Main build configuration |
NanoVNA_DAP.cfg | OpenOCD debug configuration |
├── nanovna.h (central header)
├── ch.h (ChibiOS kernel)
└── trace_info_list[], marker_info_list[]
└── FatFs/ff.h (if SD card enabled)
Approximate compiled sizes (F072 target, -O2 LTO):
| Component | Size |
|---|
| main.c | ~25 KB |
| ui.c | ~18 KB |
| plot.c | ~12 KB |
| lcd.c | ~8 KB |
| si5351.c | ~4 KB |
| vna_math.c | ~6 KB |
| Fonts | ~20 KB |
| ChibiOS | ~15 KB |
| Total | ~110 KB |
The F072 has 128 KB flash, leaving ~18 KB for calibration and configuration storage.