I have not observed any issues yet, just was looking at code to understand buffer usage/copy ...
and came with this code:
file usb_device_dci.c of LPC SDK 2.5
function USB_DeviceTransfer at line 277 checks if endpoint callback is busy and then "enters critical" to mark it busy
if (deviceHandle->epCallback[(uint8_t)((uint32_t)endpoint << 1U) | direction].isBusy)
{
return kStatus_USB_Busy;
} "here is race ? if not, then why enter critical to set a boolean ?"
USB_OSA_ENTER_CRITICAL();
deviceHandle->epCallback[(uint8_t)((uint32_t)endpoint << 1U) | direction].isBusy = 1U;
USB_OSA_EXIT_CRITICAL();
I think it should be, first enter critical, check and mark it busy and in any case exit critical
USB_OSA_ENTER_CRITICAL();
if (deviceHandle->epCallback[(uint8_t)((uint32_t)endpoint << 1U) | direction].isBusy)
{
USB_OSA_EXIT_CRITICAL();
return kStatus_USB_Busy;
}
deviceHandle->epCallback[(uint8_t)((uint32_t)endpoint << 1U) | direction].isBusy = 1U;
USB_OSA_EXIT_CRITICAL();