![]() |
ACwing FC firmware
STM32WB55: attitude IEKF, altitude Kalman filter, flight core, protocol v2
|
W25Q serial NOR flash driver (see w25q.h). More...
Go to the source code of this file.
Macros | |
| #define | CMD_WREN 0x06u |
| #define | CMD_RDSR1 0x05u |
| #define | CMD_READ 0x03u /* up to 50 MHz; the binding runs below that */ |
| #define | CMD_PP 0x02u |
| #define | CMD_SE 0x20u /* 4 KB */ |
| #define | CMD_CE 0xC7u |
| #define | CMD_JEDEC 0x9Fu |
| #define | CMD_RELEASE_PD 0xABu |
| #define | SR1_BUSY 0x01u |
| #define | SR1_WEL 0x02u |
| #define | T_PP_MS 3u /* page program max */ |
| #define | T_SE_MS 400u /* sector erase max */ |
| #define | T_CE_MS 200000u /* chip erase max */ |
Functions | |
| static int | cmd1 (w25q_t *d, uint8_t c) |
| static int | status (w25q_t *d, uint8_t *sr) |
| static int | wait_ready (w25q_t *d, uint32_t max_ms) |
| static int | write_enable (w25q_t *d) |
| static void | a24 (uint8_t *b, uint8_t cmd, uint32_t a) |
| int | w25q_init (w25q_t *d, const w25q_bus_t *bus) |
| reads the JEDEC id, releases power-down; 0 = a W25Q-compatible part | |
| int | w25q_read (w25q_t *d, uint32_t addr, void *buf, uint32_t n) |
| int | w25q_prog (w25q_t *d, uint32_t addr, const void *buf, uint32_t n) |
| inside one page | |
| int | w25q_erase_sector (w25q_t *d, uint32_t addr) |
| 4 KB, waits (≤ 400 ms) | |
| int | w25q_erase_chip (w25q_t *d) |
| waits (≤ 200 s) | |
| int | w25q_lf_read (void *ctx, uint32_t a, void *b, uint32_t n) |
| int | w25q_lf_prog (void *ctx, uint32_t a, const void *b, uint32_t n) |
| int | w25q_lf_erase (void *ctx, uint32_t a) |
W25Q serial NOR flash driver (see w25q.h).
Commands from the Winbond W25Q128JV datasheet (rev. F), 3-byte addressing.
Definition in file w25q.c.
| #define CMD_READ 0x03u /* up to 50 MHz; the binding runs below that */ |
|
static |
Definition at line 24 of file w25q.c.
References w25q_t::bus, w25q_bus_t::ctx, and w25q_bus_t::xfer.
Referenced by w25q_erase_chip(), w25q_init(), and write_enable().
|
static |
Definition at line 26 of file w25q.c.
References w25q_t::bus, CMD_RDSR1, w25q_bus_t::ctx, sr, and w25q_bus_t::xfer.
Referenced by wait_ready(), and write_enable().
|
static |
Definition at line 33 of file w25q.c.
References w25q_t::bus, w25q_bus_t::delay_ms, w25q_bus_t::now_ms, sr, SR1_BUSY, and status().
Referenced by w25q_erase_chip(), w25q_erase_sector(), and w25q_prog().
|
static |
Definition at line 46 of file w25q.c.
References cmd1(), CMD_WREN, sr, SR1_WEL, and status().
Referenced by w25q_erase_chip(), w25q_erase_sector(), and w25q_prog().
|
static |
Definition at line 54 of file w25q.c.
Referenced by w25q_erase_sector(), w25q_prog(), and w25q_read().
| int w25q_init | ( | w25q_t * | d, |
| const w25q_bus_t * | bus | ||
| ) |
reads the JEDEC id, releases power-down; 0 = a W25Q-compatible part
Definition at line 59 of file w25q.c.
References w25q_t::bus, w25q_t::cap, cmd1(), CMD_JEDEC, CMD_RELEASE_PD, w25q_bus_t::ctx, w25q_bus_t::delay_ms, w25q_t::mfr, w25q_t::size, w25q_t::type, and w25q_bus_t::xfer.
| int w25q_read | ( | w25q_t * | d, |
| uint32_t | addr, | ||
| void * | buf, | ||
| uint32_t | n | ||
| ) |
Definition at line 75 of file w25q.c.
References a24(), addr(), w25q_t::base, w25q_t::bus, CMD_READ, w25q_bus_t::ctx, n, w25q_t::size, and w25q_bus_t::xfer.
Referenced by w25q_lf_read().
| int w25q_prog | ( | w25q_t * | d, |
| uint32_t | addr, | ||
| const void * | buf, | ||
| uint32_t | n | ||
| ) |
inside one page
Definition at line 83 of file w25q.c.
References a24(), addr(), w25q_t::base, w25q_t::bus, CMD_PP, w25q_bus_t::ctx, n, w25q_t::size, T_PP_MS, wait_ready(), write_enable(), and w25q_bus_t::xfer_w.
Referenced by w25q_lf_prog().
| int w25q_erase_sector | ( | w25q_t * | d, |
| uint32_t | addr | ||
| ) |
4 KB, waits (≤ 400 ms)
Definition at line 94 of file w25q.c.
References a24(), addr(), w25q_t::base, w25q_t::bus, CMD_SE, w25q_bus_t::ctx, w25q_t::size, T_SE_MS, wait_ready(), write_enable(), and w25q_bus_t::xfer.
Referenced by w25q_lf_erase().
| int w25q_erase_chip | ( | w25q_t * | d | ) |
waits (≤ 200 s)
Definition at line 104 of file w25q.c.
References cmd1(), CMD_CE, T_CE_MS, wait_ready(), and write_enable().
| int w25q_lf_read | ( | void * | ctx, |
| uint32_t | a, | ||
| void * | b, | ||
| uint32_t | n | ||
| ) |
Definition at line 111 of file w25q.c.
References b, n, and w25q_read().
| int w25q_lf_prog | ( | void * | ctx, |
| uint32_t | a, | ||
| const void * | b, | ||
| uint32_t | n | ||
| ) |
Definition at line 112 of file w25q.c.
References b, n, and w25q_prog().
| int w25q_lf_erase | ( | void * | ctx, |
| uint32_t | a | ||
| ) |
Definition at line 113 of file w25q.c.
References w25q_erase_sector().