18 #ifndef MBED_DATAFLASH_BLOCK_DEVICE_H 19 #define MBED_DATAFLASH_BLOCK_DEVICE_H 21 #include "platform/PlatformMutex.h" 23 #include "blockdevice/BlockDevice.h" 24 #include "drivers/SPI.h" 25 #include "drivers/DigitalOut.h" 27 #ifndef MBED_CONF_DATAFLASH_SPI_MOSI 28 #define MBED_CONF_DATAFLASH_SPI_MOSI NC 30 #ifndef MBED_CONF_DATAFLASH_SPI_MISO 31 #define MBED_CONF_DATAFLASH_SPI_MISO NC 33 #ifndef MBED_CONF_DATAFLASH_SPI_CLK 34 #define MBED_CONF_DATAFLASH_SPI_CLK NC 36 #ifndef MBED_CONF_DATAFLASH_SPI_CS 37 #define MBED_CONF_DATAFLASH_SPI_CS NC 39 #ifndef MBED_CONF_DATAFLASH_SPI_FREQ 40 #define MBED_CONF_DATAFLASH_SPI_FREQ 40000000 94 PinName miso = MBED_CONF_DATAFLASH_SPI_MISO,
95 PinName sclk = MBED_CONF_DATAFLASH_SPI_CLK,
96 PinName csel = MBED_CONF_DATAFLASH_SPI_CS,
97 int freq = MBED_CONF_DATAFLASH_SPI_FREQ,
119 virtual int read(
void *buffer, mbed::bd_addr_t addr, mbed::bd_size_t
size);
130 virtual int program(
const void *buffer, mbed::bd_addr_t addr, mbed::bd_size_t size);
140 virtual int erase(mbed::bd_addr_t addr, mbed::bd_size_t size);
168 virtual mbed::bd_size_t
get_erase_size(mbed::bd_addr_t addr)
const;
174 virtual mbed::bd_size_t
size()
const;
180 virtual const char *
get_type()
const;
188 uint32_t _device_size;
190 uint16_t _block_size;
191 bool _is_initialized;
192 uint32_t _init_ref_count;
195 uint16_t _get_register(uint8_t opcode);
196 void _write_command(uint32_t command,
const uint8_t *buffer, uint32_t size);
197 void _write_enable(
bool enable);
199 int _write_page(
const uint8_t *buffer, uint32_t addr, uint32_t offset, uint32_t size);
200 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.
virtual mbed::bd_size_t get_program_size() const
Get the size of a programable block.
DataFlashBlockDevice(PinName mosi=NC, PinName miso=NC, PinName sclk=NC, PinName csel=NC, int freq=40000000, PinName nwp=NC)
Creates a DataFlashBlockDevice on a SPI bus specified by pins.
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.