AnsweredAssumed Answered

Bug / missing option in STM32CubeMX CustomHID code generation

Question asked by wong.daniel on Jun 29, 2016
Latest reply on Oct 7, 2016 by STM32Cube-T
I'm not entirely sure if this is a bug or not, but I thought I'd describe it anyway. Basically, there are options not present in STM32CubeMX for the CustomHID device which mean that it doesn't work properly if you try to send more than 2 bytes at a time.

In the past I've tried making CustomHID devices to pass data to a PC. Lets assume we want a HID device which can pass 64 bytes out ever 1ms.

This can be done by opening STM32Cube, and changing the USB_DEVICE to Custom HID device.

Then, in USB settings, change the EP size to 64 so that the entire 64 bytes can be passed at once through the endpoint. This part is fine.

Next click on 'USB_DEVICE' which opens the settings specific to a custom hid device. Then change the report descriptor size to your liking (lets say 32), and the "Out-report buffer size" to 64.

The problem with this is that there are two settings missing in STM32CubeMX which are present in the code, that is:

- "CUSTOM_HID_EPIN_SIZE" and "CUSTOM_HID_EPOUT_SIZE", in usbd_customhid.h
- polling time , in usbd_customhid.c "USBD_CUSTOM_HID_CfgDesc[]" array. By default set to 32ms (0x20)

Without setting the EPOUT size, the above won't work properly, since you're trying to send 64 bytes through an endpoint of size 2. Same goes for if you're trying to receive more than 2 bytes at a time. 

The 'polling time' would also be nice to add, otherwise the only way to change the polling time is through editing the code manually.

I didn't know where to send feedback on the STM32CubeMX software, so I'm posting in this forum.

I'm using version 4.14.0 of STM32CubeMX, with the latest libraries for the STM32F0XXX (I don't think the family makes any difference.) 

Outcomes