Arduino Projects   |   Raspberry Pi   |   Electronic Circuits   |   AVR   |   PIC   |   8051   |   Electronic Projects

USB Descriptors and their Types (Part 3/6)

Written By: 

Amanpreet Singh
Now that we have discussed the basic details of USB protocol encompassing types of USB packets and transfers, the next topic in the series is USB Descriptors. In context to USB interface, Descriptors are formatted blocks of information, through which, the host device learns about the peripheral. It helps in identifying and configuring the peripheral device.

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.

Descriptor Types

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.

 

Descriptor Types

 
bLength – This field provides the length of the descriptor in bytes.

bDescriptionType – This field indicates the type of descriptor.

 

type of descriptor.

Device Descriptors

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.

 

device descriptors

Device_qualifier 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.

 

Device_qualifier Descriptors

 

Configuration Descriptors

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.

 

Configuration Descriptors

Other_speed_configuration Descriptors

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.

Interface Descriptors

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.

It is possible to activate multiple interfaces at the same time for a configuration. The devices in which multiple interfaces are active are known as composite devices.
 
 
Interface Descriptors

Endpoint Descriptors

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 - :

 

Endpoint Descriptors

String Descriptors

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.

 

String Descriptors

Thereafter, all the subsequent string descriptor (beyond index 0) have string contents and should conform to the following format.

 
 
Format of string descriptor
 

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.

Comments

Hi aman, its really very much helping who are working first time on USB.  Its great job done by you.  You are doing service for vlsi field,,,,please keep it up and expecting more from you,,,,,,,,,...Thanks a lot.../////////