From 9e4be5e49449b6eb65fb607459ff178de05ae840 Mon Sep 17 00:00:00 2001 From: Kyle Kearney Date: Mon, 13 Jul 2020 12:56:35 -0700 Subject: [PATCH] Call HAL free functions from C++ destructors Add missing calls to HAL free to the following drivers - AnalogIn - QSPI - SerialBase --- drivers/AnalogIn.h | 4 +++- drivers/QSPI.h | 3 +++ drivers/source/SerialBase.cpp | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/AnalogIn.h b/drivers/AnalogIn.h index 38c1fc130d..dd5d067a2f 100644 --- a/drivers/AnalogIn.h +++ b/drivers/AnalogIn.h @@ -151,7 +151,9 @@ public: virtual ~AnalogIn() { - // Do nothing + lock(); + analogin_free(&_adc); + unlock(); } protected: diff --git a/drivers/QSPI.h b/drivers/QSPI.h index 1ef8df2396..f98fb45ed5 100644 --- a/drivers/QSPI.h +++ b/drivers/QSPI.h @@ -117,6 +117,9 @@ public: virtual ~QSPI() { + lock(); + qspi_free(&_qspi); + unlock(); } /** Configure the data transmission format diff --git a/drivers/source/SerialBase.cpp b/drivers/source/SerialBase.cpp index b335f695fb..40bf7d0b61 100644 --- a/drivers/source/SerialBase.cpp +++ b/drivers/source/SerialBase.cpp @@ -287,6 +287,10 @@ SerialBase::~SerialBase() for (int irq = 0; irq < IrqCnt; irq++) { attach(nullptr, (IrqType)irq); } + + if (_rx_enabled || _tx_enabled) { + serial_free(&_serial); + } } #if DEVICE_SERIAL_FC