Article directory
Descriptor definition
Descriptor implementation
/**
* @brief Device descriptor.
*/
typedef struct __attribute__ ((packed))
{
uint8_t bLength ; /**< Size of this descriptor in bytes. */
uint8_t bDescriptorType ; /**< DEVICE Descriptor Type. */
uint16_t bcdUSB ; /**< BUSB Specification Release Number in Binary-Coded Decimal (i.e., 2.10 is 210H). This field identifies the release of the USB Specification with which the device and its descriptors are compliant. */
uint8_t bDeviceClass ; /**< Class code (assigned by the USB-IF). \n If this field is reset to zero, each interface within a configuration specifies its own class information and the various interfaces operate independently. \n If this field is set to a value between 1 and FEH, the device supports different class specifications on different interfaces and the interfaces may not operate independently. This value identifies the class definition used for the aggregate interfaces. \n If this field is set to FFH, the device class is vendor-specific. */
uint8_t bDeviceSubClass ; /**< Subclass code (assigned by the USB-IF). These codes are qualified by the value of the bDeviceClass field. \n If the bDeviceClass field is reset to zero, this field must also be reset to zero. \n If the bDeviceClass field is not set to FFH, all values are reserved for assignment by the USB-IF. */
uint8_t bDeviceProtocol ; /**< Protocol code (assigned by the USB-IF). These codes are qualified by the value of the bDeviceClass and the bDeviceSubClass fields. If a device supports class-specific protocols on a device basis as opposed to an interface basis, this code identifies the protocols that the device uses as defined by the specification of the device class. \n If this field is reset to zero, the device does not use class-specific protocols on a device basis. However, it may use classspecific protocols on an interface basis. \n If this field is set to FFH, the device uses a vendor-specific protocol on a device basis. */
uint8_t bMaxPacketSize0 ; /**< Maximum packet size for endpoint zero (only 8, 16, 32, or 64 are valid). For HS devices is fixed to 64. */
uint16_t idVendor ; /**< Vendor ID (assigned by the USB-IF). */
uint16_t idProduct ; /**< Product ID (assigned by the manufacturer). */
uint16_t bcdDevice ; /**< Device release number in binary-coded decimal. */
uint8_t iManufacturer ; /**< Index of string descriptor describing manufacturer. */
uint8_t iProduct ; /**< Index of string descriptor describing product. */
uint8_t iSerialNumber ; /**< Index of string descriptor describing the device's serial number. */
uint8_t bNumConfigurations ; /**< Number of possible configurations. */
}usb_desc_device_t;
Descriptor meaning
field | description |
---|---|
bLength | Indicates the length of this descriptor. The length of the device descriptor is 18 bytes, which is 0x12 in hexadecimal. |
bDescriptorType | Descriptor type. The device descriptor number is 0x01. |
bcdUSB | 2 bytes, the USB protocol version used by this device. For example, USB2.0 is 0x0200, USB1.1 is 0x0110. During actual transmission, the low byte comes first. |
bDeviceClass | The class code used by the device. |
bDeviceSubClass | The subclass code used by the device. |
bDeviceProtocol | The protocol used by the device, the protocol code is specified by the USB Association. |
bMaxPacketSize0 | The maximum packet length for endpoint 0. Its value can be 8 16 32 64 bytes. Fixed to 64 bytes for high speed devices |
idVendor | 2 bytes, manufacturer ID. |
idProduct | 2 bytes, product ID. |
bcdDevice | 2 bytes, device version number. |
iManufacturer | Index value of a string describing the manufacturer. |
iProduct | A string index value describing the product. |
iSerialNumber | Serial number string index value describing the device. |
bNumConfigurations | Indicates how many configurations the device has. |
- The device descriptor determines how many configurations the device has