Add FatFS library to the Webserver project, extend the HTTP server so that it now...
[pub/USBasp.git] / LUFA / Drivers / USB / LowLevel / Template / Template_Endpoint_Control_W.c
index a2a9b8c..70560cf 100644 (file)
@@ -5,7 +5,9 @@ uint8_t TEMPLATE_FUNC_NAME (const void* Buffer, uint16_t Length)
        \r
        if (Length > USB_ControlRequest.wLength)\r
          Length = USB_ControlRequest.wLength;\r
-       \r
+       else if (!(Length))\r
+         Endpoint_ClearIN();\r
+\r
        while (Length || LastPacketFull)\r
        {\r
                if (Endpoint_IsSETUPReceived())\r
@@ -19,13 +21,16 @@ uint8_t TEMPLATE_FUNC_NAME (const void* Buffer, uint16_t Length)
                  \r
                if (Endpoint_IsINReady())\r
                {\r
-                       while (Length && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize))\r
+                       uint16_t BytesInEndpoint = Endpoint_BytesInEndpoint();\r
+               \r
+                       while (Length && (BytesInEndpoint < USB_ControlEndpointSize))\r
                        {\r
                                TEMPLATE_TRANSFER_BYTE(DataStream);\r
                                Length--;\r
+                               BytesInEndpoint++;\r
                        }\r
                        \r
-                       LastPacketFull = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);\r
+                       LastPacketFull = (BytesInEndpoint == USB_ControlEndpointSize);\r
                        Endpoint_ClearIN();\r
                }\r
        }\r