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>
impl<'d, A: UsbHostAllocator<'d>> BusHandle<'d, A>
Sourcepub fn free_address(&self, addr: u8)
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.
Sourcepub async fn enumerate(
&self,
route: BusRoute,
config_buf: &mut [u8],
) -> Result<(EnumerationInfo, usize), EnumerationError>
pub async fn enumerate( &self, route: BusRoute, config_buf: &mut [u8], ) -> Result<(EnumerationInfo, usize), EnumerationError>
Enumerate a connected device.
Performs the standard enumeration sequence:
- Get device descriptor (first 8 bytes) to learn EP0 max packet size
- SET_ADDRESS to assign a unique address
- Get full device descriptor
- Get configuration descriptor
- 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.