USB device stack

Fork of USBDevice by mbed official

Files at this revision

API Documentation at this revision

Comitter:
silicium
Date:
Mon Mar 31 20:41:48 2014 +0000
Parent:
14:d495202c90f4
Commit message:
commit

Changed in this revision

USBDevice/USBDevice.cpp Show annotated file Show diff for this revision Revisions of this file
USBDevice/USBDevice.h Show annotated file Show diff for this revision Revisions of this file
--- a/USBDevice/USBDevice.cpp	Thu Sep 12 14:45:27 2013 +0100
+++ b/USBDevice/USBDevice.cpp	Mon Mar 31 20:41:48 2014 +0000
@@ -711,6 +711,22 @@
     while (!configured());
 }
 
+bool USBDevice::connect(int timeout)
+{
+    /* Connect device */
+    USBHAL::connect();
+    /* Block if not configured */
+    while (!configured() && timeout>0)
+    {
+        wait_ms(100);
+        timeout -= 100;
+    }
+    if(!configured())
+        return false;
+    else
+        return true;
+}
+
 void USBDevice::disconnect(void)
 {
     /* Disconnect device */
--- a/USBDevice/USBDevice.h	Thu Sep 12 14:45:27 2013 +0100
+++ b/USBDevice/USBDevice.h	Mon Mar 31 20:41:48 2014 +0000
@@ -39,6 +39,7 @@
     * Connect a device
     */
     void connect(void);
+    bool connect(int timeout);
     
     /*
     * Disconnect a device