Added HID class bootloader, compatible with a modified version of the command line...
[pub/USBasp.git] / LUFA / Drivers / USB / LowLevel / Pipe.c
index 74a8f51..82a9c1a 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2010.
+     Copyright (C) Dean Camera, 2011.
 
   dean [at] fourwalledcubicle [dot] com
 
   dean [at] fourwalledcubicle [dot] com
-      www.fourwalledcubicle.com
+           www.lufa-lib.org
 */
 
 /*
 */
 
 /*
-  Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com)
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
@@ -44,6 +44,7 @@ bool Pipe_ConfigurePipe(const uint8_t Number,
                         const uint16_t Size,
                         const uint8_t Banks)
 {
                         const uint16_t Size,
                         const uint8_t Banks)
 {
+#if defined(ORDERED_EP_CONFIG)
        Pipe_SelectPipe(Number);
        Pipe_EnablePipe();
 
        Pipe_SelectPipe(Number);
        Pipe_EnablePipe();
 
@@ -55,6 +56,58 @@ bool Pipe_ConfigurePipe(const uint8_t Number,
        Pipe_SetInfiniteINRequests();
 
        return Pipe_IsConfigured();
        Pipe_SetInfiniteINRequests();
 
        return Pipe_IsConfigured();
+#else  
+       for (uint8_t PNum = Number; PNum < PIPE_TOTAL_PIPES; PNum++)
+       {
+               uint8_t UPCFG0XTemp;
+               uint8_t UPCFG1XTemp;
+               uint8_t UPCFG2XTemp;
+               uint8_t UPCONXTemp;
+               uint8_t UPINRQXTemp;
+               uint8_t UPIENXTemp;
+
+               Pipe_SelectPipe(PNum);
+               
+               if (PNum == Number)
+               {
+                       UPCFG0XTemp = ((Type << EPTYPE0) | Token | ((EndpointNumber & PIPE_EPNUM_MASK) << PEPNUM0));
+                       UPCFG1XTemp = ((1 << ALLOC) | Banks | Pipe_BytesToEPSizeMask(Size));
+                       UPCFG2XTemp = 0;
+                       UPCONXTemp  = ((1 << PEN) | (1 << INMODE));
+                       UPINRQXTemp = 0;
+                       UPIENXTemp  = 0;
+               }
+               else
+               {
+                       UPCFG0XTemp = UPCFG0X;
+                       UPCFG1XTemp = UPCFG1X;
+                       UPCFG2XTemp = UPCFG2X;
+                       UPCONXTemp  = UPCONX;
+                       UPINRQXTemp = UPINRQX;
+                       UPIENXTemp  = UPIENX;
+               }
+
+               if (!(UPCFG1XTemp & (1 << ALLOC)))
+                 continue;
+                 
+               Pipe_DisablePipe();
+               UPCFG1X &= (1 << ALLOC);
+
+               Pipe_EnablePipe();
+               UPCFG0X = UPCFG0XTemp;
+               UPCFG1X = UPCFG1XTemp;
+               UPCFG2X = UPCFG2XTemp;
+               UPCONX  = UPCONXTemp;
+               UPINRQX = UPINRQXTemp;
+               UPIENX  = UPIENXTemp;
+
+               if (!(Pipe_IsConfigured()))
+                 return false;         
+       }
+               
+       Pipe_SelectPipe(Number);        
+       return true;
+#endif
 }
 
 void Pipe_ClearPipes(void)
 }
 
 void Pipe_ClearPipes(void)