Книга: Advanced PIC Microcontroller Projects in C

8.4.2 Configuration Descriptors

8.4.2 Configuration Descriptors

The configuration descriptor provides information about the power requirements of the device and how many different interfaces it supports. There may be more than one configuration for a device.

Table 8.7 shows the format of the configuration descriptor with the meaning of each field.

 bLength is the length of the device descriptor.

 bDescriptorType is the descriptor type.

 wTotalLength is the total combined size of this set of descriptors (i.e., total of configuration descriptor + interface descriptor + HID descriptor + endpoint descriptor). When the configuration descriptor is read by the host, it returns the entire configuration information, which includes all interface and endpoint descriptors.

 bNumInterfaces is the number of interfaces present for this configuration.

 bConfigurationValue is used by the host (in command SetConfiguration) to select the configuration.

 iConfiguration is an index to a string descriptor describing the configuration in readable format.

 bmAttributes describes the power requirements of the device. If the device is USB bus-powered, then bit D7 is set. If it is self-powered, it sets bit D6. Bit D5 specifies the remote wakeup of the device. Bits D7 and D0–D4 are reserved.

 bMaxPower defines the maximum power the device will draw from the bus in 2mA units.

Table 8.7: Configuration descriptor

Offset Field Size Description
0 bLength 1 Descriptor size in bytes
1 bDescriptorType 1 Device descriptor (0x02)
2 wTotalLength 2 Total bytes returned
4 bNumInterfaces 1 Number of interfaces
5 bConfigurationValue 1 Value used to select configuration
6 iConfiguration 1 Index describing configuration string
7 bmAttributes 1 Power supply attributes
8 bMaxPower 2 Max power consumption in 2mA

Table 8.8 shows an example configuration descriptor for a mouse device. The length of the descriptor is 9 bytes (bLength=9), and the descriptor type is 0x02 (bDescriptorType=0x02). The total combined size of the descriptors is 34 (wTotalLength=34). The number of interfaces for the mouse device is 1 (bNumInterfaces=1). Host SetConfiguration command must use the value 1 as an argument in SetConfiguration() to select this configuration. There is no string to describe this configuration. bmAttributes is set to 0x40 to indicate that the device is self-powered. bMaxPower is set to 10 to specify that the maximum current drawn by the device is 20mA.

Table 8.8: Example configuration descriptor

Offset Field Value Description
0 bLength 9 Descriptor size is 9 bytes
1 bDescriptorType 0x02 Device descriptor is 0x02
2 wTotalLength 34 Total bytes returned is 34
4 bNumInterfaces 1 Number of interfaces is 1
5 bConfigurationValue 1 Value used to select configuration
6 iConfiguration 0x2A Index describing configuration string
7 bmAttributes 0x40 Power supply attributes
8 bMaxPower 10 Max power consumption is 20mA

Оглавление книги


Генерация: 0.071. Запросов К БД/Cache: 0 / 0
поделиться
Вверх Вниз