Oops - revert changes to the Device mode Class Driver VirtualSerial demo makefile.
[pub/USBasp.git] / LUFA / Drivers / USB / LowLevel / Pipe.c
index a8eb50f..e5c30e4 100644 (file)
@@ -44,47 +44,17 @@ bool Pipe_ConfigurePipe(const uint8_t Number,
                         const uint16_t Size,
                         const uint8_t Banks)
 {
-       uint8_t UPCFG0XTemp[PIPE_TOTAL_PIPES];
-       uint8_t UPCFG1XTemp[PIPE_TOTAL_PIPES];
-       
-       for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++)
-       {
-               Pipe_SelectPipe(PNum);
-               UPCFG0XTemp[PNum] = UPCFG0X;
-               UPCFG1XTemp[PNum] = UPCFG1X;
-       }
-       
-       UPCFG0XTemp[Number] = ((Type << EPTYPE0) | Token | ((EndpointNumber & PIPE_EPNUM_MASK) << PEPNUM0));
-       UPCFG1XTemp[Number] = ((1 << ALLOC) | Banks | Pipe_BytesToEPSizeMask(Size));
-       
-       for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++)
-       {
-               Pipe_SelectPipe(PNum);
-               UPIENX  = 0;
-               UPINTX  = 0;
-               UPCFG1X = 0;
-               Pipe_DisablePipe();
-       }
-
-       for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++)
-       {
-               if (!(UPCFG1XTemp[PNum] & (1 << ALLOC)))
-                 continue;
-               
-               Pipe_SelectPipe(PNum);          
-               Pipe_EnablePipe();
+       Pipe_SelectPipe(Number);
+       Pipe_EnablePipe();
 
-               UPCFG0X = UPCFG0XTemp[PNum];
-               UPCFG1X = UPCFG1XTemp[PNum];
-               
-               if (!(Pipe_IsConfigured()))
-                 return false;
-       }
+       UPCFG1X = 0;
        
-       Pipe_SelectPipe(Number);
+       UPCFG0X = ((Type << EPTYPE0) | Token | ((EndpointNumber & PIPE_EPNUM_MASK) << PEPNUM0));
+       UPCFG1X = ((1 << ALLOC) | Banks | Pipe_BytesToEPSizeMask(Size));
+
        Pipe_SetInfiniteINRequests();
-       
-       return true;
+
+       return Pipe_IsConfigured();
 }
 
 void Pipe_ClearPipes(void)
@@ -133,6 +103,8 @@ uint8_t Pipe_WaitUntilReady(void)
        #else
        uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;
        #endif
+
+       uint16_t PreviousFrameNumber = USB_Host_GetFrameNumber();
        
        for (;;)
        {
@@ -151,10 +123,12 @@ uint8_t Pipe_WaitUntilReady(void)
                  return PIPE_READYWAIT_PipeStalled;
                else if (USB_HostState == HOST_STATE_Unattached)
                  return PIPE_READYWAIT_DeviceDisconnected;
-                         
-               if (USB_INT_HasOccurred(USB_INT_HSOFI))
+
+               uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber();
+
+               if (CurrentFrameNumber != PreviousFrameNumber)
                {
-                       USB_INT_Clear(USB_INT_HSOFI);
+                       PreviousFrameNumber = CurrentFrameNumber;
 
                        if (!(TimeoutMSRem--))
                          return PIPE_READYWAIT_Timeout;