Block device with SPI Flash.
More...
#include <modm/driver/storage/block_device_spiflash.hpp>
|
|
using | bd_address_t = uint32_t |
| |
|
using | bd_size_t = uint32_t |
| |
|
| enum | StatusRegister : uint8_t {
Busy = Bit0,
WriteEnabled = Bit1,
EraseSuspended = Bit2,
ProgramSuspended = Bit3,
WriteProtectionLockDown = Bit4,
SecurityIdLocked = Bit5
} |
| |
|
|
bool | initialize () |
| | Initializes the storage hardware.
|
| |
|
bool | deinitialize () |
| | Deinitializes the storage hardware.
|
| |
| bool | read (uint8_t *buffer, bd_address_t address, bd_size_t size) |
| |
| bool | program (const uint8_t *buffer, bd_address_t address, bd_size_t size) |
| |
| bool | erase (bd_address_t address, bd_size_t size) |
| |
| bool | write (const uint8_t *buffer, bd_address_t address, bd_size_t size) |
| |
| JedecId | readId () |
| |
|
| MODM_FLAGS8 (StatusRegister) |
| |
| StatusRegister | readStatus () |
| |
| void | selectDie (uint8_t die) |
| |
| bool | isBusy () |
| |
| void | waitWhileBusy () |
| |
|
bool | deinitialize () |
| | Deinitializes the storage hardware.
|
| |
| bool | erase (bd_address_t address, bd_size_t size) |
| |
|
bool | initialize () |
| | Initializes the storage hardware.
|
| |
| bool | program (const uint8_t *buffer, bd_address_t address, bd_size_t size) |
| |
| bool | read (uint8_t *buffer, bd_address_t address, bd_size_t size) |
| |
| bool | write (const uint8_t *buffer, bd_address_t address, bd_size_t size) |
| |
|
void | attachConfigurationHandler (Spi::ConfigurationHandler handler) |
| |
|
|
static constexpr bd_size_t | BlockSizeRead = 1 |
| |
|
static constexpr bd_size_t | BlockSizeWrite = 256 |
| |
|
static constexpr bd_size_t | BlockSizeErase = 4 * 1'024 |
| |
|
static constexpr bd_size_t | DeviceSize = flashSize |
| |
|
static constexpr bd_size_t | ExtendedAddressThreshold = 16 * 1'024 * 1'024 |
| |
|
static constexpr bd_size_t | BlockSizeErase = 1 |
| |
| static constexpr bd_size_t | BlockSizeRead = 1 |
| |
|
static constexpr bd_size_t | BlockSizeWrite = 1 |
| |
|
|
bool | acquireMaster () |
| |
|
bool | releaseMaster () |
| |
template<typename Spi, typename Cs, uint32_t flashSize>
class modm::BdSpiFlash< Spi, Cs, flashSize >
Block device with SPI Flash.
- Template Parameters
-
The read(), erase(),program() and write() methodes wait for the chip to finish writing to the flash.
- Author
- Raphael Lehmann
-
Rasmus Kleist Hørlyck Sørensen
| bool modm::BlockDevice::erase |
( |
bd_address_t |
address, |
|
|
bd_size_t |
size |
|
) |
| |
|
inherited |
Erase blocks
The state of an erased block is undefined until it has been programmed
- Parameters
-
| address | Address of block to begin erasing |
| size | Size to erase in bytes (multiple of read block size) |
- Returns
- True on success
template<typename Spi , typename Cs , uint32_t flashSize>
| bool modm::BdSpiFlash< Spi, Cs, flashSize >::erase |
( |
bd_address_t |
address, |
|
|
bd_size_t |
size |
|
) |
| |
Erase blocks
The state of an erased block is undefined until it has been programmed
- Parameters
-
| address | Address of block to begin erasing |
| size | Size to erase in bytes (multiple of read block size) |
- Returns
- True on success
template<typename Spi , typename Cs , uint32_t flashSize>
| bool modm::BdSpiFlash< Spi, Cs, flashSize >::isBusy |
( |
| ) |
|
Check if device is busy
- Returns
- True if device is busy.
| bool modm::BlockDevice::program |
( |
const uint8_t * |
buffer, |
|
|
bd_address_t |
address, |
|
|
bd_size_t |
size |
|
) |
| |
|
inherited |
Program blocks with data
Any block has to be erased prior to being programmed
- Parameters
-
| buffer | Buffer of data to write to blocks |
| address | Address of first block to begin writing to |
| size | Size to write in bytes (multiple of read block size) |
- Returns
- True on success
template<typename Spi , typename Cs , uint32_t flashSize>
| bool modm::BdSpiFlash< Spi, Cs, flashSize >::program |
( |
const uint8_t * |
buffer, |
|
|
bd_address_t |
address, |
|
|
bd_size_t |
size |
|
) |
| |
Program blocks with data
Any block has to be erased prior to being programmed
- Parameters
-
| buffer | Buffer of data to write to blocks |
| address | Address of first block to begin writing to |
| size | Size to write in bytes (multiple of read block size) |
- Returns
- True on success
| bool modm::BlockDevice::read |
( |
uint8_t * |
buffer, |
|
|
bd_address_t |
address, |
|
|
bd_size_t |
size |
|
) |
| |
|
inherited |
Read data from one or more blocks
- Parameters
-
| buffer | Buffer to read data into |
| address | Address to begin reading from |
| size | Size to read in bytes (multiple of read block size) |
- Returns
- True on success
template<typename Spi , typename Cs , uint32_t flashSize>
| bool modm::BdSpiFlash< Spi, Cs, flashSize >::read |
( |
uint8_t * |
buffer, |
|
|
bd_address_t |
address, |
|
|
bd_size_t |
size |
|
) |
| |
Read data from one or more blocks
- Parameters
-
| buffer | Buffer to read data into |
| address | Address to begin reading from |
| size | Size to read in bytes (multiple of read block size) |
- Returns
- True on success
template<typename Spi , typename Cs , uint32_t flashSize>
Reads the Jedec ID from the flash chip
- Returns
- The Jedec Id returned from the flash chip
template<typename Spi , typename Cs , uint32_t flashSize>
| StatusRegister modm::BdSpiFlash< Spi, Cs, flashSize >::readStatus |
( |
| ) |
|
Read status register of thew Spi Flash chip
- Returns
- Status register
template<typename Spi , typename Cs , uint32_t flashSize>
| void modm::BdSpiFlash< Spi, Cs, flashSize >::selectDie |
( |
uint8_t |
die | ) |
|
Software Die Select
- Parameters
-
| die | The pre-assigned “Die ID::” of the die to select |
template<typename Spi , typename Cs , uint32_t flashSize>
| void modm::BdSpiFlash< Spi, Cs, flashSize >::waitWhileBusy |
( |
| ) |
|
This function can be used in another resumable function to wait until the flash operation is finished.
| bool modm::BlockDevice::write |
( |
const uint8_t * |
buffer, |
|
|
bd_address_t |
address, |
|
|
bd_size_t |
size |
|
) |
| |
|
inherited |
Writes data to one or more blocks after erasing them
The blocks are erased proir to being programmed
- Parameters
-
| buffer | Buffer of data to write to blocks |
| address | Address of first block to begin writing to |
| size | Size to write in bytes (multiple of read block size) |
- Returns
- True on success
template<typename Spi , typename Cs , uint32_t flashSize>
| bool modm::BdSpiFlash< Spi, Cs, flashSize >::write |
( |
const uint8_t * |
buffer, |
|
|
bd_address_t |
address, |
|
|
bd_size_t |
size |
|
) |
| |
Writes data to one or more blocks after erasing them
The blocks are erased prior to being programmed
- Parameters
-
| buffer | Buffer of data to write to blocks |
| address | Address of first block to begin writing to |
| size | Size to write in bytes (multiple of read block size) |
- Returns
- True on success
| constexpr bd_size_t modm::BlockDevice::BlockSizeRead = 1 |
|
inheritedstaticconstexpr |
Minimum block sizes for block device operations
Most persistent storage devices require program(), erase() and sometimes read() operations to be executed on fixed sized blocks.
The documentation for this class was generated from the following file:
- block_device_spiflash.hpp