17 #ifndef MBED_DATAFLASH_BLOCK_DEVICE_H 18 #define MBED_DATAFLASH_BLOCK_DEVICE_H 21 #include "BlockDevice.h" 77 int freq = MBED_CONF_DATAFLASH_SPI_FREQ,
99 virtual int read(
void *buffer, mbed::bd_addr_t addr, mbed::bd_size_t
size);
110 virtual int program(
const void *buffer, mbed::bd_addr_t addr, mbed::bd_size_t size);
120 virtual int erase(mbed::bd_addr_t addr, mbed::bd_size_t size);
148 virtual mbed::bd_size_t
get_erase_size(mbed::bd_addr_t addr)
const;
154 virtual mbed::bd_size_t
size()
const;
160 virtual const char *
get_type()
const;
169 uint32_t _device_size;
171 uint16_t _block_size;
172 bool _is_initialized;
173 uint32_t _init_ref_count;
176 uint16_t _get_register(uint8_t opcode);
177 void _write_command(uint32_t command,
const uint8_t *buffer, uint32_t size);
178 void _write_enable(
bool enable);
180 int _write_page(
const uint8_t *buffer, uint32_t addr, uint32_t offset, uint32_t size);
181 uint32_t _translate_address(bd_addr_t addr);
virtual int read(void *buffer, mbed::bd_addr_t addr, mbed::bd_size_t size)
Read blocks from a block device.
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 size() const
Get the total size of the underlying device.
virtual const char * get_type() const
Get the BlockDevice class type.
A hardware device capable of writing and reading blocks.
virtual int init()
Initialize a block device.
virtual mbed::bd_size_t get_read_size() const
Get the size of a readable block.
virtual mbed::bd_size_t get_erase_size() const
Get the size of a eraseable block.
virtual int deinit()
Deinitialize a block device.
DataFlashBlockDevice(PinName mosi, PinName miso, PinName sclk, PinName csel, int freq=MBED_CONF_DATAFLASH_SPI_FREQ, PinName nowp=NC)
Creates a DataFlashBlockDevice on a SPI bus specified by pins.
virtual mbed::bd_size_t get_program_size() const
Get the size of a programable block.
BlockDevice for DataFlash flash devices.
A digital output, used for setting the state of a pin.
A SPI Master, used for communicating with SPI slave devices.
virtual int erase(mbed::bd_addr_t addr, mbed::bd_size_t size)
Erase blocks on a block device.