BaseUsbHost example program

Dependencies:   BaseUsbHost FATFileSystem mbed mbed-rtos

Revision:
1:80205a2de336
Parent:
0:2a9734a95d55
--- a/example1_UsbFlashDrive.cpp	Tue Dec 04 13:39:57 2012 +0000
+++ b/example1_UsbFlashDrive.cpp	Wed Dec 05 13:25:18 2012 +0000
@@ -26,25 +26,39 @@
     TEST_ASSERT_TRUE(hub);
 
     for(int i = 0; i < MAX_HUB_PORT; i++) {
-        if (hub->PortEp[i]) {
-            if (hub->PortEp[i]->DeviceClass == 0x01) {  
-                ctlEp = hub->PortEp[i];
-                break;
-            }
+        if (UsbFlashDrive::check(hub->PortEp[i])) {
+            ctlEp = hub->PortEp[i];
+            break;
         }
     }
+    if (ctlEp == NULL) {
+        error("USB Flash Drive not found\n");
+    }
+    TEST_ASSERT(ctlEp);
 
     drive = new UsbFlashDrive("usb", ctlEp);
     TEST_ASSERT(drive);
 
-
-    const int file_size = 1024*256;
-    printf("USB FLASH DRIVE read/write file size: %d bytes\n", file_size);
+    const int size_table[] = {
+        1024*1,
+        1024*2,
+        1024*4,
+        1024*8,
+        1024*16,
+        1024*32,
+        1024*64,
+        1024*128,
+        1204*256,
+        1204*512,
+    };
+    
+    printf("USB FLASH DRIVE read/write test\n");
     
     char path[32];
     int size;
     Timer t;
     for(int n = 0; n <= 9; n++) {
+        int file_size = size_table[n];
         sprintf(path, "/usb/test%d.txt", n);
         FILE* fp = fopen(path, "wb");
         size = 0;