Introduction to USB--Part 3, Page 2.
1-5-4 DEVICE STATES
The USB 2.0 specification defines six different states and is listed in Table 1-7.
1-5-5 HOST CONTROLLERS
On typical desktop/laptop today, we can typically find multiple USB ports. These ports are driven by USB host controllers.
Each host controller can drive one bus by itself (up to 127 devices on one host port). It can provide current up to 500 mA at 5 Volts. The host controller is responsible for complete bus management. When the host controller does not recognize a device, it can reset the device. The controller can shut down USB ports to save power.
A host needs to check the following three items before authorizing a device on the bus:
- Can it supply the power required by the device?
- Does it have the driver matching the configuration requirements provided by the device during enumeration?
- Does the bus have sufficient bandwidth to satisfy the requirements of the device?
If these three elements are not met, the host will not enable the device on the bus.
When the host transmits a packet of data, the packet is sent to every device connected to a given port. Only one device, the addressed one, actually accepts the data. And only one device at a time is able to transmit data to the host, in response to a direct request from the host. Each hub in the chain repeats and resynchronizes the data as it relays it.
As stated above a maximum of 127 devices (including hubs) may be connected. This is because the address field in a packet is 7 bits long, and the address 0 cannot be used as it has special significance. (In most systems the bus would be running out of bandwidth, or other resources, long before the 127 devices was reached.)
Although host controllers that adhere to the OHCI, UHCI and EHCI standards are common on desktops and laptop computers, many of the MCUs that feature integrated USB host controllers do not follow these standards. Sometimes, the host controller does not include certain hardware-managed operations that are defined in the standard, or sometimes, additional hardware is added to the MCU for customized automation. The result is that standard USB host drivers cannot be used with such MCUs, which complicates product development.
1-6 USB PACKETS
The fundamental element of communications is the packet.
A packet is made of three parts: SYNC, INFORMATION, and END-OF-PACKET (EOP).
The SYNC field is 8 bits long at low and full speed, or 32 bits long at high speed. It is used to synchronize the clock of the receiver with that of the transmitter. The SYNC pattern is a chirp of either 8 bits (full-/low-speed) or 32 bits (high-speed) where each bit is a J or K state:
The last two bits indicate where the PID fields starts.
The INFORMATION field varies from 1 byte up to 1024 bytes
- Packet Identifier (PID) – 4bits + complement
- Payload and CRC – Not present in handshake packets
End of packet. The EOP field is indicated by having both D+ and D- low for 3 bits (full-/low-speed) or 8 bits (high-speed).
Next: USB Packet Types
µC/USB Device: Universal Serial Bus Device Stack for the Renesas RX63N, Chapter 2, by Christian Legare, is excerpted with permission. The text is available at Micrium.