Cleanups to the MassStorage Device demos, and the MassStorage Device Class driver.
[pub/USBasp.git] / Demos / Device / LowLevel / MassStorage / MassStorage.c
index c41b577..f9ec4a8 100644 (file)
@@ -141,7 +141,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
                                Endpoint_ClearSETUP();\r
 \r
                                /* Indicate that the current transfer should be aborted */\r
-                               IsMassStoreReset = true;                        \r
+                               IsMassStoreReset = true;\r
 \r
                                Endpoint_ClearStatusStage();\r
                        }\r
@@ -204,19 +204,6 @@ void MassStorage_Task(void)
 \r
                        /* Return command status block to the host */\r
                        ReturnCommandStatus();\r
-                       \r
-                       /* Check if a Mass Storage Reset occurred */\r
-                       if (IsMassStoreReset)\r
-                       {\r
-                               /* Reset the data endpoint banks */\r
-                               Endpoint_ResetFIFO(MASS_STORAGE_OUT_EPNUM);\r
-                               Endpoint_ResetFIFO(MASS_STORAGE_IN_EPNUM);\r
-                               \r
-                               Endpoint_SelectEndpoint(MASS_STORAGE_OUT_EPNUM);\r
-                               Endpoint_ClearStall();\r
-                               Endpoint_SelectEndpoint(MASS_STORAGE_IN_EPNUM);\r
-                               Endpoint_ClearStall();\r
-                       }\r
 \r
                        /* Indicate ready */\r
                        LEDs_SetAllLEDs(LEDMASK_USB_READY);\r
@@ -228,8 +215,23 @@ void MassStorage_Task(void)
                }\r
        }\r
 \r
-       /* Clear the abort transfer flag */\r
-       IsMassStoreReset = false;\r
+       /* Check if a Mass Storage Reset occurred */\r
+       if (IsMassStoreReset)\r
+       {\r
+               /* Reset the data endpoint banks */\r
+               Endpoint_ResetFIFO(MASS_STORAGE_OUT_EPNUM);\r
+               Endpoint_ResetFIFO(MASS_STORAGE_IN_EPNUM);\r
+               \r
+               Endpoint_SelectEndpoint(MASS_STORAGE_OUT_EPNUM);\r
+               Endpoint_ClearStall();\r
+               Endpoint_ResetDataToggle();\r
+               Endpoint_SelectEndpoint(MASS_STORAGE_IN_EPNUM);\r
+               Endpoint_ClearStall();\r
+               Endpoint_ResetDataToggle();\r
+\r
+               /* Clear the abort transfer flag */\r
+               IsMassStoreReset = false;\r
+       }\r
 }\r
 \r
 /** Function to read in a command block from the host, via the bulk data OUT endpoint. This function reads in the next command block\r