Skip to content

Commit 67e6052

Browse files
authored
Merge pull request #13318 from kyle-cypress/pr/destructors-free
Call HAL free functions from C++ destructors
2 parents f7ffd63 + 9e4be5e commit 67e6052

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

drivers/AnalogIn.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ class AnalogIn {
151151

152152
virtual ~AnalogIn()
153153
{
154-
// Do nothing
154+
lock();
155+
analogin_free(&_adc);
156+
unlock();
155157
}
156158

157159
protected:

drivers/QSPI.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ class QSPI : private NonCopyable<QSPI> {
117117

118118
virtual ~QSPI()
119119
{
120+
lock();
121+
qspi_free(&_qspi);
122+
unlock();
120123
}
121124

122125
/** Configure the data transmission format

drivers/source/SerialBase.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,10 @@ SerialBase::~SerialBase()
287287
for (int irq = 0; irq < IrqCnt; irq++) {
288288
attach(nullptr, (IrqType)irq);
289289
}
290+
291+
if (_rx_enabled || _tx_enabled) {
292+
serial_free(&_serial);
293+
}
290294
}
291295

292296
#if DEVICE_SERIAL_FC

0 commit comments

Comments
 (0)