embassy-usb-host

Crates

git

Versions

default

Flavors

Module msc

Module msc 

Source
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§

BlockCapacity
Block-device capacity derived from READ CAPACITY(10) or (16).
InquiryData
Decoded INQUIRY standard 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.
SenseData
Decoded fixed-format sense data (SPC-3 §4.5.3).

Enums§

CommandOutcome
Result of a MscDevice::command cycle whose CSW was received.
DataDir
Direction and buffer for the optional data phase of a SCSI command.
MscError
MSC host driver error.
PeripheralType
SCSI peripheral-device type (SPC-3 §6.4.2, bits 0..4 of INQUIRY byte 0).
SenseKey
SCSI sense key (SPC-3 §4.5.6, Table 27).

Functions§

find_msc
Locate the first SCSI/BBB interface in config_desc.