From f766f7d42105e19b2a6b427cf1d6a582c41a950b Mon Sep 17 00:00:00 2001 From: Russ Butler Date: Wed, 13 Sep 2017 20:05:40 -0500 Subject: [PATCH] Release deep sleep lock in destructor of Timer class Release the deep sleep lock when running instances of the Timer class are deleted. This ensures that deep sleep locks are properly released by the Timer class. --- drivers/Timer.cpp | 9 +++++++++ drivers/Timer.h | 1 + 2 files changed, 10 insertions(+) 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 */