# mengguang/w25qxx architecture

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

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

## Overview

This is a small STM32 C driver for W25Q-series SPI flash. A firmware caller initializes the driver, then uses its chip metadata and APIs to erase, read, write, check erased regions, and translate page/sector/block addresses. The implementation uses configured STM32 SPI, GPIO, and delay facilities to communicate with the flash. The excerpts show initialization and portions of erase, check, and write behavior; other API capabilities are documented in the header and README.

Main entry points: [`w25qxx.c`](https://github.com/mengguang/w25qxx/blob/master/w25qxx.c) (Flash driver), [`w25qxx.h`](https://github.com/mengguang/w25qxx/blob/master/w25qxx.h) (Driver API), [`w25qxxConf.h`](https://github.com/mengguang/w25qxx/blob/master/w25qxxConf.h) (HAL configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_firmware(("Firmware caller"))
node_driver["Flash driver<br/>[w25qxx.c]"]
node_api["Driver API<br/>[w25qxx.h]"]
node_config["HAL configuration<br/>[w25qxxConf.h]"]
node_hal["STM32 HAL"]
node_flash[("SPI flash")]

node_firmware -->|"calls driver APIs"| node_api
node_api -->|"implemented by"| node_driver
node_driver -->|"includes settings"| node_config
node_driver -->|"uses SPI GPIO delays"| node_hal
node_driver -->|"sends flash commands"| node_flash
node_driver -->|"writes pages"| node_driver

click node_driver "https://github.com/mengguang/w25qxx/blob/master/w25qxx.c"
click node_api "https://github.com/mengguang/w25qxx/blob/master/w25qxx.h"
click node_config "https://github.com/mengguang/w25qxx/blob/master/w25qxxConf.h"

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_hal toneIndigo
class node_driver,node_config toneTeal
class node_api toneMint
class node_flash toneAmber
```

## Components

### Other components

- **Firmware caller**
- [Flash driver](https://github.com/mengguang/w25qxx/blob/master/w25qxx.c): `w25qxx.c`
- [Driver API](https://github.com/mengguang/w25qxx/blob/master/w25qxx.h): `w25qxx.h`
- [HAL configuration](https://github.com/mengguang/w25qxx/blob/master/w25qxxConf.h): `w25qxxConf.h`
- **STM32 HAL**
- **SPI flash**

## Connections

- Firmware caller → Driver API: calls driver APIs (evidence: `README.md`)
- Driver API → Flash driver: implemented by (evidence: `w25qxx.c`)
- Flash driver → HAL configuration: includes settings (evidence: `w25qxx.c`)
- Flash driver → STM32 HAL: uses SPI GPIO delays (evidence: `w25qxx.c`)
- Flash driver → SPI flash: sends flash commands (evidence: `w25qxx.c`)
- Flash driver → Flash driver: writes pages (evidence: `w25qxx.c`)
