A USB mass storage device supports one or more logical units, each of which is a physical storage device. More...
#include <HostDevice.h>
Public Types | |
using | EnumCallback = Delegate< bool(LogicalUnit &unit, const Inquiry &inquiry)> |
Callback passed to enumerate() method. More... | |
Public Member Functions | |
bool | begin (const Instance &inst) |
void | end () |
Called when device is disconnected. Override as required. More... | |
bool | enumerate (EnumCallback callback) |
Enumerate all logical units managed by this device. More... | |
LogicalUnit * | operator[] (unsigned lun) const |
Access a specific logical unit by number. More... | |
size_t | getSectorSize (uint8_t lun) const |
Get the declared block/sector size for a unit. More... | |
storage_size_t | getSectorCount (uint8_t lun) const |
Get the number of blocks/sectors for a unit. More... | |
bool | read_sectors (uint8_t lun, uint32_t lba, void *dst, size_t size) |
Read data from a unit. More... | |
bool | write_sectors (uint8_t lun, uint32_t lba, const void *src, size_t size) |
Write data to a unit. More... | |
bool | wait () |
Wait for all outstanding operations to complete. More... | |
![]() | |
void | begin (const Instance &inst) |
Descendant classes should override this method to peform initialisation. More... | |
const char * | getName () const |
uint8_t | getAddress () const |
bool | operator== (const HostInterface &other) const |
bool | operator== (const Instance &other) const |
Public Attributes | |
std::unique_ptr< LogicalUnit > | units [MAX_LUN] {} |
Static Public Attributes | |
static constexpr size_t | MAX_LUN {CFG_TUH_MSC_MAXLUN} |
Additional Inherited Members | |
![]() | |
Instance | inst |
Detailed Description
A USB mass storage device supports one or more logical units, each of which is a physical storage device.
Member Typedef Documentation
◆ EnumCallback
using USB::MSC::HostDevice::EnumCallback = Delegate<bool(LogicalUnit& unit, const Inquiry& inquiry)> |
Callback passed to enumerate() method.
- Parameters
-
unit The logical unit attached to a device inquiry Detailed information
- Return values
-
bool true to continue enumeration, false to stop
Member Function Documentation
◆ begin()
◆ end()
|
virtual |
Called when device is disconnected. Override as required.
Reimplemented from USB::HostInterface.
◆ enumerate()
bool USB::MSC::HostDevice::enumerate | ( | EnumCallback | callback | ) |
Enumerate all logical units managed by this device.
- Parameters
-
callback Invoked for each discovered Logical Unit
◆ getSectorCount()
|
inline |
Get the number of blocks/sectors for a unit.
- Parameters
-
lun The logical Unit Number
- Return values
-
size_t Number of blocks, 0 if invalid
◆ getSectorSize()
Get the declared block/sector size for a unit.
- Parameters
-
lun The logical Unit Number
- Return values
-
size_t Block size in bytes, or 0 if invalid
◆ operator[]()
|
inline |
Access a specific logical unit by number.
- Parameters
-
lun The logical Unit Number
- Return values
-
LogicalUnit* The corresponding LU, or nullptr if invalid
◆ read_sectors()
Read data from a unit.
- Parameters
-
lun The logical Unit Number lba Starting Logical Block Address dst Buffer to store data size Number of sectors to read
- Return values
-
bool true on success
◆ wait()
bool USB::MSC::HostDevice::wait | ( | ) |
Wait for all outstanding operations to complete.
- Parameters
-
lun The logical Unit Number
- Return values
-
bool false on error (e.g. device forceably disconnected)
Write operations are asynchronous so calling this method ensures that the operation has completed.
◆ write_sectors()
bool USB::MSC::HostDevice::write_sectors | ( | uint8_t | lun, |
uint32_t | lba, | ||
const void * | src, | ||
size_t | size | ||
) |
Write data to a unit.
- Parameters
-
lun The logical Unit Number lba Starting Logical Block Address src Data to write size Number of sectors to write
- Return values
-
bool true on success
Member Data Documentation
◆ MAX_LUN
|
staticconstexpr |
◆ units
std::unique_ptr<LogicalUnit> USB::MSC::HostDevice::units[MAX_LUN] {} |
The documentation for this class was generated from the following file: