embassy-usb-host

Crates

git

Versions

default

Flavors

UsbHost

Struct UsbHost 

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

USB host controller.

Manages device connection, enumeration, and class driver binding.

Implementations§

Source§

impl<'d, D: UsbHostDriver<'d>> UsbHost<'d, 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, route: BusRoute, config_buf: &mut [u8], ) -> Result<(EnumerationInfo, 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

route describes how the device is reached on the bus (directly at its native speed, or via split transactions / legacy PRE through a hub’s transaction translator).

§Preconditions

The caller must have placed the device into the default (address 0) state before calling this method. For a root-port device that means an upstream bus reset has completed; for a hub-attached device, the parent hub’s port reset must have completed and BusRoute::Translated must carry the appropriate SplitInfo.

Returns the EnumerationInfo for the device and bytes written to config_buf.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<'d, D> UnwindSafe for UsbHost<'d, 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.