• 描述符——配置描述符


    描述符定义

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

    描述符实现

    /**
     * @brief USB configuration descriptor.
     */
    typedef struct __attribute__ ((packed))
    {
        uint8_t  bLength             ; /**< Size of this descriptor in bytes. */
        uint8_t  bDescriptorType     ; /**< CONFIGURATION Descriptor Type. */
        uint16_t wTotalLength        ; /**< Total length of data returned for this configuration. Includes the combined length of all descriptors (configuration, interface, endpoint, and class- or vendor-specific) returned for this configuration. */
    
        uint8_t  bNumInterfaces      ; /**< Number of interfaces supported by this configuration. */
        uint8_t  bConfigurationValue ; /**< Value to use as an argument to the SetConfiguration() request to select this configuration. */
        uint8_t  iConfiguration      ; /**< Index of string descriptor describing this configuration. */
        uint8_t  bmAttributes        ; /**< Configuration characteristics \n D7: Reserved (set to one)\n D6: Self-powered \n D5: Remote Wakeup \n D4...0: Reserved (reset to zero) \n D7 is reserved and must be set to one for historical reasons. \n A device configuration that uses power from the bus and a local source reports a non-zero value in bMaxPower to indicate the amount of bus power required and sets D6. The actual power source at runtime may be determined using the GetStatus(DEVICE) request (see USB 2.0 spec Section 9.4.5). \n If a device configuration supports remote wakeup, D5 is set to one. */
        uint8_t  bMaxPower           ; /**< Maximum power consumption of the USB device from the bus in this specific configuration when the device is fully operational. Expressed in 2 mA units (i.e., 50 = 100 mA). */
    }usb_desc_configuration_t;
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

    描述符含义

    fielddescription
    bLength配置描述符的长度。标准的 USB 配置描述符的长度为 9 字节。
    bDescriptorType描述符的类型。配置描述符的类型编码为 0x02。
    wTotalLength2 个字节,表示整个配置描述符集合的总长度,包括配置描述符,接口描述符,类特殊描述符(如果有)和端点描述符,注意低字节在前。
    bNumInterfaces表示该配置所支持的接口数量。通常功能单一的设备只具有一个接口,而复合设备则具有多个接口。
    bConfigurationValue表示该配置的值。通常一个 USB 设备可以支持多个配置,bConfiguration 就是每个配置的标识。
    iConfiguration描述该配置的字符串的索引值,如果该值为 0 ,表示没有字符串。
    bmAttributes用来描述设备的一些特性。
    bMaxPower表示设备需要从总线获取的最大电流量,单位为 2 mA。
    • 配置描述符决定有多少个接口

    在这里插入图片描述

  • 相关阅读:
    不得不会的MySQL数据库知识点(二)
    Mapper.xml文件如何写集合遍历语句
    基于SSM实现酒店入住预定管理系统
    MonoSDF学习笔记
    数据分析报告常见步骤
    农场管理小程序|基于微信小程序的农场管理系统设计与实现(源码+数据库+文档)
    CANoe创建仿真工程
    【mockserver】linux服务器搭建 easy-mock,用于挡板或模拟接口返回服务器
    TrueLicense源码解析-寻找license安装后存放的位置
    一台电脑生成两个ssh,绑定两个GitHub账号
  • 原文地址:https://blog.csdn.net/tyustli/article/details/133231437