14#define W25Q128_PAGE_PROGRAM 0x02
15#define W25Q128_READ_DATA 0x03
16#define W25Q128_WRITE_ENABLE 0x06
17#define W25Q128_ERASE_CHIP 0x60
18#define W25Q128_READ_STATUS_REGISTER_1 0x05
19#define W25Q128_READ_STATUS_REGISTER_2 0x35
20#define W25Q128_READ_STATUS_REGISTER_3 0x15
22#define W25Q128_PAGE_SIZE 256
23#define W25Q128_PAGE_COUNT 65536
31typedef struct W25Q128 {
36 void (*
erase)(
struct W25Q128 *);
37 void (*
readPage)(
struct W25Q128 *, uint32_t,
volatile uint8_t *);
38 void (*
writePage)(
struct W25Q128 *, uint32_t, uint8_t *);
41void configure_SPI4_Flash();
Struct definition for a GPIO pin.
Struct definition for SPI interface. Provides the interface for API consumers to interact with the SP...
void(* readPage)(struct W25Q128 *, uint32_t, volatile uint8_t *)
Read page method.
int pageSize
Number of bytes per page.
void(* writePage)(struct W25Q128 *, uint32_t, uint8_t *)
Write page method.
GPIOpin_t cs
Chip select GPIO.
void(* erase)(struct W25Q128 *)
Chip erase method.
SPI_t * base
Parent SPI interface.
long pageCount
Total number of pages.
void _W25Q128_writeEnable(W25Q128_t *)
Send Write Enable instruction to the flash device.
void W25Q128_erase(W25Q128_t *)
Erase flash chip.
void W25Q128_readPage(W25Q128_t *, uint32_t, volatile uint8_t *)
Read from flash.
void _W25Q128_readStatus2(W25Q128_t *, uint8_t *)
Read from Status Register 2.
void _W25Q128_readStatus3(W25Q128_t *, uint8_t *)
Read from Status Register 3.
W25Q128_t W25Q128_init(W25Q128_t *, SPI_t *, GPIOpin_t)
Initialise flash struct.
void _W25Q128_readStatus1(W25Q128_t *, uint8_t *)
Read from Status Register 1.
void W25Q128_writePage(W25Q128_t *, uint32_t, uint8_t *)
Write page to flash.