pub struct MscClass<'d, D: Driver<'d>> { /* private fields */ }Expand description
USB Mass Storage Class (MSC) implementation.
Implementations§
Source§impl<'d, D: Driver<'d>> MscClass<'d, D>
impl<'d, D: Driver<'d>> MscClass<'d, D>
Sourcepub fn new(
builder: &mut Builder<'d, D>,
state: &'d mut State<'d>,
config: Config,
) -> Self
pub fn new( builder: &mut Builder<'d, D>, state: &'d mut State<'d>, config: Config, ) -> Self
Creates a new MSC class with configuration.
Sourcepub fn max_packet_size(&self) -> u16
pub fn max_packet_size(&self) -> u16
Gets the endpoint max packet size in bytes.
Sourcepub async fn wait_connection(&mut self)
pub async fn wait_connection(&mut self)
Waits for the USB host to enable this interface.
Sourcepub async fn run<B: AsyncBlockDevice>(
&mut self,
block_device: &mut B,
block_buf: &mut [u8],
) -> StopReason
pub async fn run<B: AsyncBlockDevice>( &mut self, block_device: &mut B, block_buf: &mut [u8], ) -> StopReason
Runs the MSC BOT state machine until the host ejects the medium.
Disconnects and reconnects are handled internally. When this returns, the
host has received the status of the eject command but the device is still
attached: disable the USB device, or call run again to keep serving commands.
block_buf is a temporary buffer used for block transfers and must be at
least block_device.block_size() and max_packet_size bytes long.
A buffer of two or more blocks is split in two halves, so the USB transfer of
one half overlaps with block_device reading or writing the other. Each call
to block_device moves up to half the buffer, so a buffer of several blocks
speeds up large transfers.