Add USBDevice destructor

Add a destructor to USBDevice to ensure that resources have been
properly released. Additionally add an assert in the destructor that
deinit has already been called. If it has not been called then
interrupts can still occur which may cause a crash.
pull/9768/head
Russ Butler 2018-05-01 15:05:17 -05:00
parent ced82dd16b
commit 11e2ba1f92
2 changed files with 14 additions and 0 deletions

View File

@ -1248,6 +1248,12 @@ USBDevice::USBDevice(USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint1
_device.suspended = false;
}
USBDevice::~USBDevice()
{
MBED_ASSERT(!_initialized);
deinit();
}
uint32_t USBDevice::endpoint_max_packet_size(usb_ep_t endpoint)
{
lock();

View File

@ -82,6 +82,14 @@ public:
*/
USBDevice(USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint16_t product_release);
/**
* Cleanup this USBDevice
*
* This USBDevice must be uninitialized when the destructor is
* called or the behavior is undefined.
*/
virtual ~USBDevice();
/**
* Initialize this instance
*