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 ce402ad..70560cf 100644 (file)
@@ -1,11 +1,13 @@
 uint8_t TEMPLATE_FUNC_NAME (const void* Buffer, uint16_t Length)\r
 {\r
-       uint8_t* DataStream     = (uint8_t*)(Buffer + TEMPLATE_BUFFER_OFFSET(Length));\r
+       uint8_t* DataStream     = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length));\r
        bool     LastPacketFull = false;\r
        \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