Minor correction to the DevChapter9.c handling of Set and Clear feature requests...
authorDean Camera <dean@fourwalledcubicle.com>
Wed, 6 May 2009 13:17:38 +0000 (13:17 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Wed, 6 May 2009 13:17:38 +0000 (13:17 +0000)
LUFA/Drivers/USB/LowLevel/DevChapter9.c

index 9c319fc..f02d32b 100644 (file)
@@ -274,6 +274,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 +284,38 @@ 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
+       while (!(Endpoint_IsOUTReceived()));\r
+       Endpoint_ClearOUT();\r
 }\r
 \r
 #endif\r
 }\r
 \r
 #endif\r