Re-add in simple scheduler for compatibility with legacy code, mark all scheduler...
[pub/USBasp.git] / LUFA / Drivers / USB / Class / Host / CDC.c
index 6eca8ae..3a572f1 100644 (file)
@@ -34,7 +34,7 @@
 #define  INCLUDE_FROM_CDC_CLASS_HOST_C\r
 #include "CDC.h"\r
 \r
-static uint8_t CDC_Host_ProcessConfigDescriptor(void)\r
+static uint8_t CDC_Host_ProcessConfigDescriptor(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo)\r
 {\r
        uint8_t* ConfigDescriptorData;\r
        uint16_t ConfigDescriptorSize;\r
@@ -59,13 +59,13 @@ static uint8_t CDC_Host_ProcessConfigDescriptor(void)
                return CDC_ENUMERROR_NoCDCInterfaceFound;\r
        }\r
 \r
-       while (FoundEndpoints != ((1 << CDC_NOTIFICATIONPIPE) | (1 << CDC_DATAPIPE_IN) | (1 << CDC_DATAPIPE_OUT)))\r
+       while (FoundEndpoints != (CDC_FOUND_DATAPIPE_IN | CDC_FOUND_DATAPIPE_OUT | CDC_FOUND_DATAPIPE_NOTIFICATION))\r
        {\r
                if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
                                              DComp_CDC_Host_NextInterfaceCDCDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)\r
                {\r
                        /* Check to see if the control interface's notification pipe has been found, if so search for the data interface */\r
-                       if (FoundEndpoints & (1 << CDC_NOTIFICATIONPIPE))\r
+                       if (FoundEndpoints & CDC_FOUND_DATAPIPE_NOTIFICATION)\r
                        {\r
                                /* Get the next CDC data interface from the configuration descriptor (CDC class has two CDC interfaces) */\r
                                if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, \r
@@ -79,11 +79,11 @@ static uint8_t CDC_Host_ProcessConfigDescriptor(void)
                        {\r
                                FoundEndpoints = 0;\r
 \r
-                               Pipe_SelectPipe(CDC_NOTIFICATIONPIPE);\r
+                               Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipeNumber);\r
                                Pipe_DisablePipe();\r
-                               Pipe_SelectPipe(CDC_DATAPIPE_IN);\r
+                               Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);\r
                                Pipe_DisablePipe();\r
-                               Pipe_SelectPipe(CDC_DATAPIPE_OUT);\r
+                               Pipe_SelectPipe(CDCInterfaceInfo->Config.NotificationPipeNumber);\r
                                Pipe_DisablePipe();\r
                        \r
                                if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
@@ -106,35 +106,38 @@ static uint8_t CDC_Host_ProcessConfigDescriptor(void)
                {\r
                        if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)\r
                        {                                                          \r
-                               Pipe_ConfigurePipe(CDC_NOTIFICATIONPIPE, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN,\r
+                               Pipe_ConfigurePipe(CDCInterfaceInfo->Config.NotificationPipeNumber, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN,\r
                                                                   EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE);\r
+                               CDCInterfaceInfo->State.NotificationPipeSize = EndpointData->EndpointSize;\r
 \r
                                Pipe_SetInfiniteINRequests();\r
                                Pipe_SetInterruptPeriod(EndpointData->PollingIntervalMS);\r
                                \r
-                               FoundEndpoints |= (1 << CDC_NOTIFICATIONPIPE);\r
+                               FoundEndpoints |= CDC_FOUND_DATAPIPE_NOTIFICATION;\r
                        }\r
                }\r
                else\r
                {\r
                        if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)\r
                        {\r
-                               Pipe_ConfigurePipe(CDC_DATAPIPE_IN, EP_TYPE_BULK, PIPE_TOKEN_IN,\r
+                               Pipe_ConfigurePipe(CDCInterfaceInfo->Config.DataINPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_IN,\r
                                                                   EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE);\r
+                               CDCInterfaceInfo->State.DataINPipeSize = EndpointData->EndpointSize;\r
 \r
                                Pipe_SetInfiniteINRequests();\r
                                Pipe_Unfreeze();\r
                                \r
-                               FoundEndpoints |= (1 << CDC_DATAPIPE_IN);\r
+                               FoundEndpoints |= CDC_FOUND_DATAPIPE_IN;\r
                        }\r
                        else\r
                        {\r
-                               Pipe_ConfigurePipe(CDC_DATAPIPE_OUT, EP_TYPE_BULK, PIPE_TOKEN_OUT,\r
+                               Pipe_ConfigurePipe(CDCInterfaceInfo->Config.DataOUTPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_OUT,\r
                                                                   EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE);\r
+                               CDCInterfaceInfo->State.DataOUTPipeSize = EndpointData->EndpointSize;\r
                                \r
                                Pipe_Unfreeze();\r
                                \r
-                               FoundEndpoints |= (1 << CDC_DATAPIPE_OUT);\r
+                               FoundEndpoints |= CDC_FOUND_DATAPIPE_OUT;\r
                        }\r
                }\r
        }\r
@@ -199,7 +202,7 @@ void CDC_Host_USBTask(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo)
        switch (USB_HostState)\r
        {\r
                case HOST_STATE_Addressed:\r
-                       if ((ErrorCode = CDC_Host_ProcessConfigDescriptor()) != SuccessfulConfigRead)\r
+                       if ((ErrorCode = CDC_Host_ProcessConfigDescriptor(CDCInterfaceInfo)) != CDC_ENUMERROR_NoError)\r
                        {\r
                                USB_HostState = HOST_STATE_Unattached;\r
                        }\r