18#ifndef MBED_DATAFLASH_BLOCK_DEVICE_H
19#define MBED_DATAFLASH_BLOCK_DEVICE_H
21#include "rtos/Mutex.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,
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);
BlockDevice for DataFlash flash devices.
virtual const char * get_type() const
Get the BlockDevice class type.
virtual mbed::bd_size_t get_read_size() const
Get the size of a readable block.
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 get_program_size() const
Get the size of a programable block.
virtual mbed::bd_size_t size() const
Get the total size of the underlying device.
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.
virtual mbed::bd_size_t get_erase_size() const
Get the size of a eraseable block.
virtual int deinit()
Deinitialize a block device.
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.
virtual mbed::bd_size_t get_erase_size(mbed::bd_addr_t addr) const
Get the size of an erasable block given address.
A hardware device capable of writing and reading blocks.
A digital output, used for setting the state of a pin.
An SPI Master, used for communicating with SPI slave devices.
The Mutex class is used to synchronize the execution of threads.
uint64_t bd_size_t
Type representing a quantity of 8-bit bytes.
uint64_t bd_addr_t
Type representing the address of a specific block.