描述符——设备描述符

描述符定义

在这里插入图片描述在这里插入图片描述

描述符实现

/**
 * @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;

描述符含义

field description
bLength 表示该描述符的长度。设备描述符的长度为 18 字节,写成十六进制就是 0x12。
bDescriptorType 描述符类型。设备描述符的编号为 0x01。
bcdUSB 2 字节,该设备所使用的 USB 协议的版本。如 USB2.0 就是 0x0200,USB1.1 就是 0x0110。实际传输的时候是低字节在前。
bDeviceClass 设备所使用的类代码。
bDeviceSubClass 设备所使用子类代码。
bDeviceProtocol 设备所使用的协议,协议代码由 USB 协会规定。
bMaxPacketSize0 端点 0 的最大包长。它的取值可以是 8 16 32 64 字节。对于高速设备固定是 64 字节
idVendor 2 字节,厂商 ID。
idProduct 2 字节,产品 ID。
bcdDevice 2 字节,设备的版本号。
iManufacturer 描述厂商的字符串的索引值。
iProduct 描述产品的字符串索引值。
iSerialNumber 描述设备的序列号字符串索引值。
bNumConfigurations 表示该设备有多少种配置。
  • 设备描述符决定该设备有多少种配置
    在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/tyustli/article/details/133218392