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

8.4.1 Device Descriptors

8.4.1 Device Descriptors

The device descriptor is the top-level set of information read from a device and the first item the host attempts to retrieve.

A USB device has only one device descriptor, since the device descriptor represents the entire device. It provides general information such as manufacturer, serial number, product number, the class of the device, and the number of configurations. Table 8.5 shows the format for a device descriptor with the meaning of each field.

 bLength is the length of the device descriptor.

 bDescriptorType is the descriptor type.

 bcdUSB reports the highest version of USB the device supports in BCD format. The number is represented as 0xJJMN, where JJ is the major version number, M is the minor version number, and N is the subminor version number. For example, USB 1.1 is reported as 0x0110.

 bDeviceClass, bDeviceSubClass, and bDeviceProtocol are assigned by the USB organization and are used by the system to find a class driver for the device.

 bMaxPacketSize0 is the maximum input and output packet size for endpoint 0.

 idVendor is assigned by the USB organization and is the vendor’s ID.

 idProduct is assigned by the manufacturer and is the product ID.

 bcdDevice is the device release number and has the same format as the bcdUSB.

 iManufacturer, iProduct, and iSerialNumber are details about the manufacturer and the product. These fields have no requirement and can be set to zero.

 bNumConfigurations is the number of configurations the device supports.

Table 8.5: Device descriptor

Offset Field Size Description
0 bLength 1 Descriptor size in bytes
1 bDescriptorType 1 Device descriptor (0x01)
2 bcdUSB 2 Highest version of USB supported
4 bDeviceClass 1 Class code
5 bDeviceSubClass 1 Subclass code
6 bDeviceProtocol 1 Protocol code
7 bMaxPacketSize0 1 Maximum packet size
8 idVendor 2 Vendor ID
10 idProduct 2 Product ID
12 bcdDevice 2 Device release number
14 iManufacturer 1 Manufacturer string descriptor
15 iProduct 1 Index of product string descriptor
16 iSerialNumber 1 Index of serial number descriptor
17 bNumConfigurations 1 Number of possible configurations

Table 8.6 shows an example device descriptor for a mouse device. The length of the descriptor is 18 bytes (bLength=18), and the descriptor type is 0x01 (bDescriptorType=0x01). The device supports USB 1.1 (bcdUSB=0x0110). bDeviceClass, bDeviceSubClass, and bDeviceProtocol are set to zero to show that the class information is in the interface descriptor. bMaxPacketSize0 is set to 8 to show that the maximum input and output packet size for endpoint 0 is 8 bytes. The next three bytes identify the device by the vendor ID, product ID, and device version number. The next three items define indexes to strings about the manufacturer, product, and the serial number. Finally, we notice that the mouse device has just one configuration (bNumConfigurations=1).

Table 8.6: Example device descriptor

Offset Field Value Description
0 bLength 18 Size is 18
1 bDescriptorType 0x01 Descriptor type
2 bcdUSB 0x0110 Highest USB supported = USB 1.1
4 bDeviceClass 0x00 Class information in interface descriptor
5 bDeviceSubClass 0x00 Class information in interface descriptor
6 bDeviceProtocol 0x00 Class information in interface descriptor
7 bMaxPacketSize0 8 Maximum packet size
8 idVendor 0x02A XYZ Co Ltd.
10 idProduct 0x1001 Mouse
12 bcdDevice 0x0011 Device release number
14 iManufacturer 0x20 Index to manufacturer string
15 iProduct 0x21 Index of product string
16 iSerialNumber 0x22 Index of serial number string
17 bNumConfigurations 1 Number of possible configurations

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


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