USB设备描述符
USB描述符
USB通信开始之前,HOST需要通过模组提供的描述符来进行USB设备初始化,所以USB描述符是USB通信开始过程中非常重要的部分。描述符包括:设备描述符、配置描述符、接口描述符、端点描述符和字符串描述符(可选)。下面介绍YM310 X09模组提供的各个描述符详细内容。
模组是提供的是USB复合设备,目前软件提供的功能组合如下:
-
USB功能组合1:AT口 + LOG口(YM310.X09C_AT.S61/S62/S81版本)
-
USB功能组合2:网卡 + AT口 + LOG 口 (YM310.X09C_AT.S40/U61/U62版本)
-
USB功能组合3:网卡 + AT口 + LOG 口 + PPP口(YM310.X09C_AT.U60/YM310.X09S_AT.A60版本)
不用功能组合对应描述符值如下表,详细USB功能差异参考《AT软件介绍--AT版本列表》。
设备描述符
# 格式说明(其他描述符相同)
## 描述符类型
## 字段:内容(含义) #注释
## 字段:内容(含义) #注释
## ...
DEVICE DESCRIPTOR ## 描述符类型
bLength: 18 ## 字段:内容
bDescriptorType: 0x01 (DEVICE)
bcdUSB: 0x0200
bDeviceClass: 0xef (Miscellaneous)
bDeviceSubClass: 2
bDeviceProtocol: 1 (Interface Association Descriptor)
bMaxPacketSize0: 64
idVendor: 0x19d1
idProduct: 0x1003
bcdDevice: 0x0200
iManufacturer: 1
iProduct: 2
iSerialNumber: 3
bNumConfigurations: 1
配置描述符
CONFIGURATION DESCRIPTOR
bLength: 9
bDescriptorType: 0x02 (CONFIGURATION)
wTotalLength: 273
bNumInterfaces: 8 # USB功能组合不同,该值会有差异
bConfigurationValue: 1
iConfiguration: 0
Configuration bmAttributes: 0xa0 (NOT SELF-POWERED REMOTE-WAKEUP)
bMaxPower: 100 (200mA)
接口描述符
接口描述符体现了模组提供的USB功能,模组提供的接口(功能)如下:
- 网卡接口(ECM/RNDIS)
# 网卡接口描述符: 接口0&接口1 (本身是个复合接口,包含两个接口)
INTERFACE DESCRIPTOR (0.0): class Wireless Controller
bLength: 9
bDescriptorType: 0x04 (INTERFACE)
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 0xe0 (Wireless Controller)
bInterfaceSubClass: 0x01
bInterfaceProtocol: 0x03
iInterface: 6
INTERFACE DESCRIPTOR (1.0): class CDC-Data
bLength: 9
bDescriptorType: 0x04 (INTERFACE)
bInterfaceNumber: 1
bAlternateSetting: 0
bNumEndpoints: 2
bInterfaceClass: CDC-Data (0x0a)
bInterfaceSubClass: 0x00
bInterfaceProtocol: No class specific protocol required (0x00)
iInterface: 0
- AT口接口
# AT口接口描述符 接口2&接口3 (本身是个复合接口,包含两个接口)
INTERFACE DESCRIPTOR (2.0): class Communications and CDC Control
bLength: 9
bDescriptorType: 0x04 (INTERFACE)
bInterfaceNumber: 2
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: Communications and CDC Control (0x02)
bInterfaceSubClass: Abstract Control Model (0x02)
bInterfaceProtocol: AT Commands: V.250 etc (0x01)
iInterface: 7
INTERFACE DESCRIPTOR (3.0): class CDC-Data
bLength: 9
bDescriptorType: 0x04 (INTERFACE)
bInterfaceNumber: 3
bAlternateSetting: 0
bNumEndpoints: 2
bInterfaceClass: CDC-Data (0x0a)
bInterfaceSubClass: 0x00
bInterfaceProtocol: No class specific protocol required (0x00)
iInterface: 0
- LOG口接口
# LOG口接口描述符 接口4&接口5 (本身是个复合接口,包含两个接口)
INTERFACE DESCRIPTOR (4.0): class Communications and CDC Control
bLength: 9
bDescriptorType: 0x04 (INTERFACE)
bInterfaceNumber: 4
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: Communications and CDC Control (0x02)
bInterfaceSubClass: Abstract Control Model (0x02)
bInterfaceProtocol: AT Commands: V.250 etc (0x01)
iInterface: 8
INTERFACE DESCRIPTOR (5.0): class CDC-Data
bLength: 9
bDescriptorType: 0x04 (INTERFACE)
bInterfaceNumber: 5
bAlternateSetting: 0
bNumEndpoints: 2
bInterfaceClass: CDC-Data (0x0a)
bInterfaceSubClass: 0x00
bInterfaceProtocol: No class specific protocol required (0x00)
iInterface: 0
- PPP口接口
# PPP口接口描述符 接口6&接口7 (本身是个复合接口,包含两个接口)
INTERFACE DESCRIPTOR (6.0): class Communications and CDC Control
bLength: 9
bDescriptorType: 0x04 (INTERFACE)
bInterfaceNumber: 6
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: Communications and CDC Control (0x02)
bInterfaceSubClass: Abstract Control Model (0x02)
bInterfaceProtocol: AT Commands: V.250 etc (0x01)
iInterface: 9
INTERFACE DESCRIPTOR (7.0): class CDC-Data
bLength: 9
bDescriptorType: 0x04 (INTERFACE)
bInterfaceNumber: 7
bAlternateSetting: 0
bNumEndpoints: 2
bInterfaceClass: CDC-Data (0x0a)
bInterfaceSubClass: 0x00
bInterfaceProtocol: No class specific protocol required (0x00)
iInterface: 0
端点描述符
端点描述符是每个接口用到的端点集合,一个接口用到了三个端点,分别对应INT(中断)、OUT(输出)、IN(输入)。下面按照USB功能组合来列举端点分配情况: * USB功能组合1:AT口 + LOG口
# AT口INT&IN&OUT端点
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x81 IN Endpoint:1
bmAttributes: 0x03
.... ..11 = Transfertype: Interrupt-Transfer (0x3)
wMaxPacketSize: 16
bInterval: 16
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x01 OUT Endpoint:1
bmAttributes: 0x02
.... ..10 = Transfertype: Bulk-Transfer (0x2)
wMaxPacketSize: 512
bInterval: 0
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x82 IN Endpoint:2
bmAttributes: 0x02
.... ..10 = Transfertype: Bulk-Transfer (0x2)
wMaxPacketSize: 512
bInterval: 0
# LOG口INT&IN&OUT端点
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x83 IN Endpoint:3
bmAttributes: 0x03
.... ..11 = Transfertype: Interrupt-Transfer (0x3)
wMaxPacketSize: 16
bInterval: 16
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x02 OUT Endpoint:2
bmAttributes: 0x02
.... ..10 = Transfertype: Bulk-Transfer (0x2)
wMaxPacketSize: 512
bInterval: 0
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x84 IN Endpoint:4
bmAttributes: 0x02
.... ..10 = Transfertype: Bulk-Transfer (0x2)
wMaxPacketSize: 512
bInterval: 0
- USB功能组合2:网卡 + AT口 + LOG 口
# 网卡INT&IN&OUT端点
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x81 IN Endpoint:1
bmAttributes: 0x03 (Transfertype: Interrupt-Transfer)
wMaxPacketSize: 8
bInterval: 14
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x01 OUT Endpoint:1
bmAttributes: 0x02
wMaxPacketSize: 512
bInterval: 0
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x82 IN Endpoint:2
bmAttributes: 0x02
wMaxPacketSize: 512
bInterval: 0
# AT口INT&IN&OUT端点
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x83 IN Endpoint:3
bmAttributes: 0x03 (Transfertype: Interrupt-Transfer)
wMaxPacketSize: 16
bInterval: 16
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x02 OUT Endpoint:2
bmAttributes: 0x02
wMaxPacketSize: 512
bInterval: 0
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x84 IN Endpoint:4
bmAttributes: 0x02
wMaxPacketSize: 512
bInterval: 0
# LOG口INT&IN&OUT端点
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x85 IN Endpoint:5
bmAttributes: 0x03 (Transfertype: Interrupt-Transfer)
wMaxPacketSize: 16
bInterval: 16
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x03 OUT Endpoint:3
bmAttributes: 0x02
wMaxPacketSize: 512
bInterval: 0
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x86 IN Endpoint:6
bmAttributes: 0x02
wMaxPacketSize: 512
bInterval: 0
- USB功能组合3:网卡 + AT口 + LOG 口 + PPP口
# 网卡INT&IN&OUT端点
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x81 IN Endpoint:1
bmAttributes: 0x03 (Transfertype: Interrupt-Transfer)
wMaxPacketSize: 8
bInterval: 14
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x01 OUT Endpoint:1
bmAttributes: 0x02
wMaxPacketSize: 512
bInterval: 0
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x82 IN Endpoint:2
bmAttributes: 0x02
wMaxPacketSize: 512
bInterval: 0
# AT口INT&IN&OUT端点
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x83 IN Endpoint:3
bmAttributes: 0x03 (Transfertype: Interrupt-Transfer)
wMaxPacketSize: 16
bInterval: 16
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x02 OUT Endpoint:2
bmAttributes: 0x02
wMaxPacketSize: 512
bInterval: 0
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x84 IN Endpoint:4
bmAttributes: 0x02
wMaxPacketSize: 512
bInterval: 0
# LOG口INT&IN&OUT端点
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x85 IN Endpoint:5
bmAttributes: 0x03 (Transfertype: Interrupt-Transfer)
wMaxPacketSize: 16
bInterval: 16
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x03 OUT Endpoint:3
bmAttributes: 0x02
wMaxPacketSize: 512
bInterval: 0
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x86 IN Endpoint:6
bmAttributes: 0x02
wMaxPacketSize: 512
bInterval: 0
# PPP口INT&IN&OUT端点
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x87 IN Endpoint:7
bmAttributes: 0x03 (Transfertype: Interrupt-Transfer)
wMaxPacketSize: 16
bInterval: 16
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x04 OUT Endpoint:4
bmAttributes: 0x02
wMaxPacketSize: 512
bInterval: 0
ENDPOINT DESCRIPTOR
bLength: 7
bDescriptorType: 0x05 (ENDPOINT)
bEndpointAddress: 0x88 IN Endpoint:8
bmAttributes: 0x02
wMaxPacketSize: 512
bInterval: 0