3

Closed

Elimination of useless code in USB Driver

description

The part
 
    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.
Closed Oct 4, 2012 at 5:30 PM by ZachLibby

comments

wrote Sep 25, 2012 at 5:09 PM

This bug has been fixed and will be in the v4.3 release.  Please note that the interrupt enabled looping is still in place so that the timeout will work correctly.

wrote Oct 4, 2012 at 5:30 PM

Resolved with changeset 25620: Updates for 4.3 Beta (VS2012 support)