embassy-usb-host

Crates

git

Versions

default

Flavors

BusHandle

Struct BusHandle 

Source
pub struct BusHandle<'d, A: UsbHostAllocator<'d>> { /* private fields */ }
Expand description

Shareable handle for pipe allocation and device enumeration.

A BusHandle bundles a UsbHostAllocator produced by a UsbHostController with a reference to the bus-wide BusState.

BusHandle itself implements UsbHostAllocator by forwarding to its inner allocator, so it can be passed directly to class driver constructors.

Implementations§

Source§

impl<'d, A: UsbHostAllocator<'d>> BusHandle<'d, A>

Source

pub fn state(&self) -> &'d BusState

Borrow the shared bus state.

Source

pub fn free_address(&self, addr: u8)

Release a previously allocated device address.

Equivalent to self.state().free_address(addr). Must be called by application code when a device is removed.

Source

pub async fn enumerate( &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).

Enumerations are serialised bus-wide through the BusState’s enumeration mutex.

§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 the number of bytes written to config_buf.

Trait Implementations§

Source§

impl<'d, A: Clone + UsbHostAllocator<'d>> Clone for BusHandle<'d, A>

Source§

fn clone(&self) -> BusHandle<'d, A>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'d, A: UsbHostAllocator<'d>> UsbHostAllocator<'d> for BusHandle<'d, A>

Source§

type Pipe<T: Type, D: Direction> = <A as UsbHostAllocator<'d>>::Pipe<T, D>

Pipe implementation produced by this allocator.
Source§

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

Allocate a pipe for communication with a device endpoint. Read more

Auto Trait Implementations§

§

impl<'d, A> Freeze for BusHandle<'d, A>
where A: Freeze,

§

impl<'d, A> !RefUnwindSafe for BusHandle<'d, A>

§

impl<'d, A> Send for BusHandle<'d, A>
where A: Send,

§

impl<'d, A> Sync for BusHandle<'d, A>
where A: Sync,

§

impl<'d, A> Unpin for BusHandle<'d, A>
where A: Unpin,

§

impl<'d, A> !UnwindSafe for BusHandle<'d, A>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.