• 描述符——设备描述符


    描述符定义

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

    描述符实现

    /**
     * @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;
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24

    描述符含义

    fielddescription
    bLength表示该描述符的长度。设备描述符的长度为 18 字节,写成十六进制就是 0x12。
    bDescriptorType描述符类型。设备描述符的编号为 0x01。
    bcdUSB2 字节,该设备所使用的 USB 协议的版本。如 USB2.0 就是 0x0200,USB1.1 就是 0x0110。实际传输的时候是低字节在前。
    bDeviceClass设备所使用的类代码。
    bDeviceSubClass设备所使用子类代码。
    bDeviceProtocol设备所使用的协议,协议代码由 USB 协会规定。
    bMaxPacketSize0端点 0 的最大包长。它的取值可以是 8 16 32 64 字节。对于高速设备固定是 64 字节
    idVendor2 字节,厂商 ID。
    idProduct2 字节,产品 ID。
    bcdDevice2 字节,设备的版本号。
    iManufacturer描述厂商的字符串的索引值。
    iProduct描述产品的字符串索引值。
    iSerialNumber描述设备的序列号字符串索引值。
    bNumConfigurations表示该设备有多少种配置。
    • 设备描述符决定该设备有多少种配置
      在这里插入图片描述
  • 相关阅读:
    [CMD]常用命令
    Java面试题大全(整理版)1000+面试题附答案详解最全面看完稳了
    C++ 单向链表手动实现(课后作业版)
    【YOLOV5-5.x 源码讲解】整体项目文件导航
    Pytorch Advanced(二) Variational Auto-Encoder
    【Cheat Engine7.5】基础教程第一关(STEP1-2)
    网络安全(黑客)自学
    应用软件漏洞排名
    kafka-listener
    Java数据类型
  • 原文地址:https://blog.csdn.net/tyustli/article/details/133218392