X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/31d8ebebc0796873f7c70db80a04acdcbb307ed8..09575f9607e12ddf7284f6c8974a332a88d4ed3b:/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.c diff --git a/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.c b/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.c index 27662db75..d22e07400 100644 --- a/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.c +++ b/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.c @@ -71,9 +71,8 @@ int main(void) uint16_t ConfigDescriptorSize; uint8_t ConfigDescriptorData[512]; - if ((USB_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, NULL) != HOST_SENDCONTROL_Successful) || - (ConfigDescriptorSize > sizeof(ConfigDescriptorData)) || - (USB_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData))) + if (USB_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData, + sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful) { printf("Error Retrieving Configuration Descriptor.\r\n"); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); @@ -84,7 +83,7 @@ int main(void) if (MS_Host_ConfigurePipes(&FlashDisk_MS_Interface, ConfigDescriptorSize, ConfigDescriptorData) != MS_ENUMERROR_NoError) { - printf("Attached Device Not a Valid Mouse.\r\n"); + printf("Attached Device Not a Valid Mass Storage Device.\r\n"); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; @@ -98,7 +97,7 @@ int main(void) break; } - printf("Mouse Enumerated.\r\n"); + printf("Mass Storage Device Enumerated.\r\n"); USB_HostState = HOST_STATE_Configured; break; case HOST_STATE_Configured: @@ -113,6 +112,8 @@ int main(void) break; } + printf("Total LUNs: %d - Using first LUN in device.\r\n", (MaxLUNIndex + 1)); + if (MS_Host_ResetMSInterface(&FlashDisk_MS_Interface)) { printf("Error resetting Mass Storage interface.\r\n"); @@ -139,7 +140,7 @@ int main(void) } SCSI_Inquiry_Response_t InquiryData; - if (MS_Host_GetInquiryData(&FlashDisk_MS_Interface, &InquiryData)) + if (MS_Host_GetInquiryData(&FlashDisk_MS_Interface, 0, &InquiryData)) { printf("Error retreiving device Inquiry data.\r\n"); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); @@ -150,11 +151,16 @@ int main(void) printf("Vendor \"%.8s\", Product \"%.16s\"\r\n", InquiryData.VendorID, InquiryData.ProductID); printf("Waiting until ready...\r\n"); - bool DeviceReady; - do + for (;;) { - if (MS_Host_TestUnitReady(&FlashDisk_MS_Interface, 0, &DeviceReady)) + uint8_t ErrorCode = MS_Host_TestUnitReady(&FlashDisk_MS_Interface, 0); + + if (!(ErrorCode)) + break; + + /* Check if an error other than a logical command error (device busy) received */ + if (ErrorCode != MS_ERROR_LOGICAL_CMD_FAILED) { printf("Error waiting for device to be ready.\r\n"); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); @@ -162,7 +168,6 @@ int main(void) break; } } - while (!(DeviceReady)); printf("Retrieving Capacity... ");