Expand description
USB Mass Storage Class host driver (Bulk-Only Transport, SCSI transparent).
Implements the MSC BBB transport (USB MSC BBB r1.0): every SCSI
command runs as a CBW → optional data phase → CSW cycle on a pair
of bulk endpoints, with stall recovery via CLEAR_FEATURE and
phase-error recovery via the class-specific Bulk-Only Mass Storage
Reset. Only subclass 0x06 (SCSI transparent) / protocol 0x50
(BBB) interfaces are recognized.
An MscDevice owns the control and bulk pipes for one MSC
interface. Per-LUN handles are opened with MscDevice::lun;
all LUNs share the same transport and their commands serialize
through the device’s internal async mutex.
MscDevice::new guards the transport with a NoopRawMutex;
use MscDevice::new_with_raw_mutex with a Sync raw mutex
(e.g. CriticalSectionRawMutex) when LUNs are driven from
multiple tasks.
§Example
use embassy_usb_host::class::msc::MscDevice;
let device = MscDevice::new(&bus, &enum_info, &config_buf[..config_len]).await?;
let mut lun = device.lun(0)?;
let mut inq = [0u8; 36];
let info = lun.inquiry(&mut inq).await?;
let cap = lun.capacity().await?;
let mut block = [0u8; 512];
lun.read_blocks(0, &mut block).await?;Structs§
- Block
Capacity - Block-device capacity derived from
READ CAPACITY(10)or(16). - Inquiry
Data - Decoded
INQUIRYstandard response (SPC-3 §6.4.2). - MscDevice
- USB Mass Storage Class host device.
- MscInfo
- Descriptor-located info for the MSC interface.
- MscLun
- Handle for a single Logical Unit.
- Sense
Data - Decoded fixed-format sense data (SPC-3 §4.5.3).
Enums§
- Command
Outcome - Result of a
MscDevice::commandcycle whose CSW was received. - DataDir
- Direction and buffer for the optional data phase of a SCSI command.
- MscError
- MSC host driver error.
- Peripheral
Type - SCSI peripheral-device type (SPC-3 §6.4.2, bits 0..4 of INQUIRY byte 0).
- Sense
Key - SCSI sense key (SPC-3 §4.5.6, Table 27).
Functions§
- find_
msc - Locate the first SCSI/BBB interface in
config_desc.