mirror of https://github.com/ARMmbed/mbed-os.git
Allow USBDevice::connect() to be non-blocking.
It is required if USB is not the primary use of the device (eg: use of USB mass storage to transfer pictures from the camera (the device) to the host once in a while).pull/169/head
parent
b87dac9fce
commit
f19f0b27c1
|
|
@ -703,13 +703,16 @@ bool USBDevice::configured(void)
|
||||||
return (device.state == CONFIGURED);
|
return (device.state == CONFIGURED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void USBDevice::connect(void)
|
void USBDevice::connect(bool blocking)
|
||||||
{
|
{
|
||||||
/* Connect device */
|
/* Connect device */
|
||||||
USBHAL::connect();
|
USBHAL::connect();
|
||||||
|
|
||||||
|
if (blocking) {
|
||||||
/* Block if not configured */
|
/* Block if not configured */
|
||||||
while (!configured());
|
while (!configured());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void USBDevice::disconnect(void)
|
void USBDevice::disconnect(void)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,10 @@ public:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Connect a device
|
* Connect a device
|
||||||
|
*
|
||||||
|
* @param blocking: block if not configured
|
||||||
*/
|
*/
|
||||||
void connect(void);
|
void connect(bool blocking = true);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Disconnect a device
|
* Disconnect a device
|
||||||
|
|
|
||||||
|
|
@ -103,8 +103,7 @@ bool USBMSD::USBCallback_request(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool USBMSD::connect() {
|
bool USBMSD::connect(bool blocking) {
|
||||||
|
|
||||||
//disk initialization
|
//disk initialization
|
||||||
if (disk_status() & NO_INIT) {
|
if (disk_status() & NO_INIT) {
|
||||||
if (disk_initialize()) {
|
if (disk_initialize()) {
|
||||||
|
|
@ -131,7 +130,7 @@ bool USBMSD::connect() {
|
||||||
}
|
}
|
||||||
|
|
||||||
//connect the device
|
//connect the device
|
||||||
USBDevice::connect();
|
USBDevice::connect(blocking);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,9 +70,10 @@ public:
|
||||||
/**
|
/**
|
||||||
* Connect the USB MSD device. Establish disk initialization before really connect the device.
|
* Connect the USB MSD device. Establish disk initialization before really connect the device.
|
||||||
*
|
*
|
||||||
|
* @param blocking if not configured
|
||||||
* @returns true if successful
|
* @returns true if successful
|
||||||
*/
|
*/
|
||||||
bool connect();
|
bool connect(bool blocking = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnect the USB MSD device.
|
* Disconnect the USB MSD device.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue