Each Universal Serial Bus (USB) Device has a set of descriptors. The descriptors are read by the Host during enumeration. Descriptors inform the host of the following information about a Device:
- The version of USB supported by the Device
- Who made the Device
- How many ways the Device can be configured by the Host
- The power consumed by each Device configuration
- The number and length of endpoints on the device
- What type of transfer method is to be used to communicate with endpoints
- How often the endpoints are to be serviced
- What text to display if the Host operating systems accepts text descriptions
There are several types of descriptors for USB Devices arranged in a logical hierarchy. The following diagram illustrates the hierarchy of a descriptor for a single device with two possible configurations for the Host to activate. Each of these configurations has a single interface with two endpoints.
The most commonly used descriptors include:
- Device Descriptor
- Configuration Descriptor
- Interface Descriptor
- Endpoint Descriptor
- String Descriptor
Every USB Device must have one Device descriptor and at least one each of the configuration, interface and endpoint descriptors.
A full description of the Byte by Byte contents of the descriptor tables can be found in the USB specifications. This page explains some of the important features on each of the descriptor types and how they are used
The device descriptor is the first descriptor read by the Host during enumeration. The purpose of the Device Descriptor is let the Host know what specification of USB the Device complies to and how many possible configuration are available on the Device. Upon successful processing of the Device Descriptor the Host will read all the Configuration Descriptors.
Structure of a Device Descriptor
Key elements of a Device Descriptor
|bcdUSB||Informs the Host of what version of USB the Device supports|
|bDeviceClass||00 - The Device Class is defined in the Interface Descriptor
FF - The Device Class is Vendor Class
any other number is the specification for the Class of this Device
|idVendor||16-bit number assigned by USB.org to the product's manufacturer|
|idProduct||16-bit product model ID assigned by the Vendor to this product|
|bNumConfigurations||How many different configurations are available for this Device|
All certified USB products must have a valid Vendor ID and Product ID. See the USB development page for details on obtaining these numbers
A Device may have more than one configuration. Each Device configuration is assigned a number. The configuration descriptor serves two purposes:
- Informs the host as to how many interfaces (i.e. virtual devices) are in the configuration. While it is common for a configuration to offer only one interface, devices which appear like two or more products have more than one interface.
- How much power the device will consume if this configuration is activated by the Host. If the Device is capable of controlling its power consumption it may offer more than one configuration. Each configuration will advertise how much power would be consumed if the configuration were to be activated.
Structure of a Configuration Descriptor
Key Elements of a Configuration Descriptor
|bNuminterfaces||Number of Interface Descriptor tables available|
|MaxPower||Power load of this Device if the Host activates this configuration|
An Interface Descriptor describes the details of the function of the product. Key elements include the Number of Endpoints on the Device and which USB Device Class are implemented by the endpoints. For example, if the device were a keyboard the specified Device class would be HID (Human Interface Device) and the number of endpoints would be two. (See USB Device Class for detail on how Device Classes are implemented in USB.)
Structure of an Interface Descriptor
Key Elements of an Interface Descriptor
|bNumEndpoints||Number of endpoints in the interface|
|bInterfaceClass||USB Device Class used to set Transfer types for the endpoints|
Only one configuration can be active at any time. When a configuration is active all of its interfaces and endpoints are available to the Host. Devices which have multiple interfaces are referred to as Composite Devices. One physical product with one available USB connector would appear to the Host as two separate devices. A keyboard with an intergrated mouse (or trackball) is an example of a composite device.
Each endpoint on a Device has its own descriptor. The descriptor provides the endpoint address (i.e. endpoint number), the size of the endpoint, and the Data Transfer Type used to access the endpoint.
Key Elements of Endpoint Descriptors
|bEndpointAddress||The address of the Endpoint (i.e. endpoint number)|
|wMaxPacketSize||Length of the Endpoint|
|bInterval||How often in frames) is this endpoint to be serviced by the Host|
Even though the Device Class will usually indicate the endpoint numbers and Transfer types to be used, these items must be included in the Endpoint Descriptor
Strings Descriptors are optional human readable strings which the Host OS may display.
String Descriptor Structues
|bLength||n + 2||Size of the string descriptor|
|bDescriptorTypes||1||0x03 used for String Descriptors|
|bString||n||unicode string of length n|