# libdriver/w25qxx architecture

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

- Interactive diagram: https://gitdiagram.com/libdriver/w25qxx
- Repository: https://github.com/libdriver/w25qxx

## Overview

LibDriver W25QXX is an embedded C driver for serial flash, exposing basic and advanced operations through a platform-linked SPI/QSPI interface. The documented workflow initializes the driver, performs device identification and flash reads or writes, then deinitializes it; advanced operations include erase, status, power, and protection controls. Board projects provide command or shell entry points and hardware adapters. The README establishes broader capabilities; sampled excerpts show representative application calls and callback-link definitions, not the complete driver or adapter implementations.

Main entry points: [`src/driver_w25qxx.h`](https://github.com/libdriver/w25qxx/blob/main/src/driver_w25qxx.h) (Driver API), [`interface/driver_w25qxx_interface.h`](https://github.com/libdriver/w25qxx/blob/main/interface/driver_w25qxx_interface.h) (SPI/QSPI contract), [`project/raspberrypi4b/driver/src/raspberrypi4b_driver_w25qxx_interface.c`](https://github.com/libdriver/w25qxx/blob/main/project/raspberrypi4b/driver/src/raspberrypi4b_driver_w25qxx_interface.c) (Raspberry Pi adapter), [`project/stm32f407/driver/src/stm32f407_driver_w25qxx_interface.c`](https://github.com/libdriver/w25qxx/blob/main/project/stm32f407/driver/src/stm32f407_driver_w25qxx_interface.c) (STM32F407 adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_driver["Flash driver"]
  node_api["Driver API<br/>[driver_w25qxx.h]"]
  node_engine["Flash operations<br/>[driver_w25qxx.c]"]
  node_contract["SPI/QSPI contract"]
  node_template["Interface template"]
end

subgraph group_platform["Platform adapters"]
  node_piadapter["Raspberry Pi adapter"]
  node_pibus["Raspberry Pi SPI<br/>[spi.c]"]
  node_f4adapter["STM32F407 adapter"]
  node_f4bus["STM32F407 SPI<br/>[spi.c]"]
  node_f7adapter["STM32F767 adapter"]
  node_f7bus["STM32F767 QSPI<br/>[qspi.c]"]
end

subgraph group_boards["Board applications"]
  node_cli["Raspberry Pi CLI<br/>[main.c]"]
  node_stm407app["STM32F407 shell<br/>[main.c]"]
  node_stm767app["STM32F767 shell<br/>[main.c]"]
end

node_user(("Application user"))
node_flash(("W25QXX flash"))

node_user -->|"runs commands"| node_cli
node_user -->|"uses shell"| node_stm407app
node_user -->|"uses shell"| node_stm767app
node_cli -->|"calls operations"| node_api
node_stm407app -->|"calls operations"| node_api
node_stm767app -->|"calls operations"| node_api
node_api -->|"declares API"| node_engine
node_engine -->|"dispatches callbacks"| node_contract
node_piadapter -->|"implements"| node_contract
node_f4adapter -->|"implements"| node_contract
node_f7adapter -->|"implements"| node_contract
node_piadapter -->|"transfers SPI"| node_pibus
node_f4adapter -->|"transfers SPI"| node_f4bus
node_f7adapter -->|"transfers QSPI"| node_f7bus
node_pibus -->|"exchanges data"| node_flash
node_f4bus -->|"exchanges data"| node_flash
node_f7bus -->|"exchanges data"| node_flash

click node_cli "https://github.com/libdriver/w25qxx/blob/main/project/raspberrypi4b/src/main.c"
click node_stm407app "https://github.com/libdriver/w25qxx/blob/main/project/stm32f407/usr/src/main.c"
click node_stm767app "https://github.com/libdriver/w25qxx/blob/main/project/stm32f767/usr/src/main.c"
click node_api "https://github.com/libdriver/w25qxx/blob/main/src/driver_w25qxx.h"
click node_engine "https://github.com/libdriver/w25qxx/blob/main/src/driver_w25qxx.c"
click node_contract "https://github.com/libdriver/w25qxx/blob/main/interface/driver_w25qxx_interface.h"
click node_template "https://github.com/libdriver/w25qxx/blob/main/interface/driver_w25qxx_interface_template.c"
click node_piadapter "https://github.com/libdriver/w25qxx/blob/main/project/raspberrypi4b/driver/src/raspberrypi4b_driver_w25qxx_interface.c"
click node_pibus "https://github.com/libdriver/w25qxx/blob/main/project/raspberrypi4b/interface/src/spi.c"
click node_f4adapter "https://github.com/libdriver/w25qxx/blob/main/project/stm32f407/driver/src/stm32f407_driver_w25qxx_interface.c"
click node_f4bus "https://github.com/libdriver/w25qxx/blob/main/project/stm32f407/interface/src/spi.c"
click node_f7adapter "https://github.com/libdriver/w25qxx/blob/main/project/stm32f767/driver/src/stm32f767_driver_w25qxx_interface.c"
click node_f7bus "https://github.com/libdriver/w25qxx/blob/main/project/stm32f767/interface/src/qspi.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_api,node_engine,node_contract,node_template,node_user toneBlue
class node_piadapter,node_pibus,node_f4adapter,node_f4bus,node_f7adapter,node_f7bus toneAmber
class node_cli,node_stm407app,node_stm767app toneMint
class node_flash toneIndigo
```

## Components

### Flash driver

- [Driver API](https://github.com/libdriver/w25qxx/blob/main/src/driver_w25qxx.h): `src/driver_w25qxx.h`
- [Flash operations](https://github.com/libdriver/w25qxx/blob/main/src/driver_w25qxx.c): `src/driver_w25qxx.c`
- [SPI/QSPI contract](https://github.com/libdriver/w25qxx/blob/main/interface/driver_w25qxx_interface.h): `interface/driver_w25qxx_interface.h`
- [Interface template](https://github.com/libdriver/w25qxx/blob/main/interface/driver_w25qxx_interface_template.c): `interface/driver_w25qxx_interface_template.c`

### Platform adapters

- [Raspberry Pi adapter](https://github.com/libdriver/w25qxx/blob/main/project/raspberrypi4b/driver/src/raspberrypi4b_driver_w25qxx_interface.c): `project/raspberrypi4b/driver/src/raspberrypi4b_driver_w25qxx_interface.c`
- [Raspberry Pi SPI](https://github.com/libdriver/w25qxx/blob/main/project/raspberrypi4b/interface/src/spi.c): `project/raspberrypi4b/interface/src/spi.c`
- [STM32F407 adapter](https://github.com/libdriver/w25qxx/blob/main/project/stm32f407/driver/src/stm32f407_driver_w25qxx_interface.c): `project/stm32f407/driver/src/stm32f407_driver_w25qxx_interface.c`
- [STM32F407 SPI](https://github.com/libdriver/w25qxx/blob/main/project/stm32f407/interface/src/spi.c): `project/stm32f407/interface/src/spi.c`
- [STM32F767 adapter](https://github.com/libdriver/w25qxx/blob/main/project/stm32f767/driver/src/stm32f767_driver_w25qxx_interface.c): `project/stm32f767/driver/src/stm32f767_driver_w25qxx_interface.c`
- [STM32F767 QSPI](https://github.com/libdriver/w25qxx/blob/main/project/stm32f767/interface/src/qspi.c): `project/stm32f767/interface/src/qspi.c`

### Board applications

- [Raspberry Pi CLI](https://github.com/libdriver/w25qxx/blob/main/project/raspberrypi4b/src/main.c): `project/raspberrypi4b/src/main.c`
- [STM32F407 shell](https://github.com/libdriver/w25qxx/blob/main/project/stm32f407/usr/src/main.c): `project/stm32f407/usr/src/main.c`
- [STM32F767 shell](https://github.com/libdriver/w25qxx/blob/main/project/stm32f767/usr/src/main.c): `project/stm32f767/usr/src/main.c`

### Other components

- **Application user**
- **W25QXX flash**

## Connections

- Application user → Raspberry Pi CLI: runs commands
- Application user → STM32F407 shell: uses shell
- Application user → STM32F767 shell: uses shell
- Raspberry Pi CLI → Driver API: calls operations
- STM32F407 shell → Driver API: calls operations
- STM32F767 shell → Driver API: calls operations
- Driver API → Flash operations: declares API
- Flash operations → SPI/QSPI contract: dispatches callbacks
- Raspberry Pi adapter → SPI/QSPI contract: implements
- STM32F407 adapter → SPI/QSPI contract: implements
- STM32F767 adapter → SPI/QSPI contract: implements
- Raspberry Pi adapter → Raspberry Pi SPI: transfers SPI
- STM32F407 adapter → STM32F407 SPI: transfers SPI
- STM32F767 adapter → STM32F767 QSPI: transfers QSPI
- Raspberry Pi SPI → W25QXX flash: exchanges data
- STM32F407 SPI → W25QXX flash: exchanges data
- STM32F767 QSPI → W25QXX flash: exchanges data
