Speed up calls to Pipe_IsPipeBound() by immediately skipping unconfigured pipes,...
authorDean Camera <dean@fourwalledcubicle.com>
Sat, 12 Jun 2010 07:01:18 +0000 (07:01 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Sat, 12 Jun 2010 07:01:18 +0000 (07:01 +0000)
LUFA/Drivers/USB/LowLevel/Endpoint.c
LUFA/Drivers/USB/LowLevel/Pipe.c

index 15cb9d0..22579af 100644 (file)
@@ -139,7 +139,7 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length
 #if !defined(NO_STREAM_CALLBACKS)
                                 , StreamCallbackPtr_t Callback
 #endif
 #if !defined(NO_STREAM_CALLBACKS)
                                 , StreamCallbackPtr_t Callback
 #endif
-                                                               )
+                                )
 {
        uint8_t  ErrorCode;
        
 {
        uint8_t  ErrorCode;
        
index 4bfcc21..8e817a2 100644 (file)
@@ -79,13 +79,16 @@ bool Pipe_IsEndpointBound(const uint8_t EndpointAddress)
        {
                Pipe_SelectPipe(PNum);
                
        {
                Pipe_SelectPipe(PNum);
                
-               uint8_t PipeToken = Pipe_GetPipeToken();
+               if (!(Pipe_IsConfigured()))
+                 continue;
+               
+               uint8_t PipeToken        = Pipe_GetPipeToken();
                bool    PipeTokenCorrect = true;
 
                if (PipeToken != PIPE_TOKEN_SETUP)
                  PipeTokenCorrect = (PipeToken == ((EndpointAddress & PIPE_EPDIR_MASK) ? PIPE_TOKEN_IN : PIPE_TOKEN_OUT));
                
                bool    PipeTokenCorrect = true;
 
                if (PipeToken != PIPE_TOKEN_SETUP)
                  PipeTokenCorrect = (PipeToken == ((EndpointAddress & PIPE_EPDIR_MASK) ? PIPE_TOKEN_IN : PIPE_TOKEN_OUT));
                
-               if (Pipe_IsConfigured() && PipeTokenCorrect && (Pipe_BoundEndpointNumber() == (EndpointAddress & PIPE_EPNUM_MASK)))
+               if (PipeTokenCorrect && (Pipe_BoundEndpointNumber() == (EndpointAddress & PIPE_EPNUM_MASK)))
                  return true;
        }
        
                  return true;
        }
        
@@ -131,9 +134,9 @@ uint8_t Pipe_WaitUntilReady(void)
 
 uint8_t Pipe_Discard_Stream(uint16_t Length
 #if !defined(NO_STREAM_CALLBACKS)
 
 uint8_t Pipe_Discard_Stream(uint16_t Length
 #if !defined(NO_STREAM_CALLBACKS)
-                                 , StreamCallbackPtr_t Callback
+                            , StreamCallbackPtr_t Callback
 #endif
 #endif
-                                                                )
+                            )
 {
        uint8_t  ErrorCode;
        
 {
        uint8_t  ErrorCode;