This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

HID In reports does not trigger Event: APP_USBD_HID_USER_EVT_IN_REPORT_DONE with FreeFRTOS

I am trying to send multiple 64byte packets - in a loop - using app_usbd_hid_generic_in_report_set(). This together with the user event handler happens inside the same FreeRTOS thread.

Since I am in a loop I do not receive the event: APP_USBD_HID_USER_EVT_IN_REPORT_DONE which will allow me to send the next packet.

Question: Is there any other way to determine if the last In report has been successfully transferred which I can monitor in real time.

Perhaps I can monitor it and determine if when I can send the next packet - without waiting for the event handler.

  • Hi. 

    It is usually not a good idea to wait for an event in an eternal loop (perhaps unless you are doing it the main loop calling sd_app_evt_wait()). This is particularly a bad idea if you are doing it in a interrupt routine or event handler, as it will block the CPU from doing other tasks of lower or same priority.

    A way you could handle this is to wait for the call-back to the event handler. Then, in the event handler you can check for each relevant event and handle those separately. Please refer to examples/ble_peripheral/ble_app_hrs/main.c.
    You should also note that if you want do do a lot of processing, you should not do this in the event handler, as it runs with higher priority (think of it as an interrupt routine), but rather set a flag and do the processing in your main loop.

    You should continue to call sd_app_evt_wait() from your main loop.

    Best regards, 
    Joakim