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

bcdUSBInforms the Host of what version of USB the device supports
bDeviceClass00 - Thedevice 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
idVendor16-bit number assigned by USB.org to the product's manufacturer
idProduct16-bit product model ID assigned by the Vendor to this product
bNumConfigurationsHow 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

bNuminterfacesNumber of Interface Descriptor tables available
MaxPowerPower 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

bNumEndpointsNumber of endpoints in the interface
bInterfaceClassUSB 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 thedata transfer type used to access the endpoint.

Key Elements of Endpoint Descriptors

bEndpointAddressThe address of the endpoint (i.e. endpoint number)
wMaxPacketSizeLength of the endpoint
bIntervalHow 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

FieldSize
(in bytes)
Description
bLengthn + 2Size of the String Descriptor
bDescriptorTypes10x03 used for String Descriptors
bStringnUnicode string of length n

 Learn More