![]()
/* USB Standard Device Descriptor */
const u8 Virtual_Com_Port_DeviceDescriptor[] =
{
0x12, /* bLength */ //USB设备描述符的总长度固定为18个字节,因此为12H
USB_DEVICE_DESCRIPTOR_TYPE, /* bDescriptorType */ //USB设备描述符的类型值,固定为01H
0x00, //USB遵循的规范版本号,USB2.0; 0xXXYZ,XX为主版本号,Y为次版本号,Z为子次版本号
0x02, /* bcdUSB = 2.00 */
0x02, /* bDeviceClass: CDC */ //USB所遵循的标准设备类。0表示设备的接口相互独立,分别属于不同的设备类;
//1~FEH之间表示USB协议中定义的某个类。03H表示HID类,02H表示CDC类。
//FFH表示供应商自定义的设备类
0x00, /* bDeviceSubClass */ //USB设备所属的标准设备子类。对于显示设备类(04H),包含3个子类,
//子类代码01H表示CRT显示器,02H表示平面显示器,03H表示3D显示器。
//bDeviceClass为0时,该值为0;该值为FFH时,表示供应商自定义的设备子类
0x00, /* bDeviceProtocol */ //采用的设备类协议。该值为FFH时表示设备类协议由供应商自定义
0x40, /* bMaxPacketSize0 */ //端点0所支持最大数据包长度(字节),低速为8,全速为8,16,32或64,高速为64
0x83, //设备供应商id,使主机为其加载合适驱动
0x04, /* idVendor = 0x0483 */
0x40, //产品id,用于区分不同的usb设备
0x57, /* idProduct = 0x7540 */
0x00, //设备版本号,帮助主机加载合适驱动
0x01, /* bcdDevice = 1.00 */
1, /* Index of string descriptor describing manufacturer */ //若没有,可为0
2, /* Index of string descriptor describing product */ //若没有,可为0
3, /* Index of string descriptor describing the device's serial number */ //若没有,可为0
0x01 /* bNumConfigurations */ //USB设备所支持的配置数
};
![]()
![]()
![]()
![]()
const u8 Virtual_Com_Port_ConfigDescriptor[] =
{
/*Configuation Descriptor*/
0x09, /* bLength: Configuation Descriptor size */ //配置描述符的长度,固定为9字节,09H
USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */ //配置描述符类型,固定位02H
VIRTUAL_COM_PORT_SIZ_CONFIG_DESC, /* wTotalLength:no of returned bytes */ //配置信息总长度,配置描述符、接口描述符、端点描述符长度总和
0x00,
0x02, /* bNumInterfaces: 2 interface */ //所支持的接口数, 最小值为1
0x01, /* bConfigurationValue: Configuration value */ //USB设备的配置值
0x00, /* iConfiguration: Index of string descriptor describing the configuration */ //字符串描述符索引,若没有,可为0
0xC0, /* bmAttributes: self powered */ //配置特性,可按位寻址,第六位置1表示用总线电源,第五位置1表示支持远程唤醒,其他字段保留
//一般0~4位置0,第7位置1
0x00, /* MaxPower 0 mA */ //USB设备运行时所支持的最大电流,2mA为单位
/*Interface Descriptor*/
0x09, /* bLength: Interface Descriptor size */ //接口描述符长度,固定为9字节,09H
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType: Interface */ //接口描述符的类型值,固定位04H
/* Interface descriptor type */
0x00, /* bInterfaceNumber: Number of Interface */ //USB接口的接口号
0x00, /* bAlternateSetting: Alternate setting */ //USB接口的可替换设置值
0x01, /* bNumEndpoints: One endpoints used */ //USB接口所使用的接口总数
0x02, /* bInterfaceClass: Communication Interface Class */ //USB接口所属的设备类,1~FEH表示某个设备类;FFH表示供应商自定义
0x02, /* bInterfaceSubClass: Abstract Control Model */
0x01, /* bInterfaceProtocol: Common AT commands */ //接口所采用的设备类协议
0x00, /* iInterface: */ //USB接口字符串描述符的索引值
/*Header Functional Descriptor*/
0x05, /* bLength: Endpoint Descriptor size */
0x24, /* bDescriptorType: CS_INTERFACE */
0x00, /* bDescriptorSubtype: Header Func Desc */
0x10, /* bcdCDC: spec release number */
0x01,
/*Call Managment Functional Descriptor*/
0x05, /* bFunctionLength */
0x24, /* bDescriptorType: CS_INTERFACE */
0x01, /* bDescriptorSubtype: Call Management Func Desc */
0x00, /* bmCapabilities: D0+D1 */
0x01, /* bDataInterface: 1 */
/*ACM Functional Descriptor*/
0x04, /* bFunctionLength */
0x24, /* bDescriptorType: CS_INTERFACE */
0x02, /* bDescriptorSubtype: Abstract Control Management desc */
0x02, /* bmCapabilities */
/*Union Functional Descriptor*/
0x05, /* bFunctionLength */
0x24, /* bDescriptorType: CS_INTERFACE */
0x06, /* bDescriptorSubtype: Union func desc */
0x00, /* bMasterInterface: Communication class interface */
0x01, /* bSlaveInterface0: Data Class Interface */
/*Endpoint 2 Descriptor*/ //端点描述符长度固定为7字节,07H
0x07, /* bLength: Endpoint Descriptor size */
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */
0x82, /* bEndpointAddress: (IN2) */
0x03, /* bmAttributes: Interrupt */
VIRTUAL_COM_PORT_INT_SIZE, /* wMaxPacketSize: */
0x00,
0xFF, /* bInterval: */
/*Data class interface descriptor*/
0x09, /* bLength: Endpoint Descriptor size */
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType: */
0x01, /* bInterfaceNumber: Number of Interface */
0x00, /* bAlternateSetting: Alternate setting */
0x02, /* bNumEndpoints: Two endpoints used */
0x0A, /* bInterfaceClass: CDC */
0x00, /* bInterfaceSubClass: */
0x00, /* bInterfaceProtocol: */
0x00, /* iInterface: */
/*Endpoint 3 Descriptor*/
0x07, /* bLength: Endpoint Descriptor size */
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */
0x03, /* bEndpointAddress: (OUT3) */
0x02, /* bmAttributes: Bulk */
VIRTUAL_COM_PORT_DATA_SIZE, /* wMaxPacketSize: */
0x00,
0x00, /* bInterval: ignore for Bulk transfer */
/*Endpoint 1 Descriptor*/
0x07, /* bLength: Endpoint Descriptor size */
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */
0x81, /* bEndpointAddress: (IN1) */
0x02, /* bmAttributes: Bulk */
VIRTUAL_COM_PORT_DATA_SIZE, /* wMaxPacketSize: */
0x00,
0x00 /* bInterval */
};