cl17726 发表于 2016-9-28 14:30:07

想实现USB复合设备,使用STM32Cube.求助

想实现复合设备,使用STM32Cube,主芯片是STM32F072,需要实现的是键盘鼠标一体化设备,就是插在电脑上识别出键盘和鼠标.

首先我的Cube库的版本是这样的.



我先生成了个HID普通设备.



把接口数改成2.



然后分别做了HID_MOUSE_ReportDesc和HID_KEYBOARD_ReportDesc.但是SETUP过程只让汇报了HID_MOUSE,如何让他们区分汇报呢?



改完这两个还有多少步骤?EP的配置应该还好解决.

stary666 发表于 2016-9-28 15:05:56

可以实现的,,,

cloudcn 发表于 2016-9-28 15:13:09

复合设备还是一个设备,获取描述符还是设备的描述符,主要是多接口和多端点
这是一个复合设备的描述符,对比看一下
这个用了81 82两个端点 分别是键盘与鼠标
你的程序得多打开个端点,还要对其进行配置,并进行数据传输

      ------------------ 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          : 0x08 (8 bytes)
idVendor               : 0x046D (Logitech Inc.)
idProduct                : 0xC52E
bcdDevice                : 0x2300
iManufacturer            : 0x01 (String Descriptor 1)
Language 0x0409         : "Logitech"
iProduct               : 0x02 (String Descriptor 2)
Language 0x0409         : "USB Receiver"
iSerialNumber            : 0x00 (No String Descriptor)
bNumConfigurations       : 0x01

      ------------------ String Descriptors -----------------
             ------ String Descriptor 0 ------
bLength                  : 0x04 (4 bytes)
bDescriptorType          : 0x03 (String Descriptor)
Language ID         : 0x0409 (English - United States)
             ------ String Descriptor 1 ------
bLength                  : 0x12 (18 bytes)
bDescriptorType          : 0x03 (String Descriptor)
Language 0x0409          : "Logitech"
             ------ String Descriptor 2 ------
bLength                  : 0x1A (26 bytes)
bDescriptorType          : 0x03 (String Descriptor)
Language 0x0409          : "USB Receiver"
             ------ String Descriptor 4 ------
bLength                  : 0x1E (30 bytes)
bDescriptorType          : 0x03 (String Descriptor)
Language 0x0409          : "RQR23.00_B0005"

      ---------------- Configuration Descriptor -----------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x02 (Configuration Descriptor)
wTotalLength             : 0x003B (59 bytes)
bNumInterfaces         : 0x02
bConfigurationValue      : 0x01
iConfiguration         : 0x04 (String Descriptor 4)
Language 0x0409         : "RQR23.00_B0005"
bmAttributes             : 0xA0
D7: Reserved, set 1   : 0x01
D6: Self Powered      : 0x00 (no)
D5: Remote Wakeup       : 0x01 (yes)
D4..0: Reserved, set 0: 0x00
MaxPower               : 0x31 (98 mA)

      ---------------- Interface Descriptor -----------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x04 (Interface Descriptor)
bInterfaceNumber         : 0x00
bAlternateSetting      : 0x00
bNumEndpoints            : 0x01 (1 Endpoint)
bInterfaceClass          : 0x03 (HID - Human Interface Device)
bInterfaceSubClass       : 0x01 (Boot Interface)
bInterfaceProtocol       : 0x01 (Keyboard)
iInterface               : 0x00 (No String Descriptor)

      ------------------- HID Descriptor --------------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x21 (HID Descriptor)
bcdHID                   : 0x0111 (HID Version 1.11)
bCountryCode             : 0x00 (00 = not localized)
bNumDescriptors          : 0x01
Descriptor 1:
bDescriptorType          : 0x22 (Class=Report)
wDescriptorLength      : 0x003B (59 bytes)
Error reading descriptor : ERROR_GEN_FAILURE

      ----------------- Endpoint Descriptor -----------------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x05 (Endpoint Descriptor)
bEndpointAddress         : 0x81 (Direction=INEndpointID=1)
bmAttributes             : 0x03 (TransferType=Interrupt)
wMaxPacketSize         : 0x0008 (8 bytes) (8 bytes)
bInterval                : 0x08 (8 ms)

      ---------------- Interface Descriptor -----------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x04 (Interface Descriptor)
bInterfaceNumber         : 0x01
bAlternateSetting      : 0x00
bNumEndpoints            : 0x01 (1 Endpoint)
bInterfaceClass          : 0x03 (HID - Human Interface Device)
bInterfaceSubClass       : 0x01 (Boot Interface)
bInterfaceProtocol       : 0x02 (Mouse)
iInterface               : 0x00 (No String Descriptor)

      ------------------- HID Descriptor --------------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x21 (HID Descriptor)
bcdHID                   : 0x0111 (HID Version 1.11)
bCountryCode             : 0x00 (00 = not localized)
bNumDescriptors          : 0x01
Descriptor 1:
bDescriptorType          : 0x22 (Class=Report)
wDescriptorLength      : 0x00B1 (177 bytes)
Error reading descriptor : ERROR_GEN_FAILURE

      ----------------- Endpoint Descriptor -----------------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x05 (Endpoint Descriptor)
bEndpointAddress         : 0x82 (Direction=INEndpointID=2)
bmAttributes             : 0x03 (TransferType=Interrupt)
wMaxPacketSize         : 0x0014 (20 bytes) (20 bytes)
bInterval                : 0x02 (2 ms)

高二毛 发表于 2016-9-28 16:28:36

wvalue判断完了,具体的设备需要判断一下windex
两个设备的是不一样的。

cl17726 发表于 2016-9-28 16:51:07

高二毛 发表于 2016-9-28 16:28
wvalue判断完了,具体的设备需要判断一下windex
两个设备的是不一样的。

是不一样,但是差距很大,也不知道实际上判断哪一位

cl17726 发表于 2016-9-28 16:51:38

cloudcn 发表于 2016-9-28 15:13
复合设备还是一个设备,获取描述符还是设备的描述符,主要是多接口和多端点
这是一个复合设备的描述符,对 ...

我现在是不知道怎么增加返回,我知道要开端点,8个双向端点除了EP0还有7个,完全够用啊

zfz9232 发表于 2016-9-28 20:10:10

我是来赚积分的。

dsjsjf 发表于 2016-9-28 20:39:28

我也是来赚积分的,帮顶

cloudcn 发表于 2016-9-28 22:56:11

cl17726 发表于 2016-9-28 16:51
我现在是不知道怎么增加返回,我知道要开端点,8个双向端点除了EP0还有7个,完全够用啊 ...

但是你得把端点打开啊,还要配置缓冲
具体键盘的读写我没做过,但是中断型in端点的读到是要把数据放到缓冲,并置成valid,主机会自动读取,被读走了会有端点通知,你该装备下一次的数据

高二毛 发表于 2016-9-29 09:07:46

if(wvalue)
{
if(windex == 0){}
else if(windex == 1){}
}
大体这个意思。
页: [1] 2
查看完整版本: 想实现USB复合设备,使用STM32Cube.求助