USB device stack

Dependents:   mbed-mX-USB-TEST1 USBMSD_SD_HID_HelloWorld HidTest MIDI_usb_bridge ... more

Legacy Warning

This is an mbed 2 library. To learn more about mbed OS 5, visit the docs.

Pull requests against this repository are no longer supported. Please raise against mbed OS 5 as documented above.

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Tue Feb 18 11:00:19 2014 +0000
Parent:
17:bbd6dac92961
Child:
19:fcb63a105965
Commit message:
Synchronized with git revision 3c8f1c0c59bc1b665e9e1b1b3dc00e5fcdde6400

Full URL: https://github.com/mbedmicro/mbed/commit/3c8f1c0c59bc1b665e9e1b1b3dc00e5fcdde6400/

Allow USBDevice::connect() to be non-blocking

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
USBMSD/USBMSD.cpp Show annotated file Show diff for this revision Revisions of this file
USBMSD/USBMSD.h Show annotated file Show diff for this revision Revisions of this file
--- a/USBDevice/USBDevice.cpp	Thu Jan 23 17:30:20 2014 +0000
+++ b/USBDevice/USBDevice.cpp	Tue Feb 18 11:00:19 2014 +0000
@@ -703,12 +703,15 @@
     return (device.state == CONFIGURED);
 }
 
-void USBDevice::connect(void)
+void USBDevice::connect(bool blocking)
 {
     /* Connect device */
     USBHAL::connect();
-    /* Block if not configured */
-    while (!configured());
+    
+    if (blocking) {
+        /* Block if not configured */
+        while (!configured());
+    }
 }
 
 void USBDevice::disconnect(void)
--- a/USBDevice/USBDevice.h	Thu Jan 23 17:30:20 2014 +0000
+++ b/USBDevice/USBDevice.h	Tue Feb 18 11:00:19 2014 +0000
@@ -37,8 +37,10 @@
     
     /*
     * Connect a device
+    * 
+    * @param blocking: block if not configured
     */
-    void connect(void);
+    void connect(bool blocking = true);
     
     /*
     * Disconnect a device
--- a/USBMSD/USBMSD.cpp	Thu Jan 23 17:30:20 2014 +0000
+++ b/USBMSD/USBMSD.cpp	Tue Feb 18 11:00:19 2014 +0000
@@ -103,8 +103,7 @@
 }
 
 
-bool USBMSD::connect() {
-
+bool USBMSD::connect(bool blocking) {
     //disk initialization
     if (disk_status() & NO_INIT) {
         if (disk_initialize()) {
@@ -131,7 +130,7 @@
     }
 
     //connect the device
-    USBDevice::connect();
+    USBDevice::connect(blocking);
     return true;
 }
 
--- a/USBMSD/USBMSD.h	Thu Jan 23 17:30:20 2014 +0000
+++ b/USBMSD/USBMSD.h	Tue Feb 18 11:00:19 2014 +0000
@@ -70,9 +70,10 @@
     /**
     * Connect the USB MSD device. Establish disk initialization before really connect the device.
     *
+    * @param blocking if not configured
     * @returns true if successful
     */
-    bool connect();
+    bool connect(bool blocking = true);
 
     /**
     * Disconnect the USB MSD device.