H753_CPP_W25Q_QSPI_Flash_Read_Write_01 1.0
STM32H753 W25Q QSPI flash (Adafruit 5632/5633/5634) read/write tutorial
Loading...
Searching...
No Matches
entryPointCPP.cpp
1/*
2 * entryPointCPP.cpp
3 *
4 * Created on: Sep 3, 2026
5 * Author: johng
6 */
7
8#include "entryPointCPP.hpp"
9#include "W25QFlashQSPI.hpp"
10#include "w25q_validation.hpp"
11#include <stdio.h>
12
14static W25QFlashQSPI *w25qFlash = nullptr;
15
17static bool w25qReady = false;
18
19void initW25QFlash(void) {
20 w25qFlash = new W25QFlashQSPI();
21 w25qReady = w25qFlash->Init();
22}
23
24bool w25qIsReady(void) {
25 return w25qReady;
26}
27
28bool w25qReadBuffer(uint32_t addr, uint8_t *buf, uint32_t len) {
29 if (w25qFlash == nullptr || !w25qReady) {
30 return false;
31 }
32 bool value = w25qFlash->readBuffer(addr, buf, len);
33 return value;
34}
35
36bool w25qWriteBuffer(uint32_t addr, const uint8_t *data, uint32_t len) {
37 if (w25qFlash == nullptr || !w25qReady) {
38 return false;
39 }
40 bool value = w25qFlash->writeBuffer(addr, data, len);
41 return value;
42}
43
44bool w25qEraseSector(uint32_t addr) {
45 if (w25qFlash == nullptr || !w25qReady) {
46 return false;
47 }
48 bool value = w25qFlash->eraseSector(addr);
49 return value;
50}
51
52bool w25qReadJEDECID(uint32_t *id) {
53 if (w25qFlash == nullptr || !w25qReady) {
54 return false;
55 }
56 bool value = w25qFlash->readJEDECID(*id);
57 return value;
58}
59
60bool w25qReadJEDECIDRaw(uint32_t *id) {
61 if (w25qFlash == nullptr) {
62 return false;
63 }
64 return w25qFlash->readJEDECID(*id);
65}
66
67void w25qRunValidation(void) {
68 if (w25qFlash == nullptr || !w25qReady) {
69 printf("W25Q validation skipped -- flash not initialized\r\n");
70 return;
71 }
72 W25QValidation validation(*w25qFlash);
73 validation.RunAll();
74}
STM32 HAL QUADSPI driver for a Winbond W25Q-series flash chip (Adafruit 5632/5633/5634),...
bool writeBuffer(uint32_t addr, const uint8_t *data, uint32_t len)
Writes len bytes starting at addr, paging internally at 256-byte boundaries as the chip's Page Progra...
bool readJEDECID(uint32_t &id)
Reads the 3-byte JEDEC ID (manufacturer, memory type, capacity).
bool readBuffer(uint32_t addr, uint8_t *buf, uint32_t len)
Reads len bytes starting at addr into buf.
bool Init()
Resets the chip and verifies communication via the JEDEC ID.
bool eraseSector(uint32_t addr)
Erases the single 4KB sector containing the given address.
Destructive validation suite for a W25QFlashQSPI driver – see w25q_validation.hpp's file header for t...