modm API documentation
modm::BdHeap< DeviceSize_, externalMemory > Class Template Reference

Block device using heap (RAM) More...

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

Inheritance diagram for modm::BdHeap< DeviceSize_, externalMemory >:
modm::BlockDevice modm::NestedResumable< 3 >

Public Typedefs

using bd_address_t = uint32_t
 
using bd_size_t = uint32_t
 

Public Member Functions

modm::ResumableResult< bool > initialize ()
 Initializes the memory with zeros.
 
modm::ResumableResult< bool > initialize (uint8_t *externalMemoryAddress)
 Data will be stored at externalMemoryAddress.
 
modm::ResumableResult< bool > deinitialize ()
 Deinitializes nothing.
 
modm::ResumableResult< bool > read (uint8_t *buffer, bd_address_t address, bd_size_t size)
 
modm::ResumableResult< bool > program (const uint8_t *buffer, bd_address_t address, bd_size_t size)
 
modm::ResumableResult< bool > erase (bd_address_t address, bd_size_t size)
 
modm::ResumableResult< bool > write (const uint8_t *buffer, bd_address_t address, bd_size_t size)
 
void setMemoryAddress (uint8_t *memory)
 
modm::ResumableResult< bool > deinitialize ()
 Deinitializes the storage hardware.
 
modm::ResumableResult< bool > erase (bd_address_t address, bd_size_t size)
 
modm::ResumableResult< bool > initialize ()
 Initializes the storage hardware.
 
modm::ResumableResult< bool > program (const uint8_t *buffer, bd_address_t address, bd_size_t size)
 
modm::ResumableResult< bool > read (uint8_t *buffer, bd_address_t address, bd_size_t size)
 
modm::ResumableResult< bool > write (const uint8_t *buffer, bd_address_t address, bd_size_t size)
 

Static Public Attributes

static constexpr bd_size_t BlockSizeRead = 1
 
static constexpr bd_size_t BlockSizeWrite = 1
 
static constexpr bd_size_t BlockSizeErase = 1
 
static constexpr bd_size_t DeviceSize = DeviceSize_
 
static constexpr bd_size_t BlockSizeErase = 1
 
static constexpr bd_size_t BlockSizeRead = 1
 
static constexpr bd_size_t BlockSizeWrite = 1
 

Protected Member Functions

modm::ResumableResult< ReturnType > resumable function (...)
 
int8_t getResumableDepth () const
 
bool isResumableRunning () const
 
void stopResumable ()
 Force all resumable functions to stop running at the current nesting level.
 

Detailed Description

template<size_t DeviceSize_, bool externalMemory = false>
class modm::BdHeap< DeviceSize_, externalMemory >

Block device using heap (RAM)

Usually not persistant, but at least useful for testing. This is also useful for battery backed SRAM, some STM32 have up to 4kB of this stuff.

Template Parameters
DeviceSizeThe size of the block device
externalMemorySet to true to use an external supplied memory block (see initialize(uint8_t*))
Author
Raphael Lehmann

Member Function Documentation

modm::ResumableResult<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
addressAddress of block to begin erasing
sizeSize to erase in bytes (multiple of read block size)
Returns
True on success
template<size_t DeviceSize_, bool externalMemory = false>
modm::ResumableResult<bool> modm::BdHeap< DeviceSize_, externalMemory >::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
modm::ResumableResult< ReturnType > resumable modm::NestedResumable< 1 >::function (   ...)
inherited

Run the resumable function.

You need to implement this method in you subclass yourself.

Returns
>NestingError if still running, <=NestingError if it has finished.
int8_t modm::NestedResumable< 1 >::getResumableDepth ( ) const
inheritedinline
Returns
the nesting depth in the current resumable function, or -1 if called outside any resumable function
bool modm::NestedResumable< 1 >::isResumableRunning ( ) const
inheritedinline
Returns
true if a resumable function is running at the current nesting level, else false
modm::ResumableResult<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
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<size_t DeviceSize_, bool externalMemory = false>
modm::ResumableResult<bool> modm::BdHeap< DeviceSize_, externalMemory >::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
modm::ResumableResult<bool> modm::BlockDevice::read ( uint8_t *  buffer,
bd_address_t  address,
bd_size_t  size 
)
inherited

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<size_t DeviceSize_, bool externalMemory = false>
modm::ResumableResult<bool> modm::BdHeap< DeviceSize_, externalMemory >::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
modm::ResumableResult<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
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<size_t DeviceSize_, bool externalMemory = false>
modm::ResumableResult<bool> modm::BdHeap< DeviceSize_, externalMemory >::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

Member Data Documentation

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: