#ifndef SPI_FLASH_H #define SPI_FLASH_H #include #include #if defined ( __ICCARM__ ) #define ssize_t long #else #include #endif #include "FreeRTOS.h" #include "task.h" #include "semphr.h" #define SPI_FLASH_SECTOR_SIZE 4096 #define SPI_FLASH_SECTORS_IN_BLOCK_NUMBER 16 #define SPI_FLASH_BLOCK_SIZE 16 #define SPI_FLASH_BLOCK_NUMBER 32 //extern SemaphoreHandle_t spi_mutex; typedef struct { bool present; uint32_t sector_size; uint8_t sector_erase_op; uint16_t sector_count; } spi_flash_desc_t; extern bool spi_flash_init(void); extern ssize_t spi_flash_read(int addr, void *buf, size_t len, uint32_t timeout); extern ssize_t spi_flash_write(int addr, const void *buf, size_t len, uint32_t timeout); extern int spi_flash_erase_sector(int addr, uint32_t timeout); extern int spi_flash_chip_erase(uint32_t timeout); extern unsigned int spi_flash_get_sector_size(void); extern unsigned int spi_flash_get_sector_count(void); extern unsigned int spi_flash_get_total_size(void); bool spi_flash_is_init(void); bool spi_flash_test(void); //void init_spi_mutex(void); // -------------------------------------------------------------------------- // void spi_flash_get_id(uint8_t *buf); // -------------------------------------------------------------------------- // #endif /* SPI_FLASH_H */