mirror of https://github.com/ARMmbed/mbed-os.git
Call disconnect when uninitializing USB
Disconnect USB when uninitializing USB so it is in a well defined state.pull/9768/head
parent
12231917ef
commit
4c398a308f
|
@ -958,6 +958,7 @@ void USBDevice::deinit()
|
||||||
lock();
|
lock();
|
||||||
|
|
||||||
if (_initialized) {
|
if (_initialized) {
|
||||||
|
disconnect();
|
||||||
this->_phy->deinit();
|
this->_phy->deinit();
|
||||||
_initialized = false;
|
_initialized = false;
|
||||||
}
|
}
|
||||||
|
@ -980,7 +981,10 @@ void USBDevice::connect(bool blocking)
|
||||||
{
|
{
|
||||||
/* Connect device */
|
/* Connect device */
|
||||||
lock();
|
lock();
|
||||||
_phy->connect();
|
if (!_connected) {
|
||||||
|
_phy->connect();
|
||||||
|
_connected = true;
|
||||||
|
}
|
||||||
unlock();
|
unlock();
|
||||||
|
|
||||||
if (blocking) {
|
if (blocking) {
|
||||||
|
@ -994,7 +998,10 @@ void USBDevice::disconnect()
|
||||||
lock();
|
lock();
|
||||||
|
|
||||||
/* Disconnect device */
|
/* Disconnect device */
|
||||||
_phy->disconnect();
|
if (_connected) {
|
||||||
|
_phy->disconnect();
|
||||||
|
_connected = false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Set initial device state */
|
/* Set initial device state */
|
||||||
if (_device.state > Powered) {
|
if (_device.state > Powered) {
|
||||||
|
@ -1199,6 +1206,7 @@ USBDevice::USBDevice(USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint1
|
||||||
|
|
||||||
_phy = phy;
|
_phy = phy;
|
||||||
_initialized = false;
|
_initialized = false;
|
||||||
|
_connected = false;
|
||||||
_current_interface = 0;
|
_current_interface = 0;
|
||||||
_current_alternate = 0;
|
_current_alternate = 0;
|
||||||
_locked = 0;
|
_locked = 0;
|
||||||
|
@ -1225,6 +1233,7 @@ USBDevice::USBDevice(uint16_t vendor_id, uint16_t product_id, uint16_t product_r
|
||||||
|
|
||||||
_phy = get_usb_phy();
|
_phy = get_usb_phy();
|
||||||
_initialized = false;
|
_initialized = false;
|
||||||
|
_connected = false;
|
||||||
_current_interface = 0;
|
_current_interface = 0;
|
||||||
_current_alternate = 0;
|
_current_alternate = 0;
|
||||||
_locked = 0;
|
_locked = 0;
|
||||||
|
|
|
@ -571,6 +571,7 @@ private:
|
||||||
|
|
||||||
USBPhy *_phy;
|
USBPhy *_phy;
|
||||||
bool _initialized;
|
bool _initialized;
|
||||||
|
bool _connected;
|
||||||
control_transfer_t _transfer;
|
control_transfer_t _transfer;
|
||||||
usb_device_t _device;
|
usb_device_t _device;
|
||||||
uint32_t _max_packet_size_ep0;
|
uint32_t _max_packet_size_ep0;
|
||||||
|
|
Loading…
Reference in New Issue