USB Descriptors

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 accept text descriptions

Descriptor Structure

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.

descriptor-table.svg

Descriptor Types

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 of each of the descriptor types and how they are used.

Device Descriptor

The Device Descriptor is the first descriptor read by the Host during enumeration. The purpose of the Device Descriptor is to let the Host know what specification of USB the device complies with and how many possible configurations 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 "Developing USB Applications with Microchip" page for details on obtaining these numbers

Configuration Descriptor

A device may have more than one configuration. Each device configuration is assigned a number. The Configuration Descriptor serves two purposes:

  1. 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 that appear like two or more products have more than one interface.
  2. 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

Interface Descriptor

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 is implemented by the endpoints. For example, if the device were a keyboard, the specified device class would be Human Interface Device (HID) and the number of endpoints would be two. See the "USB Device Classes" page for details 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 that 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 integrated mouse (or trackball) is an example of a composite device.

Endpoint Descriptor

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

String Descriptor

Strings Descriptors are optional human readable strings which the Host OS may display.

String Descriptor Structues

Field Size
(in bytes)
Description
bLength n + 2 Size of the String Descriptor
bDescriptorTypes 1 0x03 used for String Descriptors
bString n Unicode string of length n

 Learn More

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.