Represents a storage device (e.g. flash memory) More...
#include <Device.h>
Public Types | |
enum class | Type : uint8_t { partitionType = uint8_t(Partition::Type::storage) , 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 |
const PartitionTable & | partitions () const |
Provide read-only access to partition table. More... | |
PartitionTable & | editablePartitions () |
Provide full access to partition table. More... | |
bool | loadPartitions (uint32_t tableOffset) |
Load partition table entries @tableOffset 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 storage_size_t | getSize () const =0 |
Obtain addressable size of this device. More... | |
virtual Type | getType () const =0 |
Obtain device type. More... | |
virtual bool | read (storage_size_t address, void *dst, size_t size)=0 |
Read data from the storage device. More... | |
virtual bool | write (storage_size_t address, const void *src, size_t size)=0 |
Write data to the storage device. More... | |
virtual bool | erase_range (storage_size_t address, storage_size_t size)=0 |
Erase a region of storage in preparation for writing. More... | |
virtual uint16_t | getSectorSize () const |
Get sector size, the unit of allocation for block-access devices. More... | |
virtual storage_size_t | getSectorCount () const |
Obtain total number of sectors on this device. More... | |
virtual bool | sync () |
Flush any pending writes to the physical media. More... | |
Public Member Functions inherited from LinkedObjectTemplate< Device > | |
Device * | getNext () const |
bool | insertAfter (Device *object) |
Iterator | begin () const |
Iterator | end () const |
Iterator | cbegin () const |
Iterator | cend () const |
Public Member Functions inherited from LinkedObject | |
virtual | ~LinkedObject () |
virtual LinkedObject * | next () const |
bool | insertAfter (LinkedObject *object) |
bool | operator== (const LinkedObject &other) const |
bool | operator!= (const LinkedObject &other) const |
Default sector size for block-based devices | |
static constexpr uint16_t | defaultSectorSize {512} |
PartitionTable | mPartitions |
size_t | printTo (Print &p) const |
Detailed Description
Represents a storage device (e.g. flash memory)
Member Typedef Documentation
◆ List
◆ OwnedList
Member Enumeration Documentation
◆ Type
|
strong |
Storage type.
Enumerator | |
---|---|
partitionType | |
XX |
Constructor & Destructor Documentation
◆ Device()
|
inline |
◆ ~Device()
Storage::Device::~Device | ( | ) |
Member Function Documentation
◆ editablePartitions()
|
inline |
Provide full access to partition table.
◆ erase_range()
|
pure virtual |
Erase a region of storage in preparation for writing.
- Parameters
-
address Where to start erasing size Size of region to erase, in bytes
- Return values
-
bool true on success, false on error
Implemented in Storage::Disk::BlockDevice, Storage::SpiFlash, Storage::ProgMem, Storage::SysMem, Storage::StreamDevice, and Storage::FileDevice.
◆ getBlockSize()
|
pure virtual |
Obtain smallest allocation unit for erase operations.
Implemented in Storage::SD::Card, Storage::Disk::BlockDevice, Storage::SysMem, Storage::SpiFlash, Storage::ProgMem, and Storage::FileDevice.
◆ getId()
|
inlinevirtual |
Obtain device ID.
- Return values
-
uint32_t typically flash chip ID
Reimplemented in USB::MSC::LogicalUnit, Storage::SpiFlash, and Storage::SD::Card.
◆ getName()
|
pure virtual |
Obtain unique device name.
Implemented in USB::MSC::LogicalUnit, Storage::SD::Card, Storage::Disk::HostFileDevice, Storage::SysMem, Storage::SpiFlash, Storage::ProgMem, and Storage::FileDevice.
◆ getSectorCount()
|
inlinevirtual |
Obtain total number of sectors on this device.
Reimplemented in Storage::Disk::BlockDevice.
◆ getSectorSize()
|
inlinevirtual |
Get sector size, the unit of allocation for block-access devices.
Override this method only if the device does not support standard 512-byte sector access. For example, 'Advanced-Format' drives use 4096-byte sectors.
◆ getSize()
|
pure virtual |
Obtain addressable size of this device.
- Return values
-
storage_size_t Must be at least as large as the value declared in the hardware configuration
Implemented in Storage::Disk::BlockDevice, Storage::SysMem, Storage::SpiFlash, Storage::ProgMem, and Storage::FileDevice.
◆ getType()
|
pure virtual |
Obtain device type.
Implemented in USB::MSC::LogicalUnit, Storage::Disk::HostFileDevice, Storage::SysMem, Storage::StreamDevice, Storage::SpiFlash, Storage::ProgMem, Storage::FileDevice, and Storage::SD::Card.
◆ loadPartitions() [1/2]
bool Storage::Device::loadPartitions | ( | Device & | source, |
uint32_t | tableOffset | ||
) |
Load partition table entries from another table.
- Parameters
-
source Device to load entries from @tableOffset Location of partition table to read
- Return values
-
bool true on success, false on failure
◆ loadPartitions() [2/2]
|
inline |
Load partition table entries @tableOffset Location of partition table to read.
- Return values
-
bool true on success, false on failure
◆ operator==()
|
inline |
◆ partitions()
|
inline |
Provide read-only access to partition table.
◆ printTo()
size_t Storage::Device::printTo | ( | Print & | p | ) | const |
◆ read()
|
pure virtual |
Read data from the storage device.
- Parameters
-
address Where to start reading dst Buffer to store data size Size of data to be read, in bytes.
- Return values
-
bool true on success, false on error
Implemented in Storage::Disk::BlockDevice, Storage::SpiFlash, Storage::ProgMem, Storage::SysMem, Storage::StreamDevice, and Storage::FileDevice.
◆ sync()
|
inlinevirtual |
Flush any pending writes to the physical media.
- Return values
-
bool Return false if sync operation failed.
Devices with intermediate buffering should implement this method.
Reimplemented in Storage::Disk::BlockDevice.
◆ write()
|
pure virtual |
Write data to the storage device.
- Parameters
-
address Where to start writing src Data to write size Size of data to be written, in bytes.
- Return values
-
bool true on success, false on error
Implemented in Storage::Disk::BlockDevice, Storage::SpiFlash, Storage::ProgMem, Storage::SysMem, Storage::StreamDevice, and Storage::FileDevice.
Member Data Documentation
◆ defaultSectorSize
|
staticconstexpr |
◆ mPartitions
|
protected |
The documentation for this class was generated from the following file: