lpcexpresso55s28 dev hid generic freertos example

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

lpcexpresso55s28 dev hid generic freertos example

1,383 Views
AlonaB
Contributor I

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.

for (; devState < ((uint32_t)USB_DEVICE_IP3511_ENDPOINTS_NUM * 2U); ++devState) {
/* Check the endpoint interrupt */
if (0U != (interruptStatus & (0x01UL << devState))) { USB_DeviceLpc3511IpInterruptToken(lpc3511IpState, (uint8_t)devState, 0U, usbErrorCode);
} }
 

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!

0 Kudos
Reply
2 Replies

125 Views
yisey
Contributor I

You can prevent the event from retriggering by adding a software “busy” flag. When your buffer is full, set the flag and return kStatus_USB_Busy in kUSB_DeviceHidEventSetReport. It’s similar to figuring out How Much Pearls Are Worth—you need to track the value carefully before proceeding. Ignore further events while the flag is set. Then, clear the flag in kUSB_DeviceHidEventSendResponse once the transfer completes. This way, the HID stack won’t process duplicate messages even if the endpoint interrupt fires again.

0 Kudos
Reply

615 Views
yisey
Contributor I

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.

0 Kudos
Reply