# shonk7/embeddedproject architecture

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

- Interactive diagram: https://gitdiagram.com/shonk7/embeddedproject
- Repository: https://github.com/shonk7/embeddedproject

## Overview

This is STM32 firmware for a clocked audio-processing demonstrator, with a touchscreen UI for clock-rate control, a three-band mixer, and a live spectrum view. The principal workflow starts in `main`, initializes the audio and sampling path, configures the rate controller, then polls the UI while audio sampling continues in the interrupt path. The graph preserves the capture/FFT and LCD/touch branches. The README is empty; some links rely on explicit comments or the source index, while the rate-controller-to-SPI implementation is unsampled and shown as unverified.

Main entry points: [`Sources/ui/ui.c`](https://github.com/shonk7/embeddedproject/blob/main/Sources/ui/ui.c) (Touch UI), [`Sources/audio.c`](https://github.com/shonk7/embeddedproject/blob/main/Sources/audio.c) (Audio ISR), [`Sources/main.c`](https://github.com/shonk7/embeddedproject/blob/main/Sources/main.c) (Firmware entry), [`Sources/Sampling/sampling.c`](https://github.com/shonk7/embeddedproject/blob/main/Sources/Sampling/sampling.c) (Sample processing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Firmware runtime"]
  node_main["Firmware entry<br/>[main.c]"]
  node_clock_config["Clock setup<br/>[SystemInit.c]"]
  node_debug["Timing and debug<br/>[debug.c]"]
end

subgraph group_audio["Audio processing"]
  node_audio_engine["Audio ISR<br/>[audio.c]"]
  node_adc["ADC input<br/>[adc.c]"]
  node_dac["DAC output<br/>[dac.c]"]
  node_ext_clock["External clock<br/>[extclk.c]"]
  node_sampling["Sample processing<br/>[sampling.c]"]
  node_mixer["Three-band mixer<br/>[mixer.c]"]
  node_capture["Sample capture<br/>[capture.c]"]
  node_fft["Spectrum FFT<br/>[fft.c]"]
end

subgraph group_controls["UI and control"]
  node_rate_control["Rate control<br/>[rate_ctrl.c]"]
  node_clock_spi["Clock-board SPI<br/>[clock_spi.c]"]
  node_ui["Touch UI<br/>[ui.c]"]
end

subgraph group_display["Display and input"]
  node_touch["Touch input<br/>[touch.c]"]
  node_graphics["LCD graphics<br/>[lcd_grph.c]"]
  node_lcd_driver["ILI9341 driver<br/>[lcd_ili9341.c]"]
  node_lcd_hardware["LCD hardware IO<br/>[lcd_hw.c]"]
end

node_user(("Operator"))
node_screen["LCD panel"]
node_clock_board["Clock board"]
node_audio_io["Audio signal path"]

node_user -->|"operates"| node_ui
node_main -->|"initializes"| node_audio_engine
node_main -->|"initializes"| node_sampling
node_main -->|"initializes"| node_rate_control
node_main -->|"initializes"| node_ui
node_main -->|"initializes"| node_debug
node_audio_engine -->|"starts conversion"| node_adc
node_audio_engine -->|"outputs samples"| node_dac
node_audio_engine -->|"uses clock"| node_ext_clock
node_audio_engine -->|"records timing"| node_debug
node_audio_engine -->|"feeds samples"| node_capture
node_sampling -->|"installs processor"| node_audio_engine
node_sampling -->|"processes samples"| node_mixer
node_sampling -->|"returns output code"| node_dac
node_ext_clock -.->|"triggers sampling"| node_audio_engine
node_audio_io -.->|"provides signal"| node_adc
node_dac -.->|"drives output"| node_audio_io
node_ui -->|"sets rate"| node_rate_control
node_ui -->|"configures mixer"| node_mixer
node_ui -->|"requests blocks"| node_capture
node_ui -->|"transforms blocks"| node_fft
node_ui -->|"polls input"| node_touch
node_ui -->|"draws pages"| node_graphics
node_rate_control -.->|"sends commands"| node_clock_spi
node_clock_spi -->|"controls rates"| node_clock_board
node_touch -->|"uses display geometry"| node_graphics
node_graphics -->|"draws through"| node_lcd_driver
node_lcd_driver -->|"uses hardware IO"| node_lcd_hardware
node_lcd_hardware -.->|"drives panel"| node_screen

click node_main "https://github.com/shonk7/embeddedproject/blob/main/Sources/main.c"
click node_clock_config "https://github.com/shonk7/embeddedproject/blob/main/Sources/SystemInit.c"
click node_debug "https://github.com/shonk7/embeddedproject/blob/main/Sources/debug.c"
click node_audio_engine "https://github.com/shonk7/embeddedproject/blob/main/Sources/audio.c"
click node_adc "https://github.com/shonk7/embeddedproject/blob/main/Sources/adc.c"
click node_dac "https://github.com/shonk7/embeddedproject/blob/main/Sources/dac.c"
click node_ext_clock "https://github.com/shonk7/embeddedproject/blob/main/Sources/extclk.c"
click node_sampling "https://github.com/shonk7/embeddedproject/blob/main/Sources/Sampling/sampling.c"
click node_mixer "https://github.com/shonk7/embeddedproject/blob/main/Sources/ui/mixer.c"
click node_capture "https://github.com/shonk7/embeddedproject/blob/main/Sources/capture.c"
click node_rate_control "https://github.com/shonk7/embeddedproject/blob/main/Sources/ui/rate_ctrl.c"
click node_clock_spi "https://github.com/shonk7/embeddedproject/blob/main/Sources/spi/clock_spi.c"
click node_ui "https://github.com/shonk7/embeddedproject/blob/main/Sources/ui/ui.c"
click node_touch "https://github.com/shonk7/embeddedproject/blob/main/Sources/ui/touch.c"
click node_fft "https://github.com/shonk7/embeddedproject/blob/main/Sources/ui/fft.c"
click node_graphics "https://github.com/shonk7/embeddedproject/blob/main/LCD/lcd_grph.c"
click node_lcd_driver "https://github.com/shonk7/embeddedproject/blob/main/LCD/lcd_ili9341.c"
click node_lcd_hardware "https://github.com/shonk7/embeddedproject/blob/main/LCD/lcd_hw.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_clock_config,node_debug toneBlue
class node_audio_engine,node_adc,node_dac,node_ext_clock,node_sampling,node_mixer,node_capture,node_fft toneAmber
class node_rate_control,node_clock_spi,node_ui toneMint
class node_touch,node_graphics,node_lcd_driver,node_lcd_hardware toneRose
class node_user,node_screen,node_clock_board,node_audio_io toneIndigo
```

## Components

### Firmware runtime

- [Firmware entry](https://github.com/shonk7/embeddedproject/blob/main/Sources/main.c): `Sources/main.c`
- [Clock setup](https://github.com/shonk7/embeddedproject/blob/main/Sources/SystemInit.c): `Sources/SystemInit.c`
- [Timing and debug](https://github.com/shonk7/embeddedproject/blob/main/Sources/debug.c): `Sources/debug.c`

### Audio processing

- [Audio ISR](https://github.com/shonk7/embeddedproject/blob/main/Sources/audio.c): `Sources/audio.c`
- [ADC input](https://github.com/shonk7/embeddedproject/blob/main/Sources/adc.c): `Sources/adc.c`
- [DAC output](https://github.com/shonk7/embeddedproject/blob/main/Sources/dac.c): `Sources/dac.c`
- [External clock](https://github.com/shonk7/embeddedproject/blob/main/Sources/extclk.c): `Sources/extclk.c`
- [Sample processing](https://github.com/shonk7/embeddedproject/blob/main/Sources/Sampling/sampling.c): `Sources/Sampling/sampling.c`
- [Three-band mixer](https://github.com/shonk7/embeddedproject/blob/main/Sources/ui/mixer.c): `Sources/ui/mixer.c`
- [Sample capture](https://github.com/shonk7/embeddedproject/blob/main/Sources/capture.c): `Sources/capture.c`
- [Spectrum FFT](https://github.com/shonk7/embeddedproject/blob/main/Sources/ui/fft.c): `Sources/ui/fft.c`

### UI and control

- [Rate control](https://github.com/shonk7/embeddedproject/blob/main/Sources/ui/rate_ctrl.c): `Sources/ui/rate_ctrl.c`
- [Clock-board SPI](https://github.com/shonk7/embeddedproject/blob/main/Sources/spi/clock_spi.c): `Sources/spi/clock_spi.c`
- [Touch UI](https://github.com/shonk7/embeddedproject/blob/main/Sources/ui/ui.c): `Sources/ui/ui.c`

### Display and input

- [Touch input](https://github.com/shonk7/embeddedproject/blob/main/Sources/ui/touch.c): `Sources/ui/touch.c`
- [LCD graphics](https://github.com/shonk7/embeddedproject/blob/main/LCD/lcd_grph.c): `LCD/lcd_grph.c`
- [ILI9341 driver](https://github.com/shonk7/embeddedproject/blob/main/LCD/lcd_ili9341.c): `LCD/lcd_ili9341.c`
- [LCD hardware IO](https://github.com/shonk7/embeddedproject/blob/main/LCD/lcd_hw.c): `LCD/lcd_hw.c`

### Other components

- **Operator**
- **LCD panel**
- **Clock board**
- **Audio signal path**

## Connections

- Operator → Touch UI: operates
- Firmware entry → Audio ISR: initializes (evidence: `Sources/main.c`)
- Firmware entry → Sample processing: initializes (evidence: `Sources/main.c`)
- Firmware entry → Rate control: initializes (evidence: `Sources/main.c`)
- Firmware entry → Touch UI: initializes (evidence: `Sources/main.c`)
- Firmware entry → Timing and debug: initializes (evidence: `Sources/main.c`)
- Audio ISR → ADC input: starts conversion (evidence: `Sources/audio.c`)
- Audio ISR → DAC output: outputs samples (evidence: `Sources/audio.c`)
- Audio ISR → External clock: uses clock (evidence: `Sources/audio.c`)
- Audio ISR → Timing and debug: records timing (evidence: `Sources/audio.c`)
- Audio ISR → Sample capture: feeds samples
- Sample processing → Audio ISR: installs processor
- Sample processing → Three-band mixer: processes samples (evidence: `Sources/Sampling/sampling.c`)
- Sample processing → DAC output: returns output code (evidence: `Sources/Sampling/sampling.c`)
- External clock → Audio ISR: triggers sampling (evidence: `Sources/audio.c`)
- Audio signal path → ADC input: provides signal
- DAC output → Audio signal path: drives output
- Touch UI → Rate control: sets rate (evidence: `Sources/ui/ui.c`)
- Touch UI → Three-band mixer: configures mixer (evidence: `Sources/ui/ui.c`)
- Touch UI → Sample capture: requests blocks (evidence: `Sources/ui/ui.c`)
- Touch UI → Spectrum FFT: transforms blocks (evidence: `Sources/ui/ui.c`)
- Touch UI → Touch input: polls input (evidence: `Sources/ui/ui.c`)
- Touch UI → LCD graphics: draws pages (evidence: `Sources/ui/ui.c`)
- Rate control → Clock-board SPI: sends commands
- Clock-board SPI → Clock board: controls rates
- Touch input → LCD graphics: uses display geometry (evidence: `Sources/ui/touch.c`)
- LCD graphics → ILI9341 driver: draws through (evidence: `LCD/lcd_grph.c`)
- ILI9341 driver → LCD hardware IO: uses hardware IO
- LCD hardware IO → LCD panel: drives panel
