AnsweredAssumed Answered

STM32L0 USB CUSTOMHID Bidirectional

Question asked by mfussi on Nov 3, 2015
Latest reply on Nov 5, 2015 by mfussi
Hi guys,

I am working on a solution to implement generic bidirectional data transfer over the USB interface. I am using the current CubeL0 library (version 1.3.0) and the USB library provided in this package. I implemented the CUSTOM HID class and stick to the standard implementation provided by the class. My project is compiled using the Sourcery CodeBench Lite toolchain.

My problem is that I cannot receive data from my PC without corrupting the implemented USB HID stack. Sending and receiving data on my PC works perfectly, with any data byte sizes (2-64 byte). But after my microcontroller received the first HID package from my PC the stack gets corrupted. Based on the byte width this can have different effects on the system. For byte widths below 8 byte data transfer is still working, but the USB HID descriptor changes. I have two html files (; which show this effect, the first file was captured before a package was received and the second one was after one package was received. The device strings are not more provided after the first HID receive, which results that my Python HID script cannot list my device anymore.

If I increase the byte width of the HID report buffer to 16 byte, then the complete communication is getting corrupted. Somehow the received bytes are wrong and the second incoming packet is never received.

After all this error looks really strange and I wasn't able to figure out where the corruption happens. Has anyone any clues where I should look to find the problem? Also, are any bidirectional HID examples for my device (STM32L052) available? I only could find examples with other USB libraries or which are only sending data. As said, sending data is working fine, receiving causes the problems.

Best Greetings