More AVR32 achitecture ports.
[pub/USBasp.git] / LUFA / Drivers / USB / Class / Host / CDC.c
index 8ad37de..cc1ff8a 100644 (file)
   this software.\r
 */\r
 \r
+#define  __INCLUDE_FROM_USB_DRIVER\r
 #include "../../HighLevel/USBMode.h"\r
 #if defined(USB_CAN_BE_HOST)\r
 \r
-#define  INCLUDE_FROM_CDC_CLASS_HOST_C\r
+#define  __INCLUDE_FROM_CDC_CLASS_HOST_C\r
+#define  __INCLUDE_FROM_CDC_DRIVER\r
 #include "CDC.h"\r
 \r
 uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, uint16_t ConfigDescriptorSize,\r
@@ -182,7 +184,8 @@ static uint8_t DComp_CDC_Host_NextCDCInterfaceEndpoint(void* const CurrentDescri
        \r
                uint8_t EndpointType = (CurrentEndpoint->Attributes & EP_TYPE_MASK);\r
        \r
-               if ((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT))\r
+               if (((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT)) &&\r
+                   !(Pipe_IsEndpointBound(CurrentEndpoint->EndpointAddress)))\r
                {\r
                        return DESCRIPTOR_SEARCH_Found;\r
                }\r
@@ -309,13 +312,22 @@ uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo
        Pipe_SetPipeToken(PIPE_TOKEN_IN);\r
        Pipe_Unfreeze();\r
 \r
-       if (Pipe_IsINReceived() && !(Pipe_BytesInPipe()))\r
-         Pipe_ClearIN();\r
-       \r
-       BytesInPipe = Pipe_BytesInPipe();\r
-       Pipe_Freeze();\r
-       \r
-       return BytesInPipe;\r
+       if (Pipe_IsINReceived())\r
+       {\r
+               if (!(Pipe_BytesInPipe()))\r
+                 Pipe_ClearIN();\r
+               \r
+               BytesInPipe = Pipe_BytesInPipe();\r
+               Pipe_Freeze();\r
+               \r
+               return BytesInPipe;\r
+       }\r
+       else\r
+       {\r
+               Pipe_Freeze();\r
+               \r
+               return 0;\r
+       }\r
 }\r
 \r
 uint8_t CDC_Host_ReceiveByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo)\r