2023-11-12 07:44 PM - edited 2023-11-12 07:57 PM
Hi guys,
I'm trying to use STM32 as a host for a HID keyboard and mouse.
I have 2 wireless mouses to test (Logitech M560, HP Spectre 700), Logitech T-BC21 wired trackball, some low-end keyboard. I'm connecting them via micro-USB to USB converter that works properly with my old tablet.
LED near USB port on NUCLEO lights up, looks like it enumerates my all test devices (function returns OK), but I'm always getting stuck in USBH_HID_POLL state and I never get this condition true (after pressing keys, moving or clicking mouses):
// usbh_hid.c USBH_HID_Process(...) function
if (USBH_LL_GetURBState(phost, HID_Handle->InPipe) == USBH_URB_DONE)
I'm following this tutorial from ControllersTech, that basically just uses generated code, except that I'm using FreeRTOS. USB interrupt is enabled (can't be turned off in code generator).
I'm powering NUCLEO from my PC USB port (programming/debugging). I have not tried to power the board from external 5V supply, but I don't think this could make any difference, since the keyboard is relatively low power.
My environment:
STM32CubeIDE
Version: 1.13.2
Build: 18220_20230914_1601 (UTC)
Here is my configuration:
Solved! Go to Solution.
2023-11-14 04:30 AM
I have found a solution.
The problem was in 1.17 software package.
I have crated two identical projects:
It looks like new driver or middleware is somehow broken.
The problem is blooming on github for few months (link), looks like it affects various USB demo applications for Discovery and Nucleo devices (confirmed by others on github) and also generated middleware or driver code in my case.
Thanks for your interest guys, I hope the staff will find time to look into it. So far, the most reasonable solution is to use an older version of the IDE with an older firmware package (the new version of the IDE does not support FW 1.16.2).
2023-11-13 12:37 AM
Hello @kaamil1984 ,
I advise you to get inspired from an available HID_StandaloneI example available in STM32CubeF7 package.
This is a typical application on how to use the STM32F722ZE USB OTG Host peripheral to interact with an USB HID Device such as a Mouse or a Keyboard.
I think this example may help you to configure the HID keyboard by following the instructions in the readme file.
I hope this help you.
Kaouthar
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-11-13 08:43 AM
So I have started this example, but without Adafruit thing.
I'm changing `hid_state` to `HID_DEMO_START` manually in the Live Expressions instead of menu.
`USBH_HID_GetDeviceType` returns type correctly. When I connect the mouse state changes to HID_MOUSE, and the mouse application state switches HID_MOUSE_IDLE, and then goes forward until HID_MOUSE_WAIT.
In HID_MOUSE_WAIT this code is called in loop:
static void USBH_MouseDemo(USBH_HandleTypeDef *phost)
{
HID_MOUSE_Info_TypeDef *m_pinfo;
m_pinfo = USBH_HID_GetMouseInfo(phost);
if(m_pinfo != NULL)
{
/* Handle Mouse data position */
USR_MOUSE_ProcessData(&mouse_info);
if(m_pinfo->buttons[0])
{
HID_MOUSE_ButtonPressed(0);
}
else
{
HID_MOUSE_ButtonReleased(0);
}
// ...
}
}
But `USBH_HID_GetMouseInfo` is never called, because `m_pinfo` is always NULL.
I also tried wired optical USB mouse and effect is still the same.
What is going on?
2023-11-13 12:17 PM
You wrote that you have several mouse models. Can you find a very old mouse, some Microsoft or IBM model? Unfortunately mice use many formats of HID report, much more versatile than keyboards. Probably something goes wrong in the HID data parsing code. Try to debug.
2023-11-14 04:30 AM
I have found a solution.
The problem was in 1.17 software package.
I have crated two identical projects:
It looks like new driver or middleware is somehow broken.
The problem is blooming on github for few months (link), looks like it affects various USB demo applications for Discovery and Nucleo devices (confirmed by others on github) and also generated middleware or driver code in my case.
Thanks for your interest guys, I hope the staff will find time to look into it. So far, the most reasonable solution is to use an older version of the IDE with an older firmware package (the new version of the IDE does not support FW 1.16.2).
2023-11-14 07:41 AM
Hello @kaamil1984 ,
Thank you for bringing this issue to our attention.
I confirm the issue and I reported internally.
Internal ticket number: 166306 (This is an internal tracking number and is not accessible or usable by customers).
Thank you.
Kaouthar
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-05-01 01:26 AM - edited 2024-05-01 01:27 AM
hi ..
any solution on ticket number for usb issue ? . i am having similar issue like below
problem is very much visible
Speed setting different & channels number is different :
Cube ide Generating additional code line for STMF722ZE & STM32F732ZE ( complete STMF72XXXXX series STMF73XXXX )
additional code line:
Cube ide Generating code without additional above mentioned line for STMF746XX,STM32F756XX &STM32F767XX & STM32F401XXXXseries .
code generation must be only issue .