if(INTERRUPTS_ENABLED_STATE() && CPU_USB_GetInterruptState() && (0 != CPU_INTC_InterruptEnableState( USB_IRQ_INDEX )))
HAL_Time_Sleep_MicroSeconds_InterruptEnabled(500); // don't call Events_WaitForEventsXXX because it will turn off interrupts
in USB_Driver::Flush should be removed for the following reasons:
- CPU_USB_GetInterruptState() cannot be implemented in a system with multiple USB controllers
- Same for USB_IRQ_INDEX
- The ‘if’ will never evaluate to true. If an interrupt is enabled and pending it is immediately taken. So we can never observe this state from other code.
- HAL_Time_Sleep_MicroSeconds_InterruptEnabled does not really sleep, it does just wait in a loop. So there is no difference in practice whether it is called or not.