1-5 USB TOPOLOGY
USB can connect a series of devices using a tiered star topology. The key elements in USB topology are the host, hubs, and devices, as illustrated in Figure 1-16. Each node in the illustration represents a USB hub or a USB device. At the top level of the graph is the root hub, which is part of the host. There is only one host in the system. The specification allows up to seven tiers and a maximum of five non-root hubs in any path between the host and a device. Each tier must contain at least one hub except for the last tier where only devices are present. Each USB device in the system has a unique address assigned by the host through a process called enumeration (see section 1-12 on page 58 for more details on enumeration).
The host learns about the device capabilities during enumeration, which allows the host operating system to load a specific driver for a particular USB device. The maximum number of peripherals that can be attached to a host is 127, including the root hub.
USB QUICK FACTS
- Star network configuration
- Only one host
- Maximum of seven levels of tiers, with each tier formed from a hub
- Host and hubs provide power to slaves
- Maximum of 5 metres per cable
- Maximum of 127 devices (hubs and root hub included)
- The host schedules and initiates data transfers.
1-5-1 USB HOST
The USB host communicates with the devices using a USB host controller. The host is responsible for detecting and enabling devices, managing bus access, performing error checking, providing and managing power, and exchanging data with the devices. Since USB devices are not responsible for these tasks, designing a USB device is a simpler job.
The host’s communication with devices consist mainly of queries. For example, on power up, or when a device is connected to the host, the host queries the device capabilities during a process called enumeration (see section 1-12 “Enumeration” on page 58).
1-5-2 USB DEVICE
A USB device implements one or more USB functions, where a function provides one specific capability to the system. Examples of USB functions are keyboards, webcam, speakers, or a mouse. The requirements of each USB function are described in the USB class specification. For example, keyboards and mice are implemented using the Human Interface Device (HID) specification.
A device cannot initiate a transaction, nor can two devices communicate directly with each other; these activities are mediated by the host. There are a variety of transaction methods for data transmission (see transfer modes), and a token-based protocol is used (see packets). When the host identifies the presence of a device on the bus, the host start transmitting frames to the device (see Frames).
1-5-3 USB DEVICE STRUCTURE
From the host’s point of view, USB devices are internally organized as a collection of configurations, interfaces and endpoints.
A USB configuration specifies the capabilities of a device. A configuration consists of a collection of USB interfaces that implement one or more USB functions. Typically only one configuration is required for a given device. However, the USB specification allows up to 255 different configurations. During enumeration, the host selects a configuration. Only one configuration can be active at a time. The device uses a configuration descriptor to inform the host about a specific configuration’s capabilities.
A USB interface or a group of interfaces provides information about a function or class implemented by the device. An interface can contain multiple mutually exclusive settings called alternate settings . The device uses an interface descriptor to inform the host about a specific interface’s capabilities. Each interface descriptor contains a class, subclass, and protocol codes defined by the USB-IF, and the number of endpoints required for a particular class implementation.
Alternate settings are used by the device to specify mutually exclusive settings for each interface. The default alternate settings contain the default settings of the device. The device also uses an interface descriptor to inform the host about an interface’s alternate settings.
An interface requires a set of endpoints to communicate with the host. Each interface has different requirements in terms of the number of endpoints, transfer type, direction, maximum packet size, and maximum polling interval. The device sends an endpoint descriptor to notify the host about endpoint capabilities.
Figure 1-17 shows the hierarchical organization of a USB device. Configurations are grouped based on the device’s speed. A high-speed device might have a particular configuration in both high-speed and low/full speed.