USBH_HID_SetProtocol() protocol parameter
Hi,
I am using my own board based on an STM32F207ZG and STM32F2 HAL v1.9.4.
I implemented an HID Host using STM32CubeIDE (v1.19.0), simply selecting USB Host and HID class support in CubeMX and generating the code.
I was able to read key events from a standard USB desktop keyboard. However, I was not able to read any key events from a USB HID RF tag reader.
While debugging usbh_hid.c, I noticed the following:
USBH_HID_SetProtocol(phost, 0U); generates a SET_PROTOCOL request with wValue = 0x0001 (Report Protocol)
whereas:
USBH_HID_SetProtocol(phost, 1U); generates wValue = 0x0000 (Boot Protocol).
because this implementation:
if (protocol)
{
phost->Control.setup.b.wValue.w = 0U;
}
else
{
phost->Control.setup.b.wValue.w = 1U;
}
In other words, the protocol parameter passed to USBH_HID_SetProtocol() is inverted with respect to the value actually transmitted in the USB SET_PROTOCOL request URB.
I noticed that the same implementation is still present in STM32F2 HAL v1.9.6.
I am not saying that this is necessarily a bug, since the current implementation may be intentional and changing the meaning of the parameter would affect existing applications. However, I find the current naming/semantics somewhat confusing, especially because a call such as:
USBH_HID_SetProtocol(phost, 0U);
actually selects Report Protocol, while passing 1U selects Boot Protocol.
Has anyone else noticed this behavior or encountered confusion/problems related to it?
Thanks for sharing your experience.
