16 #ifndef MBED_QSPIF_BLOCK_DEVICE_H 17 #define MBED_QSPIF_BLOCK_DEVICE_H 20 #include "BlockDevice.h" 27 QSPIF_BD_ERROR_OK = 0,
28 QSPIF_BD_ERROR_DEVICE_ERROR = BD_ERROR_DEVICE_ERROR,
29 QSPIF_BD_ERROR_PARSING_FAILED = -4002,
30 QSPIF_BD_ERROR_READY_FAILED = -4003,
31 QSPIF_BD_ERROR_WREN_FAILED = -4004,
32 QSPIF_BD_ERROR_INVALID_ERASE_PARAMS = -4005,
33 QSPIF_BD_ERROR_DEVICE_NOT_UNIQE = -4006,
34 QSPIF_BD_ERROR_DEVICE_MAX_EXCEED = -4007
41 enum qspif_polarity_mode {
42 QSPIF_POLARITY_MODE_0 = 0,
46 #define QSPIF_MAX_REGIONS 10 47 #define MAX_NUM_OF_ERASE_TYPES 4 48 #define QSPIF_MAX_ACTIVE_FLASH_DEVICES 10 103 QSPIFBlockDevice(PinName io0, PinName io1, PinName io2, PinName io3, PinName sclk, PinName csel,
104 int clock_mode,
int freq = MBED_CONF_QSPIF_QSPI_FREQ);
137 virtual int read(
void *buffer, mbed::bd_addr_t addr, mbed::bd_size_t
size);
152 virtual int program(
const void *buffer, mbed::bd_addr_t addr, mbed::bd_size_t size);
167 virtual int erase(mbed::bd_addr_t addr, mbed::bd_size_t size);
212 virtual mbed::bd_size_t
size()
const;
218 virtual const char *
get_type()
const;
229 int add_new_csel_instance(PinName csel);
232 int remove_csel_instance(PinName csel);
239 mbed::bd_addr_t addr, mbed::bd_size_t *size);
249 mbed::bd_size_t tx_length,
const char *rx_buffer, mbed::bd_size_t rx_length);
263 int _reset_flash_mem();
266 int _set_write_enable();
269 bool _is_mem_ready();
272 int _enable_fast_mdoe();
278 int _sfdp_parse_sfdp_headers(uint32_t &basic_table_addr,
size_t &basic_table_size,
279 uint32_t §or_map_table_addr,
size_t §or_map_table_size);
282 int _sfdp_parse_basic_param_table(uint32_t basic_table_addr,
size_t basic_table_size);
285 int _sfdp_parse_sector_map_table(uint32_t sector_map_table_addr,
size_t sector_map_table_size);
288 int _sfdp_detect_best_bus_read_mode(uint8_t *basic_param_table_ptr,
int basic_param_table_size,
bool &set_quad_enable,
292 int _sfdp_set_quad_enabled(uint8_t *basic_param_table_ptr);
295 int _sfdp_set_qpi_enabled(uint8_t *basic_param_table_ptr);
298 int _sfdp_detect_page_size(uint8_t *basic_param_table_ptr,
int basic_param_table_size);
301 int _sfdp_detect_erase_types_inst_and_size(uint8_t *basic_param_table_ptr,
int basic_param_table_size,
309 int _utils_find_addr_region(mbed::bd_size_t offset);
313 int _utils_iterate_next_largest_erase_type(uint8_t &bitfield,
int size,
int offset,
int boundry);
323 static int _number_of_active_qspif_flash_csel;
324 static PinName *_active_qspif_flash_csel_arr;
326 int _unique_device_status;
343 unsigned int _erase_type_size_arr[MAX_NUM_OF_ERASE_TYPES];
347 int _region_size_bytes[QSPIF_MAX_REGIONS];
348 bd_size_t _region_high_boundary[QSPIF_MAX_REGIONS];
350 uint8_t _region_erase_types_bitfield[QSPIF_MAX_REGIONS];
351 unsigned int _min_common_erase_size;
353 unsigned int _page_size_bytes;
355 bd_size_t _device_size_bytes;
363 uint8_t _dummy_cycles;
366 uint32_t _init_ref_count;
367 bool _is_initialized;
virtual int program(const void *buffer, mbed::bd_addr_t addr, mbed::bd_size_t size)
Program blocks to a block device.
virtual mbed::bd_size_t get_program_size() const
Get the size of a programable block.
A hardware device capable of writing and reading blocks.
virtual mbed::bd_size_t get_erase_size() const
Get the size of a eraseable block.
~QSPIFBlockDevice()
Desctruct QSPIFBlockDevie.
virtual int read(void *buffer, mbed::bd_addr_t addr, mbed::bd_size_t size)
Read blocks from a block device.
virtual mbed::bd_size_t size() const
Get the total size of the underlying device.
QSPIFBlockDevice(PinName io0, PinName io1, PinName io2, PinName io3, PinName sclk, PinName csel, int clock_mode, int freq=MBED_CONF_QSPIF_QSPI_FREQ)
Create QSPIFBlockDevice - An SFDP based Flash Block Device over QSPI bus.
virtual int get_erase_value() const
Get the value of storage byte after it was erased.
virtual int deinit()
Deinitialize a block device.
virtual mbed::bd_size_t get_read_size() const
Get the size of a readable block.
enum qspi_address_size qspi_address_size_t
Address size in bits.
virtual int erase(mbed::bd_addr_t addr, mbed::bd_size_t size)
Erase blocks on a block device.
virtual int init()
Initialize a block device.
int qspi_inst_t
Type representing a QSPI instruction.
virtual const char * get_type() const
Get the BlockDevice class type.
uint8_t qspi_alt_size_t
Alternative size in bits.
enum qspi_bus_width qspi_bus_width_t
QSPI Bus width.
BlockDevice for SFDP based flash devices over QSPI bus.
A QSPI Driver, used for communicating with QSPI slave devices.
enum qspi_status qspi_status_t
QSPI return status.