Added MS_Host_TestUnitReady() and MS_Host_ReadDeviceCapacity() to the host mode Mass...
[pub/USBasp.git] / Demos / Host / ClassDriver / MassStorageHost / MassStorageHost.c
index d9fe47d..57aba45 100644 (file)
@@ -150,11 +150,16 @@ int main(void)
                                printf("Vendor \"%.8s\", Product \"%.16s\"\r\n", InquiryData.VendorID, InquiryData.ProductID);\r
                                \r
                                printf("Waiting until ready...\r\n");\r
-                               bool DeviceReady;\r
 \r
-                               do\r
+                               for (;;)\r
                                {\r
-                                       if (MS_Host_TestUnitReady(&FlashDisk_MS_Interface, 0, &DeviceReady))\r
+                                       uint8_t ErrorCode = MS_Host_TestUnitReady(&FlashDisk_MS_Interface, 0);\r
+                                       \r
+                                       if (!(ErrorCode))\r
+                                         break;\r
+\r
+                                       /* Check if an error other than a logical command error (device busy) received */\r
+                                       if (ErrorCode != MS_ERROR_LOGICAL_CMD_FAILED)\r
                                        {\r
                                                printf("Error waiting for device to be ready.\r\n");\r
                                                LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
@@ -162,7 +167,6 @@ int main(void)
                                                break;\r
                                        }\r
                                }\r
-                               while (!(DeviceReady));\r
 \r
                                printf("Retrieving Capacity... ");\r
 \r