mirror of https://github.com/ARMmbed/mbed-os.git
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
parent
ced82dd16b
commit
11e2ba1f92
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue