mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #169 from oliviermartin/om/usb-device-connect-non-blocking
Allow USBDevice::connect() to be non-blockingpull/173/head
commit
3c8f1c0c59
|
@ -703,12 +703,15 @@ bool USBDevice::configured(void)
|
|||
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)
|
||||
|
|
|
@ -37,8 +37,10 @@ public:
|
|||
|
||||
/*
|
||||
* Connect a device
|
||||
*
|
||||
* @param blocking: block if not configured
|
||||
*/
|
||||
void connect(void);
|
||||
void connect(bool blocking = true);
|
||||
|
||||
/*
|
||||
* Disconnect a device
|
||||
|
|
|
@ -103,8 +103,7 @@ bool USBMSD::USBCallback_request(void) {
|
|||
}
|
||||
|
||||
|
||||
bool USBMSD::connect() {
|
||||
|
||||
bool USBMSD::connect(bool blocking) {
|
||||
//disk initialization
|
||||
if (disk_status() & NO_INIT) {
|
||||
if (disk_initialize()) {
|
||||
|
@ -131,7 +130,7 @@ bool USBMSD::connect() {
|
|||
}
|
||||
|
||||
//connect the device
|
||||
USBDevice::connect();
|
||||
USBDevice::connect(blocking);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,9 +70,10 @@ public:
|
|||
/**
|
||||
* 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.
|
||||
|
|
Loading…
Reference in New Issue