embassy-usb-host

Crates

git

Versions

default

Flavors

UsbHost

Struct UsbHost 

Source
pub struct UsbHost<D: UsbHostDriver> { /* private fields */ }
Expand description

USB host controller.

Manages device connection, enumeration, and class driver binding.

Implementations§

Source§

impl<D: UsbHostDriver> UsbHost<D>

Source

pub fn new(driver: D) -> Self

Create a new USB host from a driver.

Source

pub fn free_address(&mut self, addr: u8)

Release a previously allocated device address.

Source

pub fn driver(&self) -> &D

Get a reference to the underlying driver.

Source

pub fn driver_mut(&mut self) -> &mut D

Get a mutable reference to the underlying driver.

Source

pub async fn wait_for_connection(&mut self) -> Speed

Wait for a device to connect.

Issues a bus reset internally and returns the detected speed.

Source

pub async fn enumerate( &mut self, speed: Speed, config_buf: &mut [u8], ) -> Result<(DeviceDescriptor, u8, usize), EnumerationError>

Enumerate a connected device.

Performs the standard enumeration sequence:

  1. Get device descriptor (first 8 bytes) to learn EP0 max packet size
  2. SET_ADDRESS to assign a unique address
  3. Get full device descriptor
  4. Get configuration descriptor
  5. SET_CONFIGURATION

Returns the device descriptor, assigned address, and bytes written to config_buf.

Auto Trait Implementations§

§

impl<D> Freeze for UsbHost<D>
where D: Freeze,

§

impl<D> RefUnwindSafe for UsbHost<D>
where D: RefUnwindSafe,

§

impl<D> Send for UsbHost<D>
where D: Send,

§

impl<D> Sync for UsbHost<D>
where D: Sync,

§

impl<D> Unpin for UsbHost<D>
where D: Unpin,

§

impl<D> UnwindSafe for UsbHost<D>
where D: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.