#1楼主:求助: 一个具有U盘和USB键盘的设备应该如何设置配置描述符
文章发表于:2008-05-22 04:56
我想做一个设备,同时具有U盘和USB键盘的功能。
分开来的时候两者都是正确的。但是如何把他们整合在一起,是通过在配置描述符里增加一个接口来完成吗?还是怎样完成?有没有哪个高手做过类似的项目?
#2
文章发表于:2008-05-22 17:17
具体没做过。不过应该就是增加一个接口来实现的。这样的设备叫做复合设备。
#3
文章发表于:2008-05-22 17:20
是的。我U盘用的是端点1为IN传输,端点2为OUT 传输。我打算键盘用端点3来传输。接口那里设为2个接口。不知什么问题,连不上设备。
#4
文章发表于:2008-05-22 17:24
/************** Descriptor of Joystick Mouse interface ****************/
/* 09 */
0x09, /*bLength: Interface Descriptor size*/
USB_INTERFACE_DESCRIPTOR_TYPE,/*bDescriptorType: Interface descriptor type*/
0x00, /*bInterfaceNumber: Number of Interface*/
0x00, /*bAlternateSetting: Alternate setting*/
0x01, /*bNumEndpoints*/
0x03, /*bInterfaceClass: HID*/
0x01, /*bInterfaceSubClass : 1=BOOT, 0=no boot*/
0x02, /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/
0, /*iInterface: Index of string descriptor*/
0x00, /*bInterfaceNumber: Number of Interface*/
0x00, /*bAlternateSetting: Alternate setting*/
这两项是什么意思?单个接口的时候为什么是0?
#5
文章发表于:2008-05-22 18:49
你可以看看我的USB MIDI键盘,里面有多个接口。
#9
文章发表于:2008-05-22 20:27
还有报告描述符等。用BUS HOUND分析下数据。
#10
文章发表于:2008-05-22 22:30
const u8 MASS_ConfigDescriptor[MASS_SIZ_CONFIG_DESC] =
{
0x09, /* bLength: Configuation Descriptor size */
0x02, /* bDescriptorType: Configuration */
MASS_SIZ_CONFIG_DESC,
0x00,
0x02, /* bNumInterfaces: 2 interface */
0x01, /* bConfigurationValue: */
/* Configuration value */
0x00, /* iConfiguration: */
/* Index of string descriptor */
/* describing the configuration */
0x80, /* bmAttributes: */
/* bus powered */
0x32, /* MaxPower 100 mA: this current is used for detecting Vbus */
/******************** Descriptor of Mass Storage interface ********************/
0x09, /* bLength: Interface Descriptor size */
0x04, /* bDescriptorType: */
/* Interface descriptor type */
0x00, /* bInterfaceNumber: Number of Interface */
0x00, /* bAlternateSetting: Alternate setting */
0x02, /* bNumEndpoints*/
0x08, /* bInterfaceClass: MASS STORAGE Class */
0x06, /* bInterfaceSubClass : SCSI transparent*/
0x50, /* nInterfaceProtocol */
4, /* iInterface: */
/* 18 */
0x07, /*Endpoint descriptor length = 7*/
0x05, /*Endpoint descriptor type */
0x81, /*Endpoint address (IN, address 1) */
0x02, /*Bulk endpoint type */
0x40, /*Maximum packet size (64 bytes) */
0x00,
0x00, /*Polling interval in milliseconds */
/* 25 */
0x07, /*Endpoint descriptor length = 7 */
0x05, /*Endpoint descriptor type */
0x02, /*Endpoint address (OUT, address 2) */
0x02, /*Bulk endpoint type */
0x40, /*Maximum packet size (64 bytes) */
0x00,
0x00, /*Polling interval in milliseconds*/
/*32*/
/************** Descriptor of Joystick Mouse interface ****************/
0x09, /*bLength: Interface Descriptor size*/
0x04, /*bDescriptorType: Interface descriptor type*/
0x01, /*bInterfaceNumber: Number of Interface*/
0x00, /*bAlternateSetting: Alternate setting*/
0x01, /*bNumEndpoints*/
0x03, /*bInterfaceClass: HID*/
0x01, /*bInterfaceSubClass : 1=BOOT, 0=no boot*/
0x02, /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/
0, /*iInterface: Index of string descriptor*/
/******************** Descriptor of Joystick Mouse HID ********************/
0x09, /*bLength: HID Descriptor size*/
0x21, /*bDescriptorType: HID*/
0x00, /*bcdHID: HID Class Spec release number*/
0x01,
0x00, /*bCountryCode: Hardware target country*/
0x01, /*bNumDescriptors: Number of HID class descriptors to follow*/
0x22, /*bDescriptorType*/
74, /*wItemLength: Total length of Report descriptor*/
0x00,
/******************** Descriptor of Joystick Mouse endpoint ********************/
0x07, /*bLength: Endpoint Descriptor size*/
0x05, /*bDescriptorType:*/
0x83, /*bEndpointAddress: Endpoint Address (IN)*/
0x03, /*bmAttributes: Interrupt endpoint*/
0x04, /*wMaxPacketSize: 4 Byte max */
0x00,
0x20 /*bInterval: Polling Interval (32 ms)*/
};
帮我看下接口和端点定义有没有错。
#11
文章发表于:2008-05-23 02:24
这么长,看着累啊...你可以参看我写的USB键盘。应该只要将端点改改就可以了。