2015-04-30 04:00:03 +00:00
|
|
|
/*
|
|
|
|
* copyright (c) Espressif System 2010
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __SPI_FLASH_H__
|
|
|
|
#define __SPI_FLASH_H__
|
|
|
|
|
2015-10-11 04:56:11 +00:00
|
|
|
#include "flashchip.h"
|
|
|
|
|
2015-07-30 17:34:13 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-04-30 04:00:03 +00:00
|
|
|
typedef enum {
|
|
|
|
SPI_FLASH_RESULT_OK,
|
|
|
|
SPI_FLASH_RESULT_ERR,
|
|
|
|
SPI_FLASH_RESULT_TIMEOUT
|
2015-05-30 09:11:04 +00:00
|
|
|
} sdk_SpiFlashOpResult;
|
2015-04-30 04:00:03 +00:00
|
|
|
|
|
|
|
#define SPI_FLASH_SEC_SIZE 4096
|
|
|
|
|
2015-05-30 09:11:04 +00:00
|
|
|
uint32_t sdk_spi_flash_get_id(void);
|
|
|
|
sdk_SpiFlashOpResult sdk_spi_flash_read_status(uint32_t *status);
|
|
|
|
sdk_SpiFlashOpResult sdk_spi_flash_write_status(uint32_t status_value);
|
2016-02-26 05:10:08 +00:00
|
|
|
|
|
|
|
/* Erase SPI flash sector. Parameter is sector index.
|
|
|
|
|
|
|
|
Sectors are SPI_FLASH_SEC_SIZE (4096) bytes long.
|
|
|
|
*/
|
2015-05-30 09:11:04 +00:00
|
|
|
sdk_SpiFlashOpResult sdk_spi_flash_erase_sector(uint16_t sec);
|
2015-04-30 04:00:03 +00:00
|
|
|
|
2016-02-26 05:10:08 +00:00
|
|
|
/* Write data to flash.
|
|
|
|
|
|
|
|
des_addr is byte offset to write to. Should be 4-byte aligned.
|
2016-03-10 04:59:36 +00:00
|
|
|
src is pointer to a buffer to read bytes from. Should be 4-byte aligned.
|
2016-02-26 05:10:08 +00:00
|
|
|
size is length of buffer in bytes. Should be a multiple of 4.
|
|
|
|
*/
|
2016-03-23 00:11:18 +00:00
|
|
|
sdk_SpiFlashOpResult sdk_spi_flash_write(uint32_t des_addr, uint32_t *src, uint32_t size);
|
2016-02-26 05:10:08 +00:00
|
|
|
|
|
|
|
/* Read data from flash.
|
|
|
|
|
|
|
|
src_addr is byte offset to read from. Should be 4-byte aligned.
|
2016-03-10 04:59:36 +00:00
|
|
|
des is pointer to a buffer to read bytes into. Should be 4-byte aligned.
|
2016-02-26 05:10:08 +00:00
|
|
|
size is number of bytes to read. Should be a multiple of 4.
|
|
|
|
*/
|
2016-03-23 00:11:18 +00:00
|
|
|
sdk_SpiFlashOpResult sdk_spi_flash_read(uint32_t src_addr, uint32_t *des, uint32_t size);
|
2016-02-26 05:10:08 +00:00
|
|
|
|
|
|
|
|
2015-08-06 01:37:34 +00:00
|
|
|
/* SDK uses this structure internally to account for flash size.
|
|
|
|
|
2016-03-23 00:11:18 +00:00
|
|
|
See flashchip.h for more info.
|
2015-08-06 01:37:34 +00:00
|
|
|
*/
|
|
|
|
extern sdk_flashchip_t sdk_flashchip;
|
|
|
|
|
2015-07-30 17:34:13 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-04-30 04:00:03 +00:00
|
|
|
#endif
|