From 01d388f293ba531008122ebb4cfcf7113a228398 Mon Sep 17 00:00:00 2001
From: Dean Camera <dean@fourwalledcubicle.com>
Date: Sun, 5 Apr 2009 04:05:07 +0000
Subject: [PATCH] Add call to MassStore_WaitForDataReceived() in
 MassStore_GetReturnedStatus() to ensure that the CSW has been received in the
 extended MSC timeout period before continuing, to prevent long processing
 delays from causing the MassStore_GetReturnedStatus() to early-abort.

---
 Demos/Host/MassStorageHost/MassStoreCommands.c | 4 ++++
 LUFA/ChangeLog.txt                             | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/Demos/Host/MassStorageHost/MassStoreCommands.c b/Demos/Host/MassStorageHost/MassStoreCommands.c
index 700d969db..0d88acbd5 100644
--- a/Demos/Host/MassStorageHost/MassStoreCommands.c
+++ b/Demos/Host/MassStorageHost/MassStoreCommands.c
@@ -215,6 +215,10 @@ static uint8_t MassStore_GetReturnedStatus(void)
 {
 	uint8_t ErrorCode = PIPE_RWSTREAM_ERROR_NoError;
 
+	/* If an error in the command ocurred, abort */
+	if (MassStore_WaitForDataReceived() != NoError)
+	  return;
+
 	/* Select the IN data pipe for data reception */
 	Pipe_SelectPipe(MASS_STORE_DATA_IN_PIPE);
 	Pipe_Unfreeze();
diff --git a/LUFA/ChangeLog.txt b/LUFA/ChangeLog.txt
index 3622f66e9..cea1166b4 100644
--- a/LUFA/ChangeLog.txt
+++ b/LUFA/ChangeLog.txt
@@ -15,6 +15,8 @@
   *    time options
   *  - All comments in the library, bootloaders, demos and projects have now been spell-checked and spelling mistakes/typos corrected
   *  - Added new PIMA_DATA_SIZE() define to the Still Image Host demo
+  *  - Add call to MassStore_WaitForDataReceived() in MassStore_GetReturnedStatus() to ensure that the CSW has been received in the extended
+  *    MSC timeout period before continuing, to prevent long processing delays from causing the MassStore_GetReturnedStatus() to early-abort
   *
   *  \section Sec_ChangeLog090401 Version 090401
   *
-- 
GitLab