# therijalsam/stm32u585-spi-benchmark architecture

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

- Interactive diagram: https://gitdiagram.com/therijalsam/stm32u585-spi-benchmark
- Repository: https://github.com/therijalsam/stm32u585-spi-benchmark

## Overview

This is an embedded Rust benchmark for comparing blocking SPI writes with asynchronous DMA writes on STM32U585. Its principal workflow configures the SPI clock, measures payload transfers across sizes and methods, compares throughput and detects crossover points, while a background task exposes DMA concurrency. The capture utility runs the benchmark and turns its RTT output into CSV, tables, and graphs. The benchmark implementation itself was not excerpted, so links from it to timing primitives are omitted rather than inferred.

Main entry points: [`src/main.rs`](https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/src/main.rs) (Benchmark runtime), [`tools/capture_csv.py`](https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/tools/capture_csv.py) (Output capture), [`src/spi.rs`](https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/src/spi.rs) (SPI transfer adapter), [`src/benchmark.rs`](https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/src/benchmark.rs) (Benchmark engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Embedded runtime"]
  node_firmware["Benchmark runtime<br/>[main.rs]"]
  node_worker["Concurrency worker<br/>[main.rs]"]
end

subgraph group_measurement["Benchmark measurement"]
  node_engine["Benchmark engine<br/>[benchmark.rs]"]
  node_comparison["Method comparison<br/>[main.rs]"]
  node_crossover["Crossover analysis<br/>[main.rs]"]
  node_cycle["DWT cycle counter<br/>[cycle_counter.rs]"]
  node_timer["Elapsed-time timer<br/>[timer.rs]"]
end

subgraph group_hardware["SPI hardware"]
  node_interfaces["Transfer interfaces<br/>[transfer.rs]"]
  node_spi["SPI transfer adapter<br/>[spi.rs]"]
  node_peripheral{{"STM32 SPI1"}}
end

subgraph group_results["Result capture"]
  node_capture["Output capture<br/>[capture_csv.py]"]
  node_csv["Benchmark CSV<br/>[benchmark.csv]"]
  node_table["Summary table"]
  node_graphs["Performance graphs"]
  node_rtt["RTT log output"]
end

node_operator(("Benchmark operator"))

node_operator -->|"runs capture"| node_capture
node_capture -->|"runs benchmark"| node_firmware
node_firmware -->|"initializes counter"| node_cycle
node_firmware -->|"configures clock"| node_spi
node_firmware -->|"spawns task"| node_worker
node_firmware -->|"runs measurements"| node_engine
node_firmware -->|"compares methods"| node_comparison
node_firmware -->|"analyzes crossover"| node_crossover
node_spi -->|"implements"| node_interfaces
node_spi -->|"transfers via"| node_peripheral
node_firmware -->|"logs results"| node_rtt
node_capture -->|"parses output"| node_rtt
node_capture -->|"writes rows"| node_csv
node_capture -->|"writes summary"| node_table
node_capture -->|"generates graphs"| node_graphs

click node_firmware "https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/src/main.rs"
click node_worker "https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/src/main.rs"
click node_engine "https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/src/benchmark.rs"
click node_comparison "https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/src/main.rs"
click node_crossover "https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/src/main.rs"
click node_cycle "https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/src/cycle_counter.rs"
click node_timer "https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/src/timer.rs"
click node_interfaces "https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/src/transfer.rs"
click node_spi "https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/src/spi.rs"
click node_capture "https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/tools/capture_csv.py"
click node_csv "https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/results/benchmark.csv"
click node_table "https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/results/benchmark_table.txt"
click node_graphs "https://github.com/therijalsam/stm32u585-spi-benchmark/tree/main/results/graphs"

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_firmware,node_worker toneBlue
class node_engine,node_comparison,node_crossover,node_cycle,node_timer toneAmber
class node_interfaces,node_spi,node_peripheral toneMint
class node_capture,node_csv,node_table,node_graphs,node_rtt toneRose
class node_operator toneIndigo
```

## Components

### Embedded runtime

- [Benchmark runtime](https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/src/main.rs): `src/main.rs`
- [Concurrency worker](https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/src/main.rs): `src/main.rs`

### Benchmark measurement

- [Benchmark engine](https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/src/benchmark.rs): `src/benchmark.rs`
- [Method comparison](https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/src/main.rs): `src/main.rs`
- [Crossover analysis](https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/src/main.rs): `src/main.rs`
- [DWT cycle counter](https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/src/cycle_counter.rs): `src/cycle_counter.rs`
- [Elapsed-time timer](https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/src/timer.rs): `src/timer.rs`

### SPI hardware

- [Transfer interfaces](https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/src/transfer.rs): `src/transfer.rs`
- [SPI transfer adapter](https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/src/spi.rs): `src/spi.rs`
- **STM32 SPI1**

### Result capture

- [Output capture](https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/tools/capture_csv.py): `tools/capture_csv.py`
- [Benchmark CSV](https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/results/benchmark.csv): `results/benchmark.csv`
- [Summary table](https://github.com/therijalsam/stm32u585-spi-benchmark/blob/main/results/benchmark_table.txt): `results/benchmark_table.txt`
- [Performance graphs](https://github.com/therijalsam/stm32u585-spi-benchmark/tree/main/results/graphs): `results/graphs`
- **RTT log output**

### Other components

- **Benchmark operator**

## Connections

- Benchmark operator → Output capture: runs capture (evidence: `tools/capture_csv.py`)
- Output capture → Benchmark runtime: runs benchmark (evidence: `tools/capture_csv.py`)
- Benchmark runtime → DWT cycle counter: initializes counter (evidence: `src/main.rs`)
- Benchmark runtime → SPI transfer adapter: configures clock (evidence: `src/main.rs`)
- Benchmark runtime → Concurrency worker: spawns task (evidence: `src/main.rs`)
- Benchmark runtime → Benchmark engine: runs measurements (evidence: `src/main.rs`)
- Benchmark runtime → Method comparison: compares methods (evidence: `src/main.rs`)
- Benchmark runtime → Crossover analysis: analyzes crossover (evidence: `src/main.rs`)
- SPI transfer adapter → Transfer interfaces: implements (evidence: `src/spi.rs`)
- SPI transfer adapter → STM32 SPI1: transfers via (evidence: `src/spi.rs`)
- Benchmark runtime → RTT log output: logs results (evidence: `src/main.rs`)
- Output capture → RTT log output: parses output (evidence: `tools/capture_csv.py`)
- Output capture → Benchmark CSV: writes rows (evidence: `tools/capture_csv.py`)
- Output capture → Summary table: writes summary (evidence: `tools/capture_csv.py`)
- Output capture → Performance graphs: generates graphs (evidence: `tools/capture_csv.py`)
