X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/f1199200e167a737a4676378da184387e543830c..189d0c7e669b6a3d07ed35c1eaa0bfc8cbc7a729:/Demos/Host/ClassDriver/MassStorageHost/Lib/MassStoreCommands.c diff --git a/Demos/Host/ClassDriver/MassStorageHost/Lib/MassStoreCommands.c b/Demos/Host/ClassDriver/MassStorageHost/Lib/MassStoreCommands.c index f47e9f5ed..75974732c 100644 --- a/Demos/Host/ClassDriver/MassStorageHost/Lib/MassStoreCommands.c +++ b/Demos/Host/ClassDriver/MassStorageHost/Lib/MassStoreCommands.c @@ -107,10 +107,6 @@ static uint8_t MassStore_WaitForDataReceived(void) { uint16_t TimeoutMSRem = COMMAND_DATA_TIMEOUT_MS; - /* Unfreeze the OUT pipe so that it can be checked */ - Pipe_SelectPipe(MASS_STORE_DATA_OUT_PIPE); - Pipe_Unfreeze(); - /* Select the IN data pipe for data reception */ Pipe_SelectPipe(MASS_STORE_DATA_IN_PIPE); Pipe_Unfreeze(); @@ -119,10 +115,10 @@ static uint8_t MassStore_WaitForDataReceived(void) while (!(Pipe_IsINReceived())) { /* Check to see if a new frame has been issued (1ms elapsed) */ - if (FrameElapsed) + if (USB_INT_HasOccurred(USB_INT_HSOFI)) { /* Clear the flag and decrement the timeout period counter */ - FrameElapsed = false; + USB_INT_Clear(USB_INT_HSOFI); TimeoutMSRem--; /* Check to see if the timeout period for the command has elapsed */ @@ -130,24 +126,28 @@ static uint8_t MassStore_WaitForDataReceived(void) return PIPE_RWSTREAM_Timeout; } + Pipe_Freeze(); Pipe_SelectPipe(MASS_STORE_DATA_OUT_PIPE); + Pipe_Unfreeze(); /* Check if pipe stalled (command failed by device) */ if (Pipe_IsStalled()) { /* Clear the stall condition on the OUT pipe */ - MassStore_ClearPipeStall(MASS_STORE_DATA_OUT_PIPE); + USB_Host_ClearPipeStall(MASS_STORE_DATA_OUT_PIPE); return PIPE_RWSTREAM_PipeStalled; } - + + Pipe_Freeze(); Pipe_SelectPipe(MASS_STORE_DATA_IN_PIPE); + Pipe_Unfreeze(); /* Check if pipe stalled (command failed by device) */ if (Pipe_IsStalled()) { /* Clear the stall condition on the IN pipe */ - MassStore_ClearPipeStall(MASS_STORE_DATA_IN_PIPE); + USB_Host_ClearPipeStall(MASS_STORE_DATA_IN_PIPE); return PIPE_RWSTREAM_PipeStalled; } @@ -156,6 +156,12 @@ static uint8_t MassStore_WaitForDataReceived(void) if (!(USB_IsConnected)) return PIPE_RWSTREAM_DeviceDisconnected; }; + + Pipe_SelectPipe(MASS_STORE_DATA_IN_PIPE); + Pipe_Freeze(); + + Pipe_SelectPipe(MASS_STORE_DATA_OUT_PIPE); + Pipe_Freeze(); return PIPE_RWSTREAM_NoError; }