Remove USB_MODE_* macros, replace with a semantically linked USB_Modes_t enum.
[pub/USBasp.git] / LUFA / Drivers / USB / LowLevel / Host.c
index 1d7faa1..1fa5290 100644 (file)
@@ -196,14 +196,13 @@ uint8_t USB_Host_WaitMS(uint8_t MS)
 {
        bool    BusSuspended = USB_Host_IsBusSuspended();
        uint8_t ErrorCode    = HOST_WAITERROR_Successful;
+       bool    HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI);
        
-       USB_Host_ResumeBus();
-
-       bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI);
-
        USB_INT_Disable(USB_INT_HSOFI);
        USB_INT_Clear(USB_INT_HSOFI);
 
+       USB_Host_ResumeBus();
+
        while (MS)
        {
                if (USB_INT_HasOccurred(USB_INT_HSOFI))
@@ -212,7 +211,7 @@ uint8_t USB_Host_WaitMS(uint8_t MS)
                        MS--;
                }
                                        
-               if ((USB_HostState == HOST_STATE_Unattached) || (USB_CurrentMode == USB_MODE_DEVICE))
+               if ((USB_HostState == HOST_STATE_Unattached) || (USB_CurrentMode != USB_MODE_Host))
                {
                        ErrorCode = HOST_WAITERROR_DeviceDisconnect;
                        
@@ -236,12 +235,12 @@ uint8_t USB_Host_WaitMS(uint8_t MS)
                }
        }
 
-       if (HSOFIEnabled)
-         USB_INT_Enable(USB_INT_HSOFI);
-
        if (BusSuspended)
          USB_Host_SuspendBus();
 
+       if (HSOFIEnabled)
+         USB_INT_Enable(USB_INT_HSOFI);
+
        return ErrorCode;
 }
 
@@ -336,7 +335,7 @@ uint8_t USB_Host_GetDeviceStringDescriptor(const uint8_t Index,
        return USB_Host_SendControlRequest(Buffer);
 }
 
-uint8_t USB_Host_ClearPipeStall(uint8_t EndpointNum)
+uint8_t USB_Host_ClearPipeStall(const uint8_t EndpointNum)
 {
        USB_ControlRequest = (USB_Request_Header_t)
                {