esp-open-rtos/include/espressif/spi_flash.h
sheinz a91ec6eb61 sysparam fixes, tests, spi flash refactoring (#299)
Original work by @ourairquality
* Sysparam threadsafe and SPI access
* Sysparam test cases
* Fix for negative int8
* Sysparam getting bool without memory allocation. Bool tests.
* SPI flash refactoring.
* Extract common spiflash.c into core.
* Use spiflash.c in sysparam.
* Use memcpy in spiflash.c insted of hand-written version.
* Tests for spiflash.c
2017-03-22 02:18:04 +05:00

53 lines
1.3 KiB
C

/*
* copyright (c) Espressif System 2010
*
*/
#ifndef __SPI_FLASH_H__
#define __SPI_FLASH_H__
#include "flashchip.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
SPI_FLASH_RESULT_OK,
SPI_FLASH_RESULT_ERR,
SPI_FLASH_RESULT_TIMEOUT
} sdk_SpiFlashOpResult;
#define SPI_FLASH_SEC_SIZE 4096
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);
/* Erase SPI flash sector. Parameter is sector index.
Sectors are SPI_FLASH_SEC_SIZE (4096) bytes long.
*/
sdk_SpiFlashOpResult sdk_spi_flash_erase_sector(uint16_t sec);
/* Write data to flash.
des_addr is byte offset to write to. Should be 4-byte aligned.
src is pointer to a buffer to read bytes from. Should be 4-byte aligned.
size is length of buffer in bytes. Should be a multiple of 4.
*/
sdk_SpiFlashOpResult sdk_spi_flash_write(uint32_t des_addr, uint32_t *src, uint32_t size);
/* Read data from flash.
src_addr is byte offset to read from. Should be 4-byte aligned.
des is pointer to a buffer to read bytes into. Should be 4-byte aligned.
size is number of bytes to read. Should be a multiple of 4.
*/
sdk_SpiFlashOpResult sdk_spi_flash_read(uint32_t src_addr, uint32_t *des, uint32_t size);
#ifdef __cplusplus
}
#endif
#endif