Added new ENDPOINT_*_BusSuspended error code to the Endpoint function, so that the...
[pub/USBasp.git] / LUFA / Drivers / USB / LowLevel / DevChapter9.c
index 4527c1b..17a5fd4 100644 (file)
@@ -1,13 +1,13 @@
 /*\r
              LUFA Library\r
 /*\r
              LUFA Library\r
-     Copyright (C) Dean Camera, 2009.\r
+     Copyright (C) Dean Camera, 2010.\r
               \r
   dean [at] fourwalledcubicle [dot] com\r
       www.fourwalledcubicle.com\r
 */\r
 \r
 /*\r
               \r
   dean [at] fourwalledcubicle [dot] com\r
       www.fourwalledcubicle.com\r
 */\r
 \r
 /*\r
-  Copyright 2009  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+  Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
 \r
   Permission to use, copy, modify, distribute, and sell this \r
   software and its documentation for any purpose is hereby granted\r
 \r
   Permission to use, copy, modify, distribute, and sell this \r
   software and its documentation for any purpose is hereby granted\r
   this software.\r
 */\r
 \r
   this software.\r
 */\r
 \r
+#define  __INCLUDE_FROM_USB_DRIVER\r
 #include "../HighLevel/USBMode.h"\r
 \r
 #if defined(USB_CAN_BE_DEVICE)\r
 \r
 #include "../HighLevel/USBMode.h"\r
 \r
 #if defined(USB_CAN_BE_DEVICE)\r
 \r
-#define  INCLUDE_FROM_DEVCHAPTER9_C\r
+#define  __INCLUDE_FROM_DEVCHAPTER9_C\r
 #include "DevChapter9.h"\r
 \r
 uint8_t USB_ConfigurationNumber;\r
 #include "DevChapter9.h"\r
 \r
 uint8_t USB_ConfigurationNumber;\r
@@ -322,7 +323,7 @@ static void USB_Device_GetStatus(void)
 #endif\r
 #if !defined(CONTROL_ONLY_DEVICE)\r
                case (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT):\r
 #endif\r
 #if !defined(CONTROL_ONLY_DEVICE)\r
                case (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT):\r
-                       Endpoint_SelectEndpoint(USB_ControlRequest.wIndex & 0xFF);\r
+                       Endpoint_SelectEndpoint((uint8_t)USB_ControlRequest.wIndex & ENDPOINT_EPNUM_MASK);\r
 \r
                        CurrentStatus = Endpoint_IsStalled();\r
 \r
 \r
                        CurrentStatus = Endpoint_IsStalled();\r
 \r
@@ -343,7 +344,7 @@ static void USB_Device_GetStatus(void)
 }\r
 \r
 static void USB_Device_ClearSetFeature(void)\r
 }\r
 \r
 static void USB_Device_ClearSetFeature(void)\r
-{      \r
+{\r
        switch (USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT)\r
        {\r
 #if !defined(NO_DEVICE_REMOTE_WAKEUP)                  \r
        switch (USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT)\r
        {\r
 #if !defined(NO_DEVICE_REMOTE_WAKEUP)                  \r
@@ -366,18 +367,18 @@ static void USB_Device_ClearSetFeature(void)
 \r
                                Endpoint_SelectEndpoint(EndpointIndex);\r
 \r
 \r
                                Endpoint_SelectEndpoint(EndpointIndex);\r
 \r
-                               if (Endpoint_IsEnabled())\r
-                               {                               \r
-                                       if (USB_ControlRequest.bRequest == REQ_SetFeature)\r
-                                       {\r
-                                               Endpoint_StallTransaction();\r
-                                       }\r
-                                       else\r
-                                       {\r
-                                               Endpoint_ClearStall();\r
-                                               Endpoint_ResetFIFO(EndpointIndex);\r
-                                               Endpoint_ResetDataToggle();\r
-                                       }                                       \r
+                               if (!(Endpoint_IsEnabled()))\r
+                                 return;\r
+\r
+                               if (USB_ControlRequest.bRequest == REQ_SetFeature)\r
+                               {\r
+                                       Endpoint_StallTransaction();\r
+                               }\r
+                               else\r
+                               {\r
+                                       Endpoint_ClearStall();\r
+                                       Endpoint_ResetFIFO(EndpointIndex);\r
+                                       Endpoint_ResetDataToggle();\r
                                }\r
                        }\r
                        \r
                                }\r
                        }\r
                        \r