SPI flash driver.
More...
#include <neorv32.h>
#include <system.h>
#include <config.h>
#include <spi_flash.h>
#include <uart.h>
|
uint32_t | g_flash_addr |
|
uint32_t | g_exe_size |
|
◆ SPI_FLASH_CMD_enum
Enumerator |
---|
SPI_FLASH_CMD_PAGE_PROGRAM | Program page
|
SPI_FLASH_CMD_READ | Read data
|
SPI_FLASH_CMD_WRITE_DISABLE | Disallow write access
|
SPI_FLASH_CMD_READ_STATUS | Get status register
|
SPI_FLASH_CMD_WRITE_ENABLE | Allow write access
|
SPI_FLASH_CMD_WAKE | Wake up from sleep mode
|
SPI_FLASH_CMD_SECTOR_ERASE | Erase complete sector
|
◆ SPI_FLASH_SREG_enum
Enumerator |
---|
FLASH_SREG_BUSY | Busy, write/erase in progress when set, read-only
|
FLASH_SREG_WEL | Write access enabled when set, read-only
|
◆ spi_flash_cmd()
static void spi_flash_cmd |
( |
uint8_t | cmd | ) |
|
|
static |
Send single command to SPI flash.
- Parameters
-
◆ spi_flash_erase()
int spi_flash_erase |
( |
void | | ) |
|
◆ spi_flash_read_status()
static uint8_t spi_flash_read_status |
( |
void | | ) |
|
|
static |
Read flash status register.
- Returns
- SPI flash status register.
◆ spi_flash_send_addr()
static void spi_flash_send_addr |
( |
void | | ) |
|
|
static |
◆ spi_flash_setup()
int spi_flash_setup |
( |
void | | ) |
|
Setup SPI flash.
- Returns
- 0 if success, !=0 if error
◆ spi_flash_stream_get()
int spi_flash_stream_get |
( |
uint32_t * | rdata | ) |
|
Read stream word from SPI flash.
- Parameters
-
[in,out] | rdata | Pointer for returned data (uint32_t). |
- Returns
- 0 if success, !=0 if error
◆ spi_flash_stream_put()
int spi_flash_stream_put |
( |
uint32_t | wdata | ) |
|
Write stream word to SPI flash.
- Parameters
-
wdata | SPI flash write data. |
- Returns
- 0 if success, !=0 if error