Skip to content

Commit f766f7d

Browse files
committed
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.
1 parent 7b42891 commit f766f7d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

drivers/Timer.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ Timer::Timer(const ticker_data_t *data) : _running(), _start(), _time(), _ticker
2828
reset();
2929
}
3030

31+
Timer::~Timer() {
32+
core_util_critical_section_enter();
33+
if (_running) {
34+
sleep_manager_unlock_deep_sleep();
35+
}
36+
_running = 0;
37+
core_util_critical_section_exit();
38+
}
39+
3140
void Timer::start() {
3241
core_util_critical_section_enter();
3342
if (!_running) {

drivers/Timer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class Timer : private NonCopyable<Timer> {
5353
public:
5454
Timer();
5555
Timer(const ticker_data_t *data);
56+
~Timer();
5657

5758
/** Start the timer
5859
*/

0 commit comments

Comments
 (0)