USB 设备同时支持全速模式与高速模式
2021-11-23
2616
1
当一个USB高速设备接入全速的HUB时,这时会出现高速模式协商失败,这时为了设备能正常使用,会自动使用全速模式来运行。
所以为了同时支持全速与高速的设备,必须有Device Qualifier Descriptor和其它速率配置描述符(OTHER_SPEED_CONFIGURATION),用于描述全速模式下的配置信息。这些配置信息主要包括接口描述符、端点描述符。
如一个同时支持全速与高速的USB存储设备其配置描述符大概是这样的:
如本人手中的一块U盘,其配置描述符如下图:
---------------------- Device Descriptor ----------------------
bLength : 0x12 (18 bytes)
bDescriptorType : 0x01 (Device Descriptor)
bcdUSB : 0x200 (USB Version 2.00)
bDeviceClass : 0x00 (defined by the interface descriptors)
bDeviceSubClass : 0x00
bDeviceProtocol : 0x00
bMaxPacketSize0 : 0x40 (64 bytes)
idVendor : 0x0951 (Kingston Technology Company)
idProduct : 0x1665
bcdDevice : 0x0200
iManufacturer : 0x01 (String Descriptor 1)
Language 0x0409 : "Kingston"
iProduct : 0x02 (String Descriptor 2)
Language 0x0409 : "DataTraveler 2.0"
iSerialNumber : 0x03 (String Descriptor 3)
Language 0x0409 : "1C6F654E48EB1FC1391B7D69"
bNumConfigurations : 0x01 (1 Configuration)
Data (HexDump) : 12 01 00 02 00 00 00 40 51 09 65 16 00 02 01 02 .......@Q.e.....
03 01 ..
------------------ Configuration Descriptor -------------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x02 (Configuration Descriptor)
wTotalLength : 0x0020 (32 bytes)
bNumInterfaces : 0x01 (1 Interface)
bConfigurationValue : 0x01 (Configuration 1)
iConfiguration : 0x00 (No String Descriptor)
bmAttributes : 0x80
D7: Reserved, set 1 : 0x01
D6: Self Powered : 0x00 (no)
D5: Remote Wakeup : 0x00 (no)
D4..0: Reserved, set 0 : 0x00
MaxPower : 0x32 (100 mA)
Data (HexDump) : 09 02 20 00 01 01 00 80 32 09 04 00 00 02 08 06 .. .....2.......
50 00 07 05 81 02 00 02 00 07 05 02 02 00 02 00 P...............
//高速模式
---------------- Interface Descriptor -----------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x04 (Interface Descriptor)
bInterfaceNumber : 0x00
bAlternateSetting : 0x00
bNumEndpoints : 0x02 (2 Endpoints)
bInterfaceClass : 0x08 (Mass Storage)
bInterfaceSubClass : 0x06 (SCSI transparent command set)
bInterfaceProtocol : 0x50 (Bulk-Only Transport)
iInterface : 0x00 (No String Descriptor)
Data (HexDump) : 09 04 00 00 02 08 06 50 00 .......P.
----------------- Endpoint Descriptor -----------------
bLength : 0x07 (7 bytes)
bDescriptorType : 0x05 (Endpoint Descriptor)
bEndpointAddress : 0x81 (Direction=IN EndpointID=1)
bmAttributes : 0x02 (TransferType=Bulk)
wMaxPacketSize : 0x0200 (max 512 bytes)
bInterval : 0x00 (never NAKs)
Data (HexDump) : 07 05 81 02 00 02 00 .......
----------------- Endpoint Descriptor -----------------
bLength : 0x07 (7 bytes)
bDescriptorType : 0x05 (Endpoint Descriptor)
bEndpointAddress : 0x02 (Direction=OUT EndpointID=2)
bmAttributes : 0x02 (TransferType=Bulk)
wMaxPacketSize : 0x0200 (max 512 bytes)
bInterval : 0x00 (never NAKs)
Data (HexDump) : 07 05 02 02 00 02 00 .......
----------------- Device Qualifier Descriptor -----------------
bLength : 0x0A (10 bytes)
bDescriptorType : 0x06 (Device_qualifier Descriptor)
bcdUSB : 0x200 (USB Version 2.00)
bDeviceClass : 0x00 (defined by the interface descriptors)
bDeviceSubClass : 0x00
bDeviceProtocol : 0x00
bMaxPacketSize0 : 0x40 (64 Bytes)
bNumConfigurations : 0x01 (1 other-speed configuration)
bReserved : 0x00
Data (HexDump) : 0A 06 00 02 00 00 00 40 01 00 .......@..
------------ Other Speed Configuration Descriptor -------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x07 (Other_speed_configuration Descriptor)
wTotalLength : 0x0020 (32 bytes) //包括其本身和后续的长度
bNumInterfaces : 0x01 (1 Interface) //接口数据
bConfigurationValue : 0x01 (Configuration 1) //配置索引
iConfiguration : 0x00 (No String Descriptor)
bmAttributes : 0x80
D7: Reserved, set 1 : 0x01
D6: Self Powered : 0x00 (no)
D5: Remote Wakeup : 0x00 (no)
D4..0: Reserved, set 0 : 0x00
MaxPower : 0x32 (100 mA)
Data (HexDump) : 09 07 20 00 01 01 00 80 32 09 04 00 00 02 08 06 .. .....2.......
50 00 07 05 81 02 40 00 00 07 05 02 02 40 00 00 P.....@......@..
//全速模式
---------------- Interface Descriptor -----------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x04 (Interface Descriptor)
bInterfaceNumber : 0x00
bAlternateSetting : 0x00
bNumEndpoints : 0x02 (2 Endpoints)
bInterfaceClass : 0x08 (Mass Storage)
bInterfaceSubClass : 0x06 (SCSI transparent command set)
bInterfaceProtocol : 0x50 (Bulk-Only Transport)
iInterface : 0x00 (No String Descriptor)
Data (HexDump) : 09 04 00 00 02 08 06 50 00 .......P.
----------------- Endpoint Descriptor -----------------
bLength : 0x07 (7 bytes)
bDescriptorType : 0x05 (Endpoint Descriptor)
bEndpointAddress : 0x81 (Direction=IN EndpointID=1)
bmAttributes : 0x02 (TransferType=Bulk)
wMaxPacketSize : 0x0040 (max 64 bytes)
bInterval : 0x00 (never NAKs)
Data (HexDump) : 07 05 81 02 40 00 00 ....@..
----------------- Endpoint Descriptor -----------------
bLength : 0x07 (7 bytes)
bDescriptorType : 0x05 (Endpoint Descriptor)
bEndpointAddress : 0x02 (Direction=OUT EndpointID=2)
bmAttributes : 0x02 (TransferType=Bulk)
wMaxPacketSize : 0x0040 (max 64 bytes)
bInterval : 0x00 (never NAKs)
Data (HexDump) : 07 05 02 02 40 00 00 ....@..
HID人机交互QQ群:564808376
UAC音频QQ群:218581009
UVC相机QQ群:331552032
BOT&UASP大容量存储QQ群:258159197
STC-USB单片机QQ群:315457461
USB技术交流QQ群2:580684376
USB技术交流QQ群:952873936