USB笔记 其他速度配置描述符(Other_Speed_Configuration Descriptor)
其他速度配置描述符(Other_Speed_Configuration Descriptor)说明了能进行高速运行的设备在其他可能的速度下操作的配置。其他速度配置的结构与配置描述符一样。
其他速度配置描述符(Other_Speed_Configuration Descriptor)是第二个同时支持全速和高速的设备所特有的描述符(第一个是设备限定描述符(Device Qualifier Descriptor))。这个描述符与配置描述符(Configuration Descriptor)有相同的结构。区别在于其他速度配置描述符(Other_Speed_Configuration Descriptor)是在设备操作当前并未使用的速度时,才会描述配置的。这个描述符与配置描述符(Configuration Descriptor)一样,也拥有附属描述符(subordinate descriptor)。
Other_Speed_Configuration Descriptor
Offset | Field | Size | Value | Description |
---|---|---|---|---|
0 | bLength | 1 | Number | 以字节为单位的描述符大小 |
1 | bDescriptorType | 1 | Constant | 其他速度配置描述符类型 |
2 | wTotalLength | 2 | Number | 配置返回的数据总长度 |
4 | bNumInterfaces | 1 | Number | 配置支持的接口数量 |
5 | bConfigurationValue | 1 | Number | 用于选择配置的值 |
6 | iConfiguration | 1 | Index | 字符串描述符索引 |
7 | bmAttributes | 1 | Bitmap | 配置特性,与配置描述符相同 |
8 | bMaxPower | 1 | mA | 设备从总线获取的最大功耗,与配置描述符相同 |
bLength以字节为单位的描述符大小(0x09)。
bDescriptorType其他速度配置描述符类型,为OTHER_SPEED_CONFIGURATION(0x07)。
wTotalLength该配置返回的数据总长度。包括该配置返回的所有描述符(配置、接口、端点、和专用的类型或者专用的厂商描述符)的总长度。
bNumInterfaces这个配置支持的接口数量,其最小值为0x01。
bConfigurationValue确认Get Configuration 和Set Configuration请求的配置,且必须为0x01或者更高值。
iConfiguration描述这个配置的字符串描述符索引。若没有字符串描述符,此值为0。
bmAttributes配置特性。该项与配置描述符(Configuration Descriptor)相同。
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设备从总线取得的最大功耗。该项与配置描述符(Configuration Descriptor)相同。
对于usb2.0,bMaxPower 以2mA为单位。如果设备要求200ma,则bMaxPower = 100 (0x64)。设备可请求的最大总线电流500mA。
对于超高速(Enhanced SuperSpeed)设备,bMaxPower以8mA为单位。如果设备要求200ma,则bMaxPower = 25(0x19)。设备可请求的最大总线电流900mA。
如果所请求的电流不可用,主机将拒绝对设备进行配置。如果备用配置可用,驱动程序可以请求备用配置。
获取其他速度配置描述符
主机通过发送Get Descriptor
请求,来取得其他速度配置描述符(Other_Speed_Configuration Descriptor)。
Get Descriptor | Value |
---|---|
bmRequestType | 0x80 |
bmRequestType.Recipient | 0b00000(Device) |
bmRequestType.Type | 0b00(Standard) |
bmRequestType.Direction | 0b1(Device-to-Host) |
bRequest | 0x06(Get Descriptor) |
wValue | 0x0700(Other Speed Configuration #0) |
wIndex | 0x0000 |
wLength | 0x0009 |
下面举例说明一个获取其他速度配置描述符的过程。使用USB分析仪抓包,软件Total Phase Data Center。
使用USB分析仪抓包可以看到,获取其他速度配置描述符Other_Speed_Configuration Descriptor:
其他速度配置描述符Other_Speed_Configuration Descriptor的获取过程如下:
再展开看到详细的过程:
接下来详细看整个获取过程的各个字段含义:
一开始的setup包过程:
setup data:
IN包过程
OUT包过程:
完成整个其他速度配置描述符Other_Speed_Configuration Descriptor的获取。
描述符示例
这里举例一个带有其他速度配置描述符Other_Speed_Configuration Descriptor的示例设备。
Device Descriptor
Offset | Field | Size | Value | Description |
---|---|---|---|---|
0 | bLength | 1 | 0x12 | |
1 | bDescriptorType | 1 | 0x01 | DEVICE |
2 | bcdUSB | 2 | 0x0200 | 2.00 |
4 | bDeviceClass | 1 | 0x00 | |
5 | bDeviceSubClass | 1 | 0x00 | |
6 | bDeviceProtocol | 1 | 0x00 | |
7 | bMaxPacketSize0 | 1 | 0x40 | |
8 | idVendor | 2 | 0x046d | |
10 | idProduct | 2 | 0xc31c | |
12 | bcdDevice | 2 | 0x0001 | 0.01 |
14 | iManufacturer | 1 | 0x01 | |
15 | iProduct | 1 | 0x02 | |
16 | iSerialNumber | 1 | 0x03 | |
17 | bNumConfigurations | 1 | 0x01 |
Device Qualifier Descriptor
Offset | Field | Size | Value | Description |
---|---|---|---|---|
0 | bLength | 1 | 0x0a | |
1 | bDescriptorType | 1 | 0x06 | DEVICE_QUALIFIER |
2 | bcdUSB | 2 | 0x0200 | 2.00 |
4 | bDeviceClass | 1 | 0x00 | |
5 | bDeviceSubClass | 1 | 0x00 | |
6 | bDeviceProtocol | 1 | 0x00 | |
7 | bMaxPacketSize0 | 1 | 0x40 | |
8 | bNumConfigurations | 1 | 0x01 | |
9 | bReserved | 1 | 0x00 |
Configuration Descriptor
Offset | Field | Size | Value | Description |
---|---|---|---|---|
0 | bLength | 1 | 0x09 | |
1 | bDescriptorType | 1 | 0x02 | CONFIGURATION |
2 | wTotalLength | 2 | 0x00b1 | |
4 | bNumInterfaces | 1 | 0x04 | |
5 | bConfigurationValue | 1 | 0x01 | |
6 | iConfiguration | 1 | 0x00 | |
7 | bmAttributes | 1 | 0xC0 | |
8 | bMaxPower | 1 | 0x01 |
Interface Descriptor
Offset | Field | Size | Value | Description |
---|---|---|---|---|
0 | bLength | 1 | 0x09 | |
1 | bDescriptorType | 1 | 0x04 | INTERFACE |
… | … | … | … | … |
Endpoint Descriptor
Offset | Field | Size | Value | Description |
---|---|---|---|---|
0 | bLength | 1 | 0x07 | |
1 | bDescriptorType | 1 | 0x05 | ENDPOINT |
… | … | … | … | … |
省略中间的描述符。
Other_Speed_Configuration Descriptor
Offset | Field | Size | Value | Description |
---|---|---|---|---|
0 | bLength | 1 | 0x09 | |
1 | bDescriptorType | 1 | 0x07 | OTHER_SPEED_CONFIGURATION |
2 | wTotalLength | 2 | 0x00b1 | |
4 | bNumInterfaces | 1 | 0x04 | |
5 | bConfigurationValue | 1 | 0x01 | |
6 | iConfiguration | 1 | 0x00 | |
7 | bmAttributes | 1 | 0xC0 | |
8 | bMaxPower | 1 | 0x01 |
Interface Descriptor
Offset | Field | Size | Value | Description |
---|---|---|---|---|
0 | bLength | 1 | 0x09 | |
1 | bDescriptorType | 1 | 0x04 | INTERFACE |
… | … | … | … | … |
Endpoint Descriptor
Offset | Field | Size | Value | Description |
---|---|---|---|---|
0 | bLength | 1 | 0x07 | |
1 | bDescriptorType | 1 | 0x05 | ENDPOINT |
… | … | … | … | … |
后续描述符省略。
附录
USB 2.0 Other_Speed_Configuration Descriptor
Offset | Field | Size | Value | Description |
---|---|---|---|---|
0 | bLength | 1 | Number | Size of descriptor |
1 | bDescriptorType | 1 | Constant | Other_speed_Configuration Type |
2 | wTotalLength | 2 | Number | Total length of data returned |
4 | bNumInterfaces | 1 | Number | Number of interfaces supported by this speed configuration |
5 | bConfigurationValue | 1 | Number | Value to use to select configuration |
6 | iConfiguration | 1 | Index | Index of string descriptor |
7 | bmAttributes | 1 | Bitmap | Same as Configuration descriptor |
8 | bMaxPower | 1 | mA | Same as Configuration descriptor |
[参考资料]
Universal Serial Bus Specification Revision 2.0
USB Complete, 5th Edition
USB开发大全
USB2.0与OTG规范及开发指南
本文链接:https://blog.csdn.net/u012028275/article/details/109280912