USB鼠标-配置描述符(三)

 USB 鼠标详解阅读顺序

1、枚举

2、设备描述符

3、设置地址

4、配置描述符

5、接口描述符

6、HID 描述符

7、端点描述符

8、字符串描述符

9、HID 报告描述符

10、HID 报告的返回

配置描述符定义

配置描述符结构

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

配置描述符抓包

配置描述符的数据格式

  • 0x09 bLength字段。配置描述符的长度为9字节
  • 0x02 bDescriptorType字段。配置描述符编号为0x02
  • 0x22 wTotalLength字段。配置描述符集合的总长度,包括配置描述符本身、接口描述符、类描述符、端点描述符等,LSB
  • 0x00
  • 0x01 bNumInterfaces字段。该配置包含的接口数,只有一个接口
  • 0x01 bConfiguration字段。该配置的值为1
  • 0x00 iConfigurationz字段,该配置的字符串索引。这里没有,为0
  • 0xA0 bmAttributes字段,该设备的属性
  • 0x32 bMaxPower字段,该设备需要的最大电流量。每单位电流为 2 mA
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值