Difference between revisions of "STM32 W25Qxx"
Line 20: | Line 20: | ||
== W25Qxx Library == | == W25Qxx Library == | ||
+ | |||
+ | To make the W25Qxx easy to use, we need to develop a [https://github.com/lbthomsen/stm32-w25qxx library] with a set of simple functions: | ||
+ | |||
+ | <pre> | ||
+ | W25QXX_result_t w25qxx_init(W25QXX_HandleTypeDef *w25qxx, SPI_HandleTypeDef *hspi, GPIO_TypeDef *cs_port, uint16_t cs_pin); | ||
+ | W25QXX_result_t w25qxx_read(W25QXX_HandleTypeDef *w25qxx, uint32_t address, uint8_t *buf, uint32_t len); | ||
+ | W25QXX_result_t w25qxx_write(W25QXX_HandleTypeDef *w25qxx, uint32_t address, uint8_t *buf, uint32_t len); | ||
+ | W25QXX_result_t w25qxx_erase(W25QXX_HandleTypeDef *w25qxx, uint32_t address, uint32_t len); | ||
+ | </pre> | ||
+ | |||
+ | We will use a handle to keep information such as GPIO pins. | ||
+ | |||
+ | === init === | ||
+ | |||
+ | To be added | ||
+ | |||
+ | === read === | ||
+ | |||
+ | To be added | ||
+ | |||
+ | === write === | ||
+ | |||
+ | To be added | ||
+ | |||
+ | === erase === | ||
To be added | To be added |
Revision as of 02:43, 1 March 2022
This page describes how to use W25Qxx Serial Flash/EEPROM chips with the STM32. The examples and code on this page has been developed on and for the Black Pill development board.
The resulting library can be found here: https://github.com/lbthomsen/stm32-w25qxx
An example using this library can be found here: https://github.com/lbthomsen/blackpill/tree/master/eeprom
Black Pill EEPROM
The Black Pill boards, whether original or copy, all includes an unpopulated footprint on the back side, with space for a "generic eeprom". This footprint can be populated with a wide range of compatible EEPROM chips.
The examples on this page are all using a Black Pill with a Winbond W25Q128.
The original Black Pill board have been going through a few changes which can be a bit confusing. In all cases, the footprint is wired up to SPI1, but it is important to notice that on some boards the DO (MISO) pin of the W25Qxx is wired to PA6, and on some it is wired to PB4. Be certain to check which one is actually used.
In our case, the Black Pill board is clearly not an original, and PA6 is being used throughout:
W25Qxx Library
To make the W25Qxx easy to use, we need to develop a library with a set of simple functions:
W25QXX_result_t w25qxx_init(W25QXX_HandleTypeDef *w25qxx, SPI_HandleTypeDef *hspi, GPIO_TypeDef *cs_port, uint16_t cs_pin); W25QXX_result_t w25qxx_read(W25QXX_HandleTypeDef *w25qxx, uint32_t address, uint8_t *buf, uint32_t len); W25QXX_result_t w25qxx_write(W25QXX_HandleTypeDef *w25qxx, uint32_t address, uint8_t *buf, uint32_t len); W25QXX_result_t w25qxx_erase(W25QXX_HandleTypeDef *w25qxx, uint32_t address, uint32_t len);
We will use a handle to keep information such as GPIO pins.
init
To be added
read
To be added
write
To be added
erase
To be added
Using the library
To be added