Fixed incorrect/missing control status stage transfers on demos, bootloaders and...
[pub/USBasp.git] / Demos / MassStorage / MassStorage.c
index 34fcee4..92e3307 100644 (file)
@@ -159,10 +159,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                case REQ_MassStorageReset:\r
                        if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
-                               /* Indicate that the current transfer should be aborted */\r
-                               IsMassStoreReset = true;\r
-                       \r
                                Endpoint_ClearSetupReceived();\r
+\r
+                               /* Indicate that the current transfer should be aborted */\r
+                               IsMassStoreReset = true;                        \r
+\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupINReady()));\r
                                Endpoint_ClearSetupIN();\r
                        }\r
 \r
@@ -171,9 +174,15 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                        if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
                                /* Indicate to the host the number of supported LUNs (virtual disks) on the device */\r
-                               Endpoint_ClearSetupReceived();                  \r
+                               Endpoint_ClearSetupReceived();\r
+\r
                                Endpoint_Write_Byte(TOTAL_LUNS - 1);\r
+                               \r
                                Endpoint_ClearSetupIN();\r
+                               \r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupOUTReceived()));\r
+                               Endpoint_ClearSetupOUT();\r
                        }\r
                        \r
                        break;\r