Table 8.10: Example interface descriptor
Offset | Field | Value | Description |
---|---|---|---|
0 | bLength | 9 | Descriptor size is 9 bytes |
1 | bDescriptorType | 0x04 | Device descriptor is 0x04 |
2 | bInterfaceNumber | 0 | Number of interface |
3 | bAlternateSetting | 0 | Value to select alternate setting |
4 | bNumEndpoints | 1 | Number of endpoints is 1 |
5 | bInterfaceClass | 0x03 | Class code is 0x03 |
6 | bInterfaceSubClass | 0x02 | Subclass code is 0x02 |
7 | bInterfaceProtocol | 0x02 | Protocol code is 0x02 |
8 | iInterface | 0 | Index of string descriptor to interface |
bAlternateSetting is set to 0 (i.e., no alternate interfaces). The number of endpoints used by this interface is 1 (excluding endpoint 0), and this is the endpoint used for the mouse to send its data. The device class code is 0x03 (bInterfaceClass=0x03). This is an HID (human interface device) type class. The interface subclass is set to 0x02. The device protocol is 0x02 (mouse). There is no string to describe this interface (iInterface=0).
8.4.4 HID Descriptors
An HID descriptor always follows an interface descriptor when the interface belongs to the HID class. Table 8.11 shows the format of the HID descriptor.
bLength is the length of the device descriptor.
bDescriptorType is the descriptor type.
bcdHID is the HID class specification.
bCountryCode specifies any special local changes.
bNumDescriptors specifies if there are any additional descriptors associated with this class.
bDescriptorType is the type of the additional descriptor specified in bNumDescriptors.
wDescriptorLength is the length of the additional descriptor in bytes.
Table 8.11: HID descriptor
Offset | Field | Size | Description |
---|---|---|---|
0 | bLength | 1 | Descriptor size in bytes |
1 | bDescriptorType | 1 | HID (0x21) |
2 | bcdHID | 2 | HID class |
4 | bCountryCode | 1 | Special country dependent code |
5 | bNumDescriptors | 1 | Number of additional descriptors |
6 | bDescriptorType | 1 | Type of additional descriptor |
7 | wDescriptorLength | 2 | Length of additional descriptor |
Table 8.12 shows an example HID descriptor for a mouse device. The length of the descriptor is 9 bytes (bLength=9), and the descriptor type is 0x21 (bDescriptorType=0x21). The HID class is set to 1.1 (bcdHID=0x0110). The country code is set to zero (bCountryCode=0), specifying that there is no special localization with this device. The number of descriptors is set to 1 bNumDescriptors=1) which specifies that there is one additional descriptor associated with this class. The type of the additional descriptor is REPORT (bDescriptorType=REPORT), and its length is 52 bytes (wDescriptorLength=52).
Table 8.12: Example HID descriptor
Offset | Field | Value | Description |
---|---|---|---|
0 | bLength | 9 | Descriptor size is 9 bytes |
1 | bDescriptorType | 0x21 | HID (0x21) |
2 | bcdHID | 0x0110 | Class version 1.1 |
4 | bCountryCode | 0 | No special country dependent code |
5 | bNumDescriptors | 1 | Number of additional descriptors |
6 | bDescriptorType | REPORT | Type of additional descriptor |
7 | wDescriptorLength | 5 | Length of additional descriptor |
8.4.5 Endpoint Descriptors
Table 8.13 shows the format of the endpoint descriptor.
bLength is the length of the device descriptor.
bDescriptorType is the descriptor type.
bEndpointAddress is the address of the endpoint.
bmAttributes specifies what type of endpoint it is.
wMaxPacketSize is the maximum packet size.
bInterval specifies how often the endpoint should be polled (in ms).
Table 8.13: Endpoint descriptor
Offset | Field | Size | Description |
---|---|---|---|
0 | bLength | 1 | Descriptor size in bytes |
1 | bDescriptorType | 1 | Endpoint (0x05) |
2 | bcdEndpointAddress | 1 | Endpoint address |
4 | bmAttributes | 1 | Type of endpoint |
5 | wMaxPacketSize | 2 | Max packet size |
6 | bInterval | 1 | Polling interval |
Table 8.14 shows an example endpoint descriptor for a mouse device. The length of the descriptor is 7 bytes (bLength=7), and the descriptor type is 0x05 (bDescriptorType=0x05). The endpoint address is 0x50 (bEndpointAddress=0x50). The endpoint is to be used as an interrupt endpoint (bmAttributes=0x03). The maximum packet size is set to 2 (wMaxPacketSize=0x02) to indicate that packets longer than 2 bytes will not be sent from the endpoint. The endpoint should be polled at least once every 20ms (bInterval=0x14).