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>
impl<'d, D: UsbHostDriver<'d>> UsbHost<'d, D>
Sourcepub fn free_address(&mut self, addr: u8)
pub fn free_address(&mut self, addr: u8)
Release a previously allocated device address.
Sourcepub fn driver_mut(&mut self) -> &mut D
pub fn driver_mut(&mut self) -> &mut D
Get a mutable reference to the underlying driver.
Sourcepub async fn wait_for_connection(&mut self) -> Speed
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.
Sourcepub async fn enumerate(
&mut self,
route: BusRoute,
config_buf: &mut [u8],
) -> Result<(EnumerationInfo, usize), EnumerationError>
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:
- 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).
§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.