mirror of https://github.com/ARMmbed/mbed-os.git
Properly unlock sleep in destructor of drivers
Unlock sleep in CAN and SerialBase. This prevents deep sleep from staying locked if these objects are destroyed without first clearing the callbacks.pull/5220/head
parent
87b151c8a0
commit
f854f3e6db
|
@ -46,6 +46,11 @@ CAN::CAN(PinName rd, PinName td, int hz) : _can(), _irq() {
|
|||
|
||||
CAN::~CAN() {
|
||||
// No lock needed in destructor
|
||||
|
||||
// Detaching interrupts releases the sleep lock if it was locked
|
||||
for (int irq = 0; irq < IrqCnt; irq++) {
|
||||
attach(NULL, (IrqType)irq);
|
||||
}
|
||||
can_irq_free(&_can);
|
||||
can_free(&_can);
|
||||
}
|
||||
|
|
|
@ -133,6 +133,16 @@ void SerialBase:: unlock() {
|
|||
// Stub
|
||||
}
|
||||
|
||||
SerialBase::~SerialBase()
|
||||
{
|
||||
// No lock needed in destructor
|
||||
|
||||
// Detaching interrupts releases the sleep lock if it was locked
|
||||
for (int irq = 0; irq < IrqCnt; irq++) {
|
||||
attach(NULL, (IrqType)irq);
|
||||
}
|
||||
}
|
||||
|
||||
#if DEVICE_SERIAL_FC
|
||||
void SerialBase::set_flow_control(Flow type, PinName flow1, PinName flow2) {
|
||||
lock();
|
||||
|
|
|
@ -241,8 +241,7 @@ protected:
|
|||
|
||||
protected:
|
||||
SerialBase(PinName tx, PinName rx, int baud);
|
||||
virtual ~SerialBase() {
|
||||
}
|
||||
virtual ~SerialBase();
|
||||
|
||||
int _base_getc();
|
||||
int _base_putc(int c);
|
||||
|
|
Loading…
Reference in New Issue