cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to use USB HID keyboard and mouse at the same time on a STM32F469?

Digimorf
Associate III

Hello, I need to understand if it's possible to use both USB HID keyboard and mouse in a project powered by a STM32F469. I have thought about plug a mini HUB and connect both keyboard and mouse. Is there something I can start from? I have searched a lot but I can't find find something similar. Thanks

20 REPLIES 20
Digimorf
Associate III

Thanks for the information, actually I just found this project on Github

STM32F4HUB

https://github.com/mori-br/STM32F4HUB

that seems to be really promising. I have tried it, and it finds correctly a hub. But it seems to have problems when reading devices plugged in. Sometimes it works but with one device only. The author says that this driver works with FS devices because of some problems of the USB.

I will try to port it to the stm32f469 ​and the latest HAL version.

But if someone has any ideas...

Please note that this project is not finished and abandoned by the author.

The reason why it works only with FS devices is errata or the USB controller of STM32F4.

I haven't worked on the 'F4 USB recently and forgot details, please google or ask ST support.

Segger supports hubs in their USB host library and they say that newer STM32 F7, H7 do not suffer from that errata.

-- pa

Digimorf
Associate III

@Pavel A.​ 

Thank you for your answer, unfortunately, I can't change MCU at this stage of the project. For the release version I only support the use of the keyboard, but I was digging into the matter and check if there is the possibility to use a mouse also:

www.arcadeit.net

I will try to contact the support to know if in the 469 has the same issue, or if it has been solved in newer units.

I will go on doing research on this, but thanks.

Pavel A.
Evangelist III

> I was digging into the matter and check if there is the possibility to use a mouse also:

Of course, mice work in general. But what surprised me that mice that can be found 'in wild' are much more diverse than keyboards.

Only few models support the basic 'boot' protocol featured in the ST example.

For most mice you'll need to parse HID descriptors and deal with complex report formats. Some of them have multiple HID collections and some even are composite (not clear why)

-- pa

Digimorf
Associate III

"For most mice you'll need to parse HID descriptors and deal with complex report formats. Some of them have multiple HID collections and some even are composite (not clear why)"... Oh, good 😅 Once USB meant Universal Serial Bus... :rolling_on_the_floor_laughing:

Anyway, I have tested the STM32HUB project on a Discovery board with all keyboards (5) and mice (6) that I have. No one uses FS! All LS except for a wireless mouse by HP, and a combo Keyboard + Smart card reader that are FS. This concerns me a bit.

Digimorf
Associate III

I had an interesting test with STM32F4HUB code on the Discovery F4. Since all keyboard and mice that I have didn't work together through a HUB, I tried to understand if combo devices could work better, and I got an interesting surprise: do you remember those old adapters USB to PS/2 for using PS/2 Keyboard and mouse on one USB port? Good, that worked!

Not only with PS2 devices but also with USB kyb&mouse through a PS2 to USB single adapter on each end.

So I was able to use the USB keyboard and mouse through those adapters , see attachment. There are still some weird behaviors when resetting and starting the Discovery, but when the firmware doesn't "freeze" it works perfectly 🙂

0693W000003RwNOQA0.jpgWhat do you think?

This is the log text of the STM32F4HUB terminal:

APP RUNNING...
MCU-ID 10076413
HAL_HCD_MspInit
USB Device Attached
USBH_LL_GetSpeed 2 (LOW=2,FULL=1)
addrd: 0x00, pipe: 0
addrd: 0x80, pipe: 1
USBH_ParseDevDesc
12 01 01 01 00 00 00 08
Enum mps: 8, addr: 0
USBH_ParseDevDesc
12 01 01 01 00 00 00 08 B4 04 81 80 06 01 01 02 00 01
PID  : 8081h
VID  : 4b4h
Address (#5) assigned.
USBH_ParseCfgDesc, number of interfaces: 2
itfclass 0x03
USBH_ParseInterfaceDesc, itf 0, class 0x03, subclass: 0x01, proto: 0x01, numep 1
itfclass 0x03
USBH_ParseInterfaceDesc, itf 1, class 0x03, subclass: 0x01, proto: 0x02, numep 1
Manufacturer : Cypress
Product : PS/2 to USB Adapter
Serial Number : N/A
Enumeration done.
This device has only 1 configuration.
Default configuration set.
INTERFACES: 2
Switching to Interface (#0)
Class    : 3h
SubClass : 1h
Protocol : 1h
HID LEN 65 - 0
KeyBoard found.
addrd: 0x81, pipe: 2
IN  size=8, num 2, addr 0x81, pool 10, lowspeed? 1
Switching to Interface (#1)
Class    : 3h
SubClass : 1h
Protocol : 2h
HID LEN 52 - 1
Mouse found.
addrd: 0x82, pipe: 3
IN  size=4, num 3, addr 0x82, pool 10, lowspeed? 1
Switching to Interface (#0)
HID class started.
KEYB 10
KEYB 0
KEYB 17
KEYB 0
BUTTON 0
BUTTON 0
BUTTON 0
BUTTON 0

This could be an easy solution to use those old devices also 🙂

Nice. Cypress is a good company, their stuff is reliable.

By the way, once we've made a STM32F4 based host for USB keyboard & mouse and PS/2 keyboard and mouse - all in one.

It was kind of a KVM switch. For the remote (device) end I wanted to use these PS/2 to USB adapters, because they are LS and very compatible with everything.

-- pa

Okay, but this is not a hub, but a 2-interface single HID device.

JW