Before the USB function (or functions, in a compound device) can be operated,
the device must be configured. The host does the configuring by acquiring the
configuration information from the USB device. USB devices report their
attributes by descriptors. A descriptor is the defined structure and
format in which the data is transferred. A complete description of the USB
descriptors can be found in Chapter 9 of the USB Specification (see
http://www.usb.org for the full specification).
It is best to view the USB descriptors as a hierarchical structure with four
levels:
-
The Device level
-
The Configuration level
-
The Interface level (this level may include an optional
sub-level called Alternate Setting)
-
The Endpoint level
There is only one device descriptor for each USB device. Each device has one
or more configurations, each configuration has one or more interfaces, and
each interface has zero or more endpoints, as demonstrated in
Figure 3.3 below.
- Device Level: The device descriptor includes general
information about the USB device, i.e. global information for all of the
device configurations. The device descriptor identifies, among other
things, the device class (HID device, hub, locator device, etc.), subclass,
protocol code, vendor ID, device ID and more. Each USB device has one
device descriptor.
- Configuration Level: A USB device has one or more
configuration descriptors. Each descriptor identifies the number of
interfaces grouped in the configuration and the power attributes of the
configuration (such as self-powered, remote wakeup, maximum power
consumption and more). Only one configuration can be loaded at a given
time. For example, an ISDN adapter might have two different configurations,
one that presents it with a single interface of 128 Kb/s and a second that
presents it with two interfaces of 64 Kb/s each.
- Interface Level: The interface is a related set of
endpoints that present a specific functionality or feature of the device.
Each interface may operate independently. The interface descriptor
describes the number of the interface, the number of endpoints used by this
interface and the interface-specific class, subclass and protocol values
when the interface operates independently.
In addition, an interface may have alternate settings. The alternate
settings allow the endpoints or their characteristics to be varied after
the device is configured.
- Endpoint Level: The lowest level is the endpoint
descriptor, which provides the host with information regarding the
endpoint's data transfer type and maximum packet size. For isochronous
endpoints, the maximum packet size is used to reserve the required bus time
for the data transfer – i.e. the bandwidth. Other endpoint attributes
are its bus access frequency, endpoint number, error handling mechanism and
direction. The same endpoint can have different properties (and
consequently different uses) in different alternate settings.
Seems complicated? Not at all! WinDriver automates the USB configuration
process. The included DriverWizard utility [5]
and USB diagnostics application scan the USB bus, detect all USB devices and
their configurations, interfaces, alternate settings and endpoints, and enable
you to pick the desired configuration before starting driver development.
WinDriver identifies the endpoint transfer type as determined in the endpoint
descriptor. The driver created with WinDriver contains all configuration
information acquired at this early stage.