Storage::Device Class Referenceabstract

Represents a storage device (e.g. flash memory) More...

#include <Device.h>

Inheritance diagram for Storage::Device:
[legend]
Collaboration diagram for Storage::Device:
[legend]

Public Types

enum  Type : uint8_t { Type::XX }
 Storage type. More...
 
using List = LinkedObjectListTemplate< Device >
 
using OwnedList = OwnedLinkedObjectListTemplate< Device >
 
- Public Types inherited from LinkedObjectTemplate< Device >
using Iterator = IteratorTemplate< Device, Device *, Device &>
 
using ConstIterator = IteratorTemplate< const Device, const Device *, const Device &>
 

Public Member Functions

 Device ()
 
 ~Device ()
 
bool operator== (const String &name) const
 
PartitionTablepartitions ()
 
const PartitionTablepartitions () const
 
bool loadPartitions (uint32_t tableOffset)
 Load partition table entries Location of partition table to read. More...
 
bool loadPartitions (Device &source, uint32_t tableOffset)
 Load partition table entries from another table. More...
 
virtual String getName () const =0
 Obtain unique device name. More...
 
virtual uint32_t getId () const
 Obtain device ID. More...
 
virtual size_t getBlockSize () const =0
 Obtain smallest allocation unit for erase operations. More...
 
virtual size_t getSize () const =0
 Obtain addressable size of this device. More...
 
virtual Type getType () const =0
 Obtain device type. More...
 
virtual bool read (uint32_t address, void *dst, size_t size)=0
 Read data from the storage device. More...
 
virtual bool write (uint32_t address, const void *src, size_t size)=0
 Write data to the storage device. More...
 
virtual bool erase_range (uint32_t address, size_t size)=0
 Erase a region of storage in preparation for writing. More...
 
- Public Member Functions inherited from LinkedObjectTemplate< Device >
Device * getNext () const
 
Iterator begin () const
 
Iterator end () const
 
Iterator cbegin () const
 
Iterator cend () const
 
- Public Member Functions inherited from LinkedObject
virtual ~LinkedObject ()
 
virtual LinkedObjectnext () const
 
LinkedObjectgetNext () const
 
bool operator== (const LinkedObject &other) const
 
bool operator!= (const LinkedObject &other) const
 

Protected Attributes

PartitionTable mPartitions
 

Detailed Description

Represents a storage device (e.g. flash memory)

Member Typedef Documentation

◆ List

◆ OwnedList

Member Enumeration Documentation

◆ Type

enum Storage::Device::Type : uint8_t
strong

Storage type.

Enumerator
XX 

Constructor & Destructor Documentation

◆ Device()

Storage::Device::Device ( )
inline

◆ ~Device()

Storage::Device::~Device ( )

Member Function Documentation

◆ erase_range()

virtual bool Storage::Device::erase_range ( uint32_t  address,
size_t  size 
)
pure virtual

Erase a region of storage in preparation for writing.

Parameters
addressWhere to start erasing
sizeSize of region to erase, in bytes
Return values
booltrue on success, false on error

Implemented in Storage::FileDevice, Storage::SysMem, Storage::StreamDevice, Storage::ProgMem, and Storage::SpiFlash.

◆ getBlockSize()

virtual size_t Storage::Device::getBlockSize ( ) const
pure virtual

Obtain smallest allocation unit for erase operations.

Implemented in Storage::FileDevice, Storage::SysMem, Storage::ProgMem, and Storage::SpiFlash.

◆ getId()

virtual uint32_t Storage::Device::getId ( ) const
inlinevirtual

Obtain device ID.

Return values
uint32_ttypically flash chip ID

Reimplemented in Storage::SpiFlash.

◆ getName()

virtual String Storage::Device::getName ( ) const
pure virtual

Obtain unique device name.

Implemented in Storage::FileDevice, Storage::SpiFlash, Storage::SysMem, and Storage::ProgMem.

◆ getSize()

virtual size_t Storage::Device::getSize ( ) const
pure virtual

Obtain addressable size of this device.

Return values
size_tMust be at least as large as the value declared in the partition table

Implemented in Storage::FileDevice, Storage::SysMem, Storage::ProgMem, and Storage::SpiFlash.

◆ getType()

virtual Type Storage::Device::getType ( ) const
pure virtual

◆ loadPartitions() [1/2]

bool Storage::Device::loadPartitions ( uint32_t  tableOffset)
inline

Load partition table entries Location of partition table to read.

Return values
booltrue on success, false on failure

◆ loadPartitions() [2/2]

bool Storage::Device::loadPartitions ( Device source,
uint32_t  tableOffset 
)

Load partition table entries from another table.

Parameters
sourceDevice to load entries from Location of partition table to read
Return values
booltrue on success, false on failure

◆ operator==()

bool Storage::Device::operator== ( const String name) const
inline

◆ partitions() [1/2]

PartitionTable& Storage::Device::partitions ( )
inline

◆ partitions() [2/2]

const PartitionTable& Storage::Device::partitions ( ) const
inline

◆ read()

virtual bool Storage::Device::read ( uint32_t  address,
void *  dst,
size_t  size 
)
pure virtual

Read data from the storage device.

Parameters
addressWhere to start reading
dstBuffer to store data
sizeSize of data to be read, in bytes.
Return values
booltrue on success, false on error

Implemented in Storage::FileDevice, Storage::SysMem, Storage::ProgMem, Storage::StreamDevice, and Storage::SpiFlash.

◆ write()

virtual bool Storage::Device::write ( uint32_t  address,
const void *  src,
size_t  size 
)
pure virtual

Write data to the storage device.

Parameters
addressWhere to start writing
srcData to write
sizeSize of data to be written, in bytes.
Return values
booltrue on success, false on error

Implemented in Storage::FileDevice, Storage::StreamDevice, Storage::SysMem, Storage::ProgMem, and Storage::SpiFlash.

Member Data Documentation

◆ mPartitions

PartitionTable Storage::Device::mPartitions
protected

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