1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 【USB笔记】配置描述符Configuration Descriptor

【USB笔记】配置描述符Configuration Descriptor

时间:2023-05-30 20:27:12

相关推荐

【USB笔记】配置描述符Configuration Descriptor

USB笔记 配置描述符(Configuration Descriptor)

配置描述符(Configuration Descriptor)说明了一个特定配置的相关信息。取得设备描述符(Device Descriptor)后,主机就可以继续去获取设备的配置、接口和端点描述符。当主机请求配置描述符(Configuration Descriptor)时,返回的是所有相关的接口和端点描述符。

一个USB设备有一个或多个配置描述符(Configuration Descriptor)。配置描述符描述了配置所提供的接口数量。每个接口可以独立操作。每种配置有一个或多个接口,而且每个接口有零个或多个端点。在一个配置中,接口不会共享一个端点,除非端点被相同接口的备用设置使用。没有这一限制、属于不同配置的接口可以共享端点。

配置描述符(Configuration Descriptor)规定了设备的特征和能力。一般单个配置已经足够了,但在驱动程序的支持下,带有多应用或多电源选择的设备可支持多重配置。且每次只有一个配置被激活。每个配置需要一个配置描述符,其中含有关于设备电源使用及所支持接口数的信息。每个配置描述符都有附属描述符(subordinate descriptor),包括一个或多个接口描述符(Interface Descriptor)以及可选的端点描述符(Endpoint Descriptor)。

Configuration Descriptor

bLength以字节为单位的描述符大小(0x09)。

bDescriptorType配置描述符类型,为CONFIGURATION (0x02)。

wTotalLength配置返回的数据总长度。包括该配置返回的所有描述符(配置、接口、端点、和专用的类型或者专用的厂商描述符)的总长度。

bNumInterfaces这个配置支持的接口数量,最小值为0x01。

bConfigurationValue确认Get Configuration 和Set Configuration请求的配置,且必须为0x01或者更高值。取值为0的Set Configuration请求会使设备进入未配置状态(Not Configured state)。

iConfiguration描述这个配置的字符串描述符索引。若没有字符串描述符,这个字段的值为0。

bmAttributes配置特性。

Bit 7:USB1.0协议中表示总线供电(Bus Powered),设置Bit 7 = 1表示由总线供电(Bus Powered)。其他协议该位保留(Reserved),必须设置为1。

Bit 6:自供电(Self-powered)。如果Bits 6 = 1,设备是自供电(Self-powered)的。

Bit 5 :远程唤醒(Remote Wakeup)。如果Bit 5 = 1,设备支持远程唤醒。

Bits 4…0:未使用,保留,必须为0。

bMaxPower当设备完全运行时,特定配置的USB设备从总线取得的最大功耗。

对于usb2.0,bMaxPower 以2mA为单位。如果设备要求200ma,则bMaxPower = 100 (0x64)。设备可请求的最大总线电流500mA。

对于增强型超高速(Enhanced SuperSpeed)设备,bMaxPower以8mA为单位。如果设备要求200ma,则bMaxPower = 25(0x19)。设备可请求的最大总线电流900mA。

当设备和主机支持USB Power Delivery Rev. 2.0,主机可以从PD Class Specific Descriptors检索设备的电源需求。

获取配置描述符

主机通过发送Get Descriptor请求,取得配置描述符及其附属描述符。

下面举例说明一个获取配置描述符Configuration Descriptor的过程。使用USB分析仪抓包,软件Total Phase Data Center。

配置描述符Configuration Descriptor如下所示:

使用USB分析仪抓包可以看到,获取配置描述符Configuration Descriptor:

配置描述符Configuration Descriptor的获取过程如下:

再展开看到详细的过程:

接下来详细看整个获取过程的各个字段含义:

一开始的setup包过程:

setup data:

IN包过程

OUT包过程:

完成整个配置描述符Configuration Descriptor的获取。

描述符示例

这里举例一个带有该描述符的示例设备,这是一个键盘Keyboard的完整描述符信息。

Device Descriptor

Configuration Descriptor

Interface Descriptor

HID Descriptor

Endpoint Descriptor

Interface Descriptor

HID Descriptor

Endpoint Descriptor

附录

USB1.1/USB 2.0 Configuration Descriptor

USB 3.x Configuration Descriptor

USB1.0 Configuration Descriptor

[参考资料]

Universal Serial Bus Specification Revision 1.0

Universal Serial Bus Specification Revision 1.1

Universal Serial Bus Specification Revision 2.0

Universal Serial Bus 3.0 Specification

Universal Serial Bus 3.1 Specification

Universal Serial Bus 3.2 Specification

Universal Serial Bus Power Delivery Specification Revision 2.0, V1.2

USB Complete, 5th Edition

USB开发大全

USB2.0与OTG规范及开发指南

/u012028275/article/details/109280001

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。