X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/ac70ddd0a1c412bb54def48e53caaebd0b5c9c61..d475ea4394ba0e16f89300ebeb452cea7c2d9232:/Demos/Host/LowLevel/MassStorageHost/Lib/MassStoreCommands.c diff --git a/Demos/Host/LowLevel/MassStorageHost/Lib/MassStoreCommands.c b/Demos/Host/LowLevel/MassStorageHost/Lib/MassStoreCommands.c index 95aafca8c..c524b5387 100644 --- a/Demos/Host/LowLevel/MassStorageHost/Lib/MassStoreCommands.c +++ b/Demos/Host/LowLevel/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(); @@ -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; } @@ -237,29 +243,6 @@ static uint8_t MassStore_GetReturnedStatus(void) return PIPE_RWSTREAM_NoError; } -/** Clears the stall condition in the attached device on the nominated endpoint number. - * - * \param EndpointNum Endpoint number in the attached device whose stall condition is to be cleared - * - * \return A value from the USB_Host_SendControlErrorCodes_t enum - */ -uint8_t MassStore_ClearPipeStall(const uint8_t EndpointNum) -{ - USB_ControlRequest = (USB_Request_Header_t) - { - .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT), - .bRequest = REQ_ClearFeature, - .wValue = FEATURE_ENDPOINT_HALT, - .wIndex = EndpointNum, - .wLength = 0, - }; - - /* Select the control pipe for the request transfer */ - Pipe_SelectPipe(PIPE_CONTROLPIPE); - - return USB_Host_SendControlRequest(NULL); -} - /** Issues a Mass Storage class specific request to reset the attached device's Mass Storage interface, * readying the device for the next CBW. *