cancel
Showing results for 
Search instead for 
Did you mean: 

USB custom HID: unable to send data from controller to PC consecutively

Juan.2422
Associate II

I am using STM32L1 series and configured it as as custom HID device. I am able to receive data from PC and able to respond once using USBD_CUSTOM_HID_SendReport function. If i am trying to send again data to PC using the same function it is not working. It is going to either USB device status as busy or device state suspended.

I have used "09.7_USB HID device - custom device lab" document to configure the project. Please let me know how to figure out the issue.

12 REPLIES 12
Piranha
Chief II
Juan.2422
Associate II

@Piranha​ I was trying to understand the issue using STM library itself. Have you tried it using the same?

After the experience with Ethernet and seeing the code that team writes everywhere, when I needed USB, I didn't waste my time on a broken bloatware written by incompetent "developers" and went strait to TinyUSB. Works as a charm!

And ST's USB stack does everything in ISRs, which is a ridiculously dumb and limiting design.

@Piranha​ Thank you for your suggestions. I will look into TinyUSB implementation.

Juan.2422
Associate II

@Amel NASRI​ Could you help me with some information on issue with "unable to send data from controller to PC consecutively". I am using STM32L152RC with cubeMX version 6.3.0 and latest firmware version.

Hi @Juan.2422​ ,

In the package STM32CubeL1, there is already a ready to use CustomHID example. You find it in this path under the package: STM32CubeL1/Projects/STM32L152D-EVAL/Applications/USB_Device/CustomHID_Standalone.

To build your own example with STM32CubeMX, you can refer to this video tutorial.

Please note that latest CubeMX version is 6.5. Please try to align with this one.

-Amel

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.

@Amel NASRI​ I have followed the same video tutorial. I could always receive data from Host PC & also response back to the host using USBD_CUSTOM_HID_SendReport function.

But if micro controller device initiate USBD_CUSTOM_HID_SendReport it is failing.USB device status is either busy or device state suspended. Is there anything i am missing?

I have also tried CubeMX version is 6.5 but no progress.

@Piranha​ I have implemented and tested tiny USB but facing the same issue. I am unable to send data to host consecutively using tud_hid_report().I am calling tud_hid_report() function two times inside tud_hid_set_report_cb() callback method. What i found is ep_state is busy and claimed, so it is not sending data for the second time.

Pavel A.
Evangelist III

>  I am unable to send data to host consecutively using tud_hid_report().I am calling tud_hid_report() function two times inside tud_hid_set_report_cb() callback method.

You cannot send data to host before the host receives the previous data and requests you to send again.

No "pushing" data to the host. Design your software based on this.