modm API documentation
modm::BdSpiStackFlash< SpiBlockDevice, DieCount > Class Template Reference

SpiStack homogenoues memory. More...

#include <modm/driver/storage/block_device_spistack_flash.hpp>

Inheritance diagram for modm::BdSpiStackFlash< SpiBlockDevice, DieCount >:
modm::BlockDevice

Public Typedefs

using bd_address_t = uint32_t
 
using bd_size_t = uint32_t
 

Public Member Functions

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)
 
bool isBusy ()
 
void waitWhileBusy ()
 

Static Public Attributes

static constexpr bd_size_t BlockSizeRead = SpiBlockDevice::BlockSizeRead
 
static constexpr bd_size_t BlockSizeWrite = SpiBlockDevice::BlockSizeWrite
 
static constexpr bd_size_t BlockSizeErase = SpiBlockDevice::BlockSizeErase
 
static constexpr bd_size_t DieSize = SpiBlockDevice::DeviceSize
 
static constexpr bd_size_t DeviceSize = DieCount * DieSize
 

Detailed Description

template<typename SpiBlockDevice, uint8_t DieCount>
class modm::BdSpiStackFlash< SpiBlockDevice, DieCount >

SpiStack homogenoues memory.

The read(), erase(),program() and write() methodes wait for the chip to finish writing to the flash.

Template Parameters
SpiBlockDeviceBase SPI block device of the homogenous stack
Author
Rasmus Kleist Hørlyck Sørensen

Member Function Documentation

template<typename SpiBlockDevice , uint8_t DieCount>
bool modm::BdSpiStackFlash< SpiBlockDevice, DieCount >::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
addressAddress of block to begin erasing
sizeSize to erase in bytes (multiple of read block size)
Returns
True on success
template<typename SpiBlockDevice , uint8_t DieCount>
bool modm::BdSpiStackFlash< SpiBlockDevice, DieCount >::isBusy ( )

Check if device is busy

Returns
True if any die in the stack is busy.
template<typename SpiBlockDevice , uint8_t DieCount>
bool modm::BdSpiStackFlash< SpiBlockDevice, DieCount >::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
bufferBuffer of data to write to blocks
addressAddress of first block to begin writing to
sizeSize to write in bytes (multiple of read block size)
Returns
True on success
template<typename SpiBlockDevice , uint8_t DieCount>
bool modm::BdSpiStackFlash< SpiBlockDevice, DieCount >::read ( uint8_t *  buffer,
bd_address_t  address,
bd_size_t  size 
)

Read data from one or more blocks

Parameters
bufferBuffer to read data into
addressAddress to begin reading from
sizeSize to read in bytes (multiple of read block size)
Returns
True on success
template<typename SpiBlockDevice , uint8_t DieCount>
void modm::BdSpiStackFlash< SpiBlockDevice, DieCount >::waitWhileBusy ( )

This function can be used in another resumable function to wait until the flash operation is finished.

template<typename SpiBlockDevice , uint8_t DieCount>
bool modm::BdSpiStackFlash< SpiBlockDevice, DieCount >::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
bufferBuffer of data to write to blocks
addressAddress of first block to begin writing to
sizeSize to write in bytes (multiple of read block size)
Returns
True on success

The documentation for this class was generated from the following file: