diff --git a/drivers/Timer.cpp b/drivers/Timer.cpp index 12f9737ca4..8e3c406ba9 100644 --- a/drivers/Timer.cpp +++ b/drivers/Timer.cpp @@ -28,6 +28,15 @@ Timer::Timer(const ticker_data_t *data) : _running(), _start(), _time(), _ticker reset(); } +Timer::~Timer() { + core_util_critical_section_enter(); + if (_running) { + sleep_manager_unlock_deep_sleep(); + } + _running = 0; + core_util_critical_section_exit(); +} + void Timer::start() { core_util_critical_section_enter(); if (!_running) { diff --git a/drivers/Timer.h b/drivers/Timer.h index e353720b96..848f8087c3 100644 --- a/drivers/Timer.h +++ b/drivers/Timer.h @@ -53,6 +53,7 @@ class Timer : private NonCopyable { public: Timer(); Timer(const ticker_data_t *data); + ~Timer(); /** Start the timer */