Hello,
I am using the LPC55S28 microcontroller and adapting code from the hid generic example into my project. I implemented a type of flow control by returning kStatus_USB_Busy in kUSB_DeviceHidEventSetReport when I want the host to wait and not send more messages.
This behavior is triggered immediately because interruptStatus and devState are updated to 2 and 1, respectively.
How can I prevent this event from being re-triggered, given that the buffer does not contain any new data? Currently, this results in duplicate messages being processed every time I return the kStatus_USB_Busy status.
I would appreciate your help!
Use a software flag to track the busy state. Before processing kUSB_DeviceHidEventSetReport, check if a flag like isHidBusy is set. If it is, skip processing to prevent duplicate handling. Similar to how Turf Protection window film prevents repeated damage, this flag ensures the same event isn’t retriggered while the buffer hasn’t changed. Only clear the flag when the previous data has been fully handled. Additionally, ensure the endpoint interrupt flag is cleared or skipped in the ISR if no new data is available.