files_storage_driver.h
1 #pragma once 2 3 #ifdef __cplusplus 4 extern "C" { 5 #endif // __cplusplus 6 7 #include "stdint.h" 8 #include "stdlib.h" 9 #include "stdbool.h" 10 11 typedef enum 12 { 13 FILES_STORAGE_SUCCESS = 0, 14 FILES_STORAGE_ERROR_INTERNAL, 15 FILES_STORAGE_ERROR_NO_MEM, 16 FILES_STORAGE_ERROR_NOT_SUPPORTED, 17 FILES_STORAGE_ERROR_INVALID_PARAM, 18 FILES_STORAGE_ERROR_INVALID_STATE, 19 FILES_STORAGE_ERROR_INVALID_LENGTH, 20 FILES_STORAGE_ERROR_TIMEOUT, 21 FILES_STORAGE_ERROR_FORBIDDEN, 22 FILES_STORAGE_ERROR_NULL, 23 FILES_STORAGE_ERROR_INVALID_ADDR, 24 FILES_STORAGE_ERROR_BUSY, 25 FILES_STORAGE_ERROR_ALREADY_INITIALIZED, 26 } files_storage_error_t; 27 28 typedef struct files_storage_info_s { 29 bool initialized; 30 size_t sector_size; 31 size_t sector_count; 32 size_t block_size; 33 size_t block_count; 34 int32_t (*configure_qspi)(void); 35 const char* name; 36 } files_storage_info_t; 37 38 typedef struct files_storage_driver_s { 39 files_storage_error_t (*initialize)(void); 40 files_storage_error_t (*uninitialize)(void); 41 files_storage_error_t (*read)(uint32_t address, uint8_t* buffer, size_t buffer_size); 42 files_storage_error_t (*program)(uint32_t address, const uint8_t* data, size_t data_length); 43 files_storage_error_t (*erase_sector)(uint32_t address); 44 files_storage_error_t (*sync)(void); 45 files_storage_info_t* info; 46 } files_storage_driver_t; 47 48 #ifdef __cplusplus 49 } 50 #endif // __cplusplus