USB基础知识
发布日期:2023-10-09
点击次数:429
Basic Knowledge of USB
1. What’s USB?
USB (Universal Serial Bus) devices have the most significant advantages of hot-swappable functionality and fast transfer rates. USB is a master-slave structured system with two roles, Host and Device. In addition, there are two special types of USB devices, which are USB Hub devices and USB OTG devices.
The current protocol versions of USB are: USB1.0, USB1.1, USB2.0, USB3.0, USB4.0. USB1.0 and USB1.1 only have Low-Speed Mode and Full-Speed Mode, with theoretical maximum transfer rates of 1.5Mbps and 12Mbps respectively. USB2.0 introduces a faster transfer speed (High-Speed Mode), with a theoretical maximum transfer rate of 480Mbps. and USB3.0 in terms of speed improvement, with a theoretical maximum transfer rate of up to 5Gbps. It should be noted that these are theoretical values, which are difficult to achieve in practice (Performance optimization is required).
In the actual development process, there are different transmission rates for different transmission types. Each data interaction is a rather complex process, including the parsing of token packets, the transmission of data packets, the response of handshake packets, and so on, all of which are additional consumptions. Therefore, it is impossible to reach the theoretical value of the transmission speed. There are four types of USB transmission: Control Transmission, Interrupt Transmission, Block Transmission, and Isochronous Transmission.
2. Electrical characteristics of USB
USB uses differential transfer mode and has two data wires, which are
(1) USB Data Positive, the USB-DP wire, abbreviated as D+
(2) USB Data Minus, USB Data Minus, that is, the USB-DM wire, abbreviated as D-
The rest is the power wire (5V-VBus) and ground (GND). For USB OTG devices, there will be an additional ID wire.
3. USB host-side hardware controller type
It contains four types: OHCI / UHCI / EHCI / xHCI.
OHCI and UHCI are all USB1.1 interface standards while EHCI is USB2.0 and the latest xHCI is the USB3.0 interface standard.
OHCI: Open Host Controller Interface, the standard for USB 1.1, is not just for USB, but also supports other interfaces, such as support for Apple‘s Firewire IEEE 1394 interface. Compared with UHCI, OHCI hardware complexity, many things are left to the hardware, so the task of implementing the corresponding software driver, it is relatively simple. It is mainly used for non-x86 USB, such as expansion cards, USB master for embedded development boards.
UHCI: Universal Host Controller Interface, the Intel-led interface standard for USB 1.0 and 1.1, is not compatible with OHCI. UHCI requires more work at the software driver level and needs to be more complex.
EHCI: Enhanced Host Controller Interface, the Intel-led interface standard for USB 2.0. EHCI provides only the high-speed capabilities of USB 2.0 and relies on UHCI or OHCI to provide support for full-speed or low-speed devices.
xHCI: eXtensible Host Controller Interface, the interface standard for USB 3.0, is a major improvement over the previous 3 types in terms of speed, energy efficiency, and virtualization. xHCI supports all types of speed USB devices (SuperSpeed for USB 3.0; USB 2.0 Low-, Full-, and High-speed; USB 1.1 Low- and Full-speed) which can replace the previous 3 types (UHCI/OHCI/EHCI).
4. Identify the speed pattern of the device
For Device, according to the speed, devices working in low-speed mode are called low-speed devices; devices working in full-speed mode are called full-speed devices; Similarly, devices working in high-speed mode are called high-speed devices; For Host, there are only two types of full-speed hosts and high-speed Hosts.
4.1 Identify low-speed and full-speed devices
Both D+ and D- of the host are connected with 15K pull-down resistors; D+ of the data line of a full-speed USB device is connected with a 1.5K pull-up resistor, and once it is connected to the host, D+ of the host is pulled up; D- of the data line of a low-speed USB device is connected with a 1.5K pull-up resistor, and once it is connected to the host, D- of the host is pulled up. Therefore, the host can determine whether the connected device is a full-speed or low-speed device based on the detected results. The hardware structure diagram is as follows.
4.2 Identify high-speed devices
At the beginning, the high-speed device is connected to the host in full-speed mode, and D+ has a pull-up resistor. After the host detects that the full-speed device is connected, it resets the device and the USB device receives the reset signal and initiates the high-speed mode handshake protocol for speed identification. Next, it depends on the host side, if the host‘s USB controller supports high-speed mode transmission, the host will interact with the high-speed device to complete the high-speed mode handshake protocol. After that, both work in high-speed mode. If the host does not support high speed mode transmission, then the handshake protocol will fail and the device side will not switch to high speed mode.
The full-speed and high-speed controllers, both are DP pull-ups, and only the low-speed is a DM pull-up (when configuring the registers, you need to pay attention).
5. Classification of USB devices
This is a USB device class table extracted from the USB protocol descriptor document.
6. USB data transfer method
The USB bus is a serial bus (just like a serial port) and data is transferred one by one on the data line. the LSB comes first, the lowest bit is sent first, followed by the next lowest bit and finally the highest bit (MSB).
By HornmicLink_Bob Kuo @231009 16:05