X-Git-Url: http://git.linex4red.de/pub/lufa.git/blobdiff_plain/75d440ace31c326dc80c84c3d346a425f43f1dd6..4cc7f5200beef90c39c8c8310ed7c8b849afb4d9:/LUFA/Drivers/USB/LowLevel/Pipe.c diff --git a/LUFA/Drivers/USB/LowLevel/Pipe.c b/LUFA/Drivers/USB/LowLevel/Pipe.c index 8e817a279..f8cf4f9ba 100644 --- a/LUFA/Drivers/USB/LowLevel/Pipe.c +++ b/LUFA/Drivers/USB/LowLevel/Pipe.c @@ -38,20 +38,54 @@ uint8_t USB_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE; -bool Pipe_ConfigurePipe(const uint8_t Number, const uint8_t Type, const uint8_t Token, const uint8_t EndpointNumber, - const uint16_t Size, const uint8_t Banks) +bool Pipe_ConfigurePipe(const uint8_t Number, + const uint8_t Type, + const uint8_t Token, + const uint8_t EndpointNumber, + const uint16_t Size, + const uint8_t Banks) { - Pipe_SelectPipe(Number); - Pipe_EnablePipe(); - - UPCFG1X = 0; + 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; + } - UPCFG0X = ((Type << EPTYPE0) | Token | ((EndpointNumber & PIPE_EPNUM_MASK) << PEPNUM0)); - UPCFG1X = ((1 << ALLOC) | Banks | Pipe_BytesToEPSizeMask(Size)); + 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(); + } - Pipe_SetInfiniteINRequests(); + for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++) + { + if (!(UPCFG1XTemp[PNum] & (1 << ALLOC))) + continue; + + Pipe_SelectPipe(PNum); + Pipe_EnablePipe(); - return Pipe_IsConfigured(); + UPCFG0X = UPCFG0XTemp[PNum]; + UPCFG1X = UPCFG1XTemp[PNum]; + + if (!(Pipe_IsConfigured())) + return false; + } + + Pipe_SelectPipe(Number); + Pipe_SetInfiniteINRequests(); + + return true; } void Pipe_ClearPipes(void) @@ -60,13 +94,10 @@ void Pipe_ClearPipes(void) for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++) { - Pipe_ResetPipe(PNum); Pipe_SelectPipe(PNum); - UPIENX = 0; - UPINTX = 0; - Pipe_ClearError(); - Pipe_ClearErrorFlags(); - Pipe_DeallocateMemory(); + UPIENX = 0; + UPINTX = 0; + UPCFG1X = 0; Pipe_DisablePipe(); } }