你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

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

[复制链接]
cl17726 提问时间:2016-9-28 14:30 /
想实现复合设备,使用STM32Cube,主芯片是STM32F072,需要实现的是键盘鼠标一体化设备,就是插在电脑上识别出键盘和鼠标.

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

微信截图_20160928142443.png

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

微信截图_20160928142615.png

把接口数改成2.

微信截图_20160928142729.png

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

微信截图_20160928142839.png

改完这两个还有多少步骤?EP的配置应该还好解决.
收藏 2 评论12 发布时间:2016-9-28 14:30

举报

12个回答
stary666 回答时间:2016-9-28 15:05:56
可以实现的,,,
st.png
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[0]           : 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=IN  EndpointID=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=IN  EndpointID=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){}
}
大体这个意思。
12下一页

所属标签

相似问题

官网相关资源

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
微信公众号二维码 微信公众号
手机版二维码 手机版