A Descriptor contains information like type of the device, Vendor ID, Compliant USB Version, number of configurations device supports, number of endpoints, etc. The USB peripheral must respond with descriptors when requested by the host. During enumeration, the host uses control transfer to request the device for descriptors.
There are mainly five types of descriptors
• Device Descriptors
• Configuration Descriptors
• Interface Descriptors
• Endpoint Descriptors
• String Descriptors
During enumeration, the host requests for the higher level descriptors. As enumeration progresses, the higher level descriptors inform the host about the lower level descriptors (if any). The descriptors contain a number of fields and most of them use prefix to indicate the format or content type. The common prefixes are: b = byte (8 bits), w = word (16 bits), bcd = binary coded decimal, bm = bitmap (bit array), i = index, id = identifier.
Each descriptor contains a series of fields and follows a common format. The first byte specifies the length of the descriptor while the second byte indicates the type of descriptor.
bDescriptionType – This field indicates the type of descriptor.
The device descriptor provides the basic information about the device. It represents the entire USB device. It is the first descriptor read by the host. The host receives this descriptor after sending Get_Descriptor request.
The descriptor contains fields containing device specific information like USB version, device class, Product ID, Vendor ID, number of configurations supported by device, etc. Check out the table below to learn about common fields included in device descriptors.
USB Devices that support both full and high speed modes must have a device_qualifier Descriptor. When the USB device switches its speed mode, values in some fields get changed in device descriptor. The device_qualifier descriptor provides information only about those field values that get changed when device switches to an alternate speed mode. This descriptor contains following fields out of which first two are common while other changes specific to the device.
A USB device can have one or more configurations. Most devices only have one configuration. The configuration provides information related to power source, power consumption, and number of interfaces.
The bNumConfigurations in device descriptor tells the host about the number of possible configurations. The host uses Set_Configuration request to select a configuration and Get_Configuration request to read the currently selected configuration.
The configuration descriptor contains following fields.
This descriptor is for devices which support both full and high speed modes. It returns the configuration for the speed mode currently not active. The structure is same as configuration descriptor except for the field value for bDescriptor type, which is 0x07.
A configuration can have one or more interfaces that can be taken as features or functions implemented by the device. The interface descriptor provides information related to particular feature of the device like class, subclass, protocol and number of endpoints interface uses.
The bNumInterfaces in configuration descriptor tells the host about the number of possible interfaces. After selecting a configuration, the host uses Set_Interface request to select an interface and Get_Interface request to read the currently selected interface.
The Endpoint Descriptor describes the endpoints associated with an interface. There is no descriptor for default endpoint zero. The endpoint zero is control endpoint and is configured even before the request of any descriptor. The information contained in this descriptor is used to determine the bandwidth required by the USB bus.
This descriptor includes following fields – :
String descriptors contain human readable texts. They are generally used to provide information. Other descriptors contain index value that points to strings containing information for manufacturer, product, serial number, configuration, interface. Other descriptors like Class and Vendor Specific can contain indexes to string descriptors
The Strings are encoded in Unicode format and multiple languages are supported. The host can get the list of supported languages using Get_Descriptor request with 0 in wIndex field. The device returns the String descriptor containing codes for different languages. The first 2 fields are mandatory fields and other fields contain language codes.
Thereafter, all the subsequent string descriptor (beyond index 0) have string contents and should conform to the following format.
Other Standard Descriptors
According to USB 2.0 specifications, there are additional descriptors for other specific purposes. These are as follows- :
interface_association Descriptor: This is for composite devices that have more than one interface for a single function or feature.
Interface_power Descriptor: It was proposed by Microsoft 1998 but hasn’t been implemented. The aim to propose this descriptor was to give the ability to interfaces to manage their own power consumption individually.
OTG Descriptor: This descriptor is required for devices that support OTG Host Negotiation Protocol (HNP) or Session Request Protocol.
Debug descriptors: The debug descriptor is used by debug devices for debugging purposes.
In the next part of the USB series, we will discuss USB requests and stages of control transfer.