Fixing issues with library dependencies

Dependencies:   FATFileSystem mbed-rtos

Fork of USBHost by mbed official

Revision:
4:b320d68e98e7
Parent:
0:a554658735bf
Child:
8:93da8ea2708b
diff -r 0f5c32575eb8 -r b320d68e98e7 USBHost/USBDeviceConnected.cpp
--- a/USBHost/USBDeviceConnected.cpp	Wed Mar 06 17:50:07 2013 +0000
+++ b/USBHost/USBDeviceConnected.cpp	Tue Mar 12 17:23:37 2013 +0000
@@ -36,23 +36,27 @@
     device_subclass = 0;
     proto = 0;
     speed = false;
-    strcpy(name, "Unknown");
     for (int i = 0; i < MAX_INTF; i++) {
         memset((void *)&intf[i], 0, sizeof(INTERFACE));
         intf[i].in_use = false;
         for (int j = 0; j < MAX_ENDPOINT_PER_INTERFACE; j++) {
             intf[i].ep[j] = NULL;
+            strcpy(intf[i].name, "Unknown");
         }
     }
     hub_parent = NULL;
     hub = NULL;
+    nb_interf = 0;
 }
 
 INTERFACE * USBDeviceConnected::getInterface(uint8_t index) {
-    if (index >= MAX_INTF) {
+    if (index >= MAX_INTF)
         return NULL;
-    }
-    return &intf[index];
+    
+    if (intf[index].in_use)
+        return &intf[index];
+    
+    return NULL;
 }
 
 bool USBDeviceConnected::addInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol) {
@@ -64,7 +68,6 @@
     intf[intf_nb].intf_subclass = intf_subclass;
     intf[intf_nb].intf_protocol = intf_protocol;
     intf[intf_nb].nb_endpoint = 0;
-    nb_interf++;
     return true;
 }
 
@@ -92,7 +95,7 @@
 }
 
 void USBDeviceConnected::disconnect() {
-    for(int i = 0; i < nb_interf; i++) {
+    for(int i = 0; i < MAX_INTF; i++) {
         intf[i].detach.call();
     }
     init();
@@ -121,4 +124,3 @@
     }
     return intf[intf_nb].ep[index];
 }
-