Add demos/bootloaders/projects overview to the manual.
[pub/USBasp.git] / Demos / Host / ClassDriver / MassStorageHost / Lib / MassStoreCommands.c
index f47e9f5..7597473 100644 (file)
@@ -107,10 +107,6 @@ static uint8_t MassStore_WaitForDataReceived(void)
 {\r
        uint16_t TimeoutMSRem = COMMAND_DATA_TIMEOUT_MS;\r
 \r
 {\r
        uint16_t TimeoutMSRem = COMMAND_DATA_TIMEOUT_MS;\r
 \r
-       /* Unfreeze the OUT pipe so that it can be checked */\r
-       Pipe_SelectPipe(MASS_STORE_DATA_OUT_PIPE);\r
-       Pipe_Unfreeze();\r
-\r
        /* Select the IN data pipe for data reception */\r
        Pipe_SelectPipe(MASS_STORE_DATA_IN_PIPE);\r
        Pipe_Unfreeze();\r
        /* Select the IN data pipe for data reception */\r
        Pipe_SelectPipe(MASS_STORE_DATA_IN_PIPE);\r
        Pipe_Unfreeze();\r
@@ -119,10 +115,10 @@ static uint8_t MassStore_WaitForDataReceived(void)
        while (!(Pipe_IsINReceived()))\r
        {\r
                /* Check to see if a new frame has been issued (1ms elapsed) */\r
        while (!(Pipe_IsINReceived()))\r
        {\r
                /* Check to see if a new frame has been issued (1ms elapsed) */\r
-               if (FrameElapsed)\r
+               if (USB_INT_HasOccurred(USB_INT_HSOFI))\r
                {\r
                        /* Clear the flag and decrement the timeout period counter */\r
                {\r
                        /* Clear the flag and decrement the timeout period counter */\r
-                       FrameElapsed = false;\r
+                       USB_INT_Clear(USB_INT_HSOFI);\r
                        TimeoutMSRem--;\r
 \r
                        /* Check to see if the timeout period for the command has elapsed */\r
                        TimeoutMSRem--;\r
 \r
                        /* Check to see if the timeout period for the command has elapsed */\r
@@ -130,24 +126,28 @@ static uint8_t MassStore_WaitForDataReceived(void)
                          return PIPE_RWSTREAM_Timeout;\r
                }\r
        \r
                          return PIPE_RWSTREAM_Timeout;\r
                }\r
        \r
+               Pipe_Freeze();\r
                Pipe_SelectPipe(MASS_STORE_DATA_OUT_PIPE);\r
                Pipe_SelectPipe(MASS_STORE_DATA_OUT_PIPE);\r
+               Pipe_Unfreeze();\r
 \r
                /* Check if pipe stalled (command failed by device) */\r
                if (Pipe_IsStalled())\r
                {\r
                        /* Clear the stall condition on the OUT pipe */\r
 \r
                /* Check if pipe stalled (command failed by device) */\r
                if (Pipe_IsStalled())\r
                {\r
                        /* Clear the stall condition on the OUT pipe */\r
-                       MassStore_ClearPipeStall(MASS_STORE_DATA_OUT_PIPE);\r
+                       USB_Host_ClearPipeStall(MASS_STORE_DATA_OUT_PIPE);\r
 \r
                        return PIPE_RWSTREAM_PipeStalled;\r
                }\r
 \r
                        return PIPE_RWSTREAM_PipeStalled;\r
                }\r
-\r
+               \r
+               Pipe_Freeze();\r
                Pipe_SelectPipe(MASS_STORE_DATA_IN_PIPE);\r
                Pipe_SelectPipe(MASS_STORE_DATA_IN_PIPE);\r
+               Pipe_Unfreeze();\r
 \r
                /* Check if pipe stalled (command failed by device) */\r
                if (Pipe_IsStalled())\r
                {\r
                        /* Clear the stall condition on the IN pipe */\r
 \r
                /* Check if pipe stalled (command failed by device) */\r
                if (Pipe_IsStalled())\r
                {\r
                        /* Clear the stall condition on the IN pipe */\r
-                       MassStore_ClearPipeStall(MASS_STORE_DATA_IN_PIPE);\r
+                       USB_Host_ClearPipeStall(MASS_STORE_DATA_IN_PIPE);\r
 \r
                        return PIPE_RWSTREAM_PipeStalled;\r
                }\r
 \r
                        return PIPE_RWSTREAM_PipeStalled;\r
                }\r
@@ -156,6 +156,12 @@ static uint8_t MassStore_WaitForDataReceived(void)
                if (!(USB_IsConnected))\r
                  return PIPE_RWSTREAM_DeviceDisconnected;\r
        };\r
                if (!(USB_IsConnected))\r
                  return PIPE_RWSTREAM_DeviceDisconnected;\r
        };\r
+       \r
+       Pipe_SelectPipe(MASS_STORE_DATA_IN_PIPE);\r
+       Pipe_Freeze();\r
+               \r
+       Pipe_SelectPipe(MASS_STORE_DATA_OUT_PIPE);\r
+       Pipe_Freeze();\r
 \r
        return PIPE_RWSTREAM_NoError;\r
 }\r
 \r
        return PIPE_RWSTREAM_NoError;\r
 }\r