Usb host manages data exchange between connected devices and coordinates communication protocols in electronic systems.
In every USB connection there is a controller and a controlled device. The controller is the host: the device that manages all communications on the bus and controls the connected peripherals. The computer is a host, but so can be a microcontroller with the appropriate hardware, a phone, a router, or a television [1][2][3][4][5].
The USB bus is a tiered star network: the host is at the root, and each peripheral connects to a port of the host or of an hub, which replicates the bus on multiple ports. There can be up to $127$ devices per host, across a maximum of five hub tiers. No peripheral can initiate communication on its own: the host polls each according to a transfer schedule, and this organization, with a single control point, simplifies devices and makes the protocol deterministic [1][2][3].
The USB $2.0$ cable has four wires: power ($5\ \mathrm{V}$), ground, and two data wires ($D+$ and $D-$) with differential signaling. In USB $3$ two differential pairs are added, one per direction, allowing simultaneous communication in both directions. The host supplies power to peripherals: $500\ \mathrm{mA}$ to $5\ \mathrm{V}$ ($2.5\ \mathrm{W}$) for USB $2.0$ and $900\ \mathrm{mA}$ ($4.5\ \mathrm{W}$) for USB $3$; with USB Power Delivery protocols power can reach $100\ \mathrm{W}$ and beyond, with voltages up to $20\ \mathrm{V}$ and higher. The Type-C connector is reversible and supports all these modes [1][2][3][4].
The host recognizes the presence and speed of a device from the pull-up resistor on the data line. Each host line is connected to ground through a $15\ \mathrm{k\Omega}$ resistor (pull-down); the peripheral connects a $1{,}5\ \mathrm{k\Omega}$ resistor to $3.3\ \mathrm{V}$ on $D+$ (full speed) or on $D-$ (low speed). The voltage divider between $1{,}5\ \mathrm{k\Omega}$ and $15\ \mathrm{k\Omega}$ brings the line to $3.3\cdot15/16.5 = 3.0\ \mathrm{V}$ relative to ground, and the host thus detects the connection. Speeds are: low ($1.5\ \mathrm{Mbit/s}$), full ($12\ \mathrm{Mbit/s}$), high ($480\ \mathrm{Mbit/s}$), SuperSpeed ($5\ \mathrm{Gbit/s}$), and SuperSpeed+ ($10$ and $20\ \mathrm{Gbit/s}$), with further subsequent versions [1][2][3][4][5].
When a device is connected, the host performs the enumeration procedure: it resets the device, assigns it a unique $7$-bit address, reads the descriptors (identifiers of manufacturer and product, class, configurations, endpoints, and power consumption), and loads the appropriate driver. The device declares itself with a class (HID for keyboards and mice, mass storage, audio, serial communication, and others), for which the system often already has a generic driver [1][2][3].
Data passes through endpoints (numbered communication points of a device) with four types of transfer.
- Control: configuration and commands, with error checking.
- Bulk: large amounts of data without timing constraints, with delivery guarantee (mass storage, printers); they use the bandwidth left free by others.
- Interrupt: small data with limited latency; the host polls at fixed intervals (keyboards, mice).
- Isochronous: real-time streams with reserved bandwidth and no retransmission (audio, video) [1][2][3][4].
The host divides time into frames of $1\ \mathrm{ms}$ (at high speed, microframes of $125\ \mathrm{\mu s}$) and schedules packets within them. Packets are of *token* type (start of a transfer), data, and handshake (acknowledgment), with CRC error checking [1][2][3].
Nominal speeds are never reached: the protocol has overhead, bandwidth is shared among all devices on the same host, and devices are limited by their own speed. NRZI encoding with bit stuffing (after six identical bits, a zero is inserted) ensures synchronization. Available current is limited and voltage drop in long or thin cables reduces voltage. Hot plugging requires overcurrent and overvoltage protection.
A USB $2.0$ host transferring data in bulk mode (typical values).
1. Data line level with $1{,}5\ \mathrm{k\Omega}$ pull-up and $15\ \mathrm{k\Omega}$ pull-down: $3.3\cdot15/(1.5 + 15) = 3.0\ \mathrm{V}$.
2. At full speed, each frame of $1\ \mathrm{ms}$ can contain at most $19$ bulk packets of $64\ \mathrm{bytes}$: $19\cdot64\cdot1000 = 1.216\ \mathrm{MB/s}$ (versus the theoretical $1.5\ \mathrm{MB/s}$ of $12\ \mathrm{Mbit/s}$).
3. A file of $1\ \mathrm{MB}$ therefore requires $1/1.216 = 0.82\ \mathrm{s}$.
4. At high speed, $13$ packets of $512\ \mathrm{bytes}$ can be transmitted per microframe of $125\ \mathrm{\mu s}$: $13\cdot512\cdot8000 = 53.2\ \mathrm{MB/s}$, versus the theoretical $60\ \mathrm{MB/s}$ ($480\ \mathrm{Mbit/s}$).
5. A file of $1\ \mathrm{MB}$ therefore requires $19\ \mathrm{ms}$, if the device is fast enough.
A USB host is found in computers and phones, in TVs and set-top boxes, in cars (infotainment ports), in routers and printers with host ports, in development boards and microcontrollers with USB host controllers, which read flash drives, keyboards, and other peripherals.
[1] Wikipedia (it): USB
[2] Wikipedia (en): USB
[3] Wikipedia (de): Universal Serial Bus
[4] Wikipedia (fr): USB
[5] Wikipedia (ru): USB
Generating summary…