Fixed bug in RNDISEthernet and DualCDC demos not using the correct USB_ControlRequest...
[pub/USBasp.git] / LUFA / Drivers / USB / LowLevel / DevChapter9.c
index bf1cb6c..6ecadb0 100644 (file)
@@ -118,8 +118,6 @@ static void USB_Device_SetAddress(void)
 {\r
        Endpoint_ClearSETUP();\r
        \r
 {\r
        Endpoint_ClearSETUP();\r
        \r
-       while (!(Endpoint_IsINReady()));\r
-       \r
        Endpoint_ClearIN();\r
        \r
        while (!(Endpoint_IsINReady()));\r
        Endpoint_ClearIN();\r
        \r
        while (!(Endpoint_IsINReady()));\r
@@ -131,7 +129,7 @@ static void USB_Device_SetAddress(void)
 \r
 static void USB_Device_SetConfiguration(void)\r
 {\r
 \r
 static void USB_Device_SetConfiguration(void)\r
 {\r
-       bool    AlreadyConfigured = (USB_ConfigurationNumber != 0);\r
+       bool AlreadyConfigured = (USB_ConfigurationNumber != 0);\r
 \r
 #if defined(USE_SINGLE_DEVICE_CONFIGURATION)\r
        if ((uint8_t)USB_ControlRequest.wValue > 1)\r
 \r
 #if defined(USE_SINGLE_DEVICE_CONFIGURATION)\r
        if ((uint8_t)USB_ControlRequest.wValue > 1)\r
@@ -165,7 +163,7 @@ static void USB_Device_SetConfiguration(void)
 \r
 void USB_Device_GetConfiguration(void)\r
 {\r
 \r
 void USB_Device_GetConfiguration(void)\r
 {\r
-       Endpoint_ClearSETUP();  \r
+       Endpoint_ClearSETUP();\r
 \r
        Endpoint_Write_Byte(USB_ConfigurationNumber);\r
        \r
 \r
        Endpoint_Write_Byte(USB_ConfigurationNumber);\r
        \r
@@ -188,7 +186,7 @@ static void USB_Device_GetDescriptor(void)
        #if defined(USE_RAM_DESCRIPTORS)\r
        Endpoint_Write_Control_Stream_LE(DescriptorPointer, DescriptorSize);\r
        #else\r
        #if defined(USE_RAM_DESCRIPTORS)\r
        Endpoint_Write_Control_Stream_LE(DescriptorPointer, DescriptorSize);\r
        #else\r
-       bool     SendZLP;\r
+       bool SendZLP;\r
        \r
        if (USB_ControlRequest.wLength > DescriptorSize)\r
          USB_ControlRequest.wLength = DescriptorSize;\r
        \r
        if (USB_ControlRequest.wLength > DescriptorSize)\r
          USB_ControlRequest.wLength = DescriptorSize;\r
@@ -274,6 +272,8 @@ static void USB_Device_ClearSetFeature(void)
                case REQREC_DEVICE:\r
                        if ((uint8_t)USB_ControlRequest.wValue == FEATURE_REMOTE_WAKEUP)\r
                          USB_RemoteWakeupEnabled = (USB_ControlRequest.bRequest == REQ_SetFeature);\r
                case REQREC_DEVICE:\r
                        if ((uint8_t)USB_ControlRequest.wValue == FEATURE_REMOTE_WAKEUP)\r
                          USB_RemoteWakeupEnabled = (USB_ControlRequest.bRequest == REQ_SetFeature);\r
+                       else\r
+                         return;\r
                        \r
                        break;                  \r
 #if !defined(CONTROL_ONLY_DEVICE)\r
                        \r
                        break;                  \r
 #if !defined(CONTROL_ONLY_DEVICE)\r
@@ -282,33 +282,35 @@ static void USB_Device_ClearSetFeature(void)
                        {\r
                                uint8_t EndpointIndex = ((uint8_t)USB_ControlRequest.wIndex & ENDPOINT_EPNUM_MASK);\r
                                \r
                        {\r
                                uint8_t EndpointIndex = ((uint8_t)USB_ControlRequest.wIndex & ENDPOINT_EPNUM_MASK);\r
                                \r
-                               if (EndpointIndex != ENDPOINT_CONTROLEP)\r
-                               {\r
-                                       Endpoint_SelectEndpoint(EndpointIndex);\r
-\r
-                                       if (Endpoint_IsEnabled())\r
-                                       {                               \r
-                                               if (USB_ControlRequest.bRequest == REQ_ClearFeature)\r
-                                               {\r
-                                                       Endpoint_ClearStall();\r
-                                                       Endpoint_ResetFIFO(EndpointIndex);\r
-                                                       Endpoint_ResetDataToggle();\r
-                                               }\r
-                                               else\r
-                                               {\r
-                                                       Endpoint_StallTransaction();                                            \r
-                                               }\r
+                               if (EndpointIndex == ENDPOINT_CONTROLEP)\r
+                                 return;\r
+\r
+                               Endpoint_SelectEndpoint(EndpointIndex);\r
+\r
+                               if (Endpoint_IsEnabled())\r
+                               {                               \r
+                                       if (USB_ControlRequest.bRequest == REQ_ClearFeature)\r
+                                       {\r
+                                               Endpoint_ClearStall();\r
+                                               Endpoint_ResetFIFO(EndpointIndex);\r
+                                               Endpoint_ResetDataToggle();\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               Endpoint_StallTransaction();\r
                                        }\r
                                        }\r
-\r
-                                       Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);\r
-                                       Endpoint_ClearSETUP();\r
-                                       Endpoint_ClearIN();\r
                                }\r
                        }\r
                        \r
                        break;\r
 #endif\r
        }\r
                                }\r
                        }\r
                        \r
                        break;\r
 #endif\r
        }\r
+\r
+       Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);\r
+\r
+       Endpoint_ClearSETUP();\r
+\r
+       Endpoint_ClearIN();\r
 }\r
 \r
 #endif\r
 }\r
 \r
 #endif\r