embassy-usb-driver

Crates

git

Versions

default

Flavors

UsbHostDriver

Trait UsbHostDriver 

Source
pub trait UsbHostDriver: Sized {
    type Pipe<T: Type, D: Direction>: UsbPipe<T, D>;

    // Required methods
    async fn wait_for_device_event(&self) -> DeviceEvent;
    async fn bus_reset(&self);
    fn alloc_pipe<T: Type, D: Direction>(
        &self,
        addr: u8,
        endpoint: &EndpointInfo,
        split: Option<SplitInfo>,
    ) -> Result<Self::Pipe<T, D>, HostError>;
}
Expand description

Async USB Host Driver trait. To be implemented by the HAL.

Required Associated Types§

Source

type Pipe<T: Type, D: Direction>: UsbPipe<T, D>

Pipe implementation of this UsbHostDriver

Required Methods§

Source

async fn wait_for_device_event(&self) -> DeviceEvent

Wait for a root-port attach/detach.

On attach, the implementation must drive a bus reset to completion before returning and must report the speed that the device settled on after reset.

Source

async fn bus_reset(&self)

Force a bus reset on the root port.

Invalidates every pipe currently allocated against addresses other than 0. Used to recover from a misbehaving device or to force re-enumeration without unplug.

Source

fn alloc_pipe<T: Type, D: Direction>( &self, addr: u8, endpoint: &EndpointInfo, split: Option<SplitInfo>, ) -> Result<Self::Pipe<T, D>, HostError>

Allocate pipe for communication with device.

This can be a scarce resource, for one-off requests please scope the pipe so it’s dropped after completion.

split - when Some, every transfer on this pipe is routed as a split transaction through the specified hub’s TT (USB 2.0 §11.14), or as a legacy PRE packet on full-speed controllers (USB 1.1 §11.8.6). Pass None when the device is reached directly (host at the same speed as the device, or the device is high-speed).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§