Skip to main content

Module hub

Module hub 

Source
Expand description

USB hubs.

A hub is an ordinary device with one class-specific interface: the host powers its downstream ports, waits for a device to appear, resets the port and then enumerates the new device at address zero. Hub wraps the Device that enumerated the hub and performs those steps.

let device = host.enumerate()?;             // the hub itself
let hub = Hub::open(&device)?;              // SET_CONFIGURATION + hub descriptor
hub.power_ports()?;                         // PORT_POWER on every port
hub.wait_for_connection(1, 2000)?;          // something was plugged in
hub.reset_port(1)?;                         // PORT_RESET, wait for C_PORT_RESET
let child = hub.enumerate_child(1, address)?;

The hub is left configured and powered, so a later device on the same port only needs reset_port and enumerate_child.

Devices behind a high-speed hub that run at full or low speed need the hub’s transaction translator. enumerate_child records it in the HubRoute it hands to the controller; controllers without split-transaction support report HostError::Unsupported.

Structs§

Hub
An enumerated hub.
HubDescriptor
The hub class descriptor (USB 2.0 §11.23.2.1).
HubPortStatus
What GET_STATUS reports for a downstream port.