Skip to content

Commit d1b367f

Browse files
authored
Merge pull request #9483 from mprse/ticker_sleep_lock_fix
Fix for Issue #7308 (Deep_sleep_lock Ticker.h Issue)
2 parents e965aa6 + af02b23 commit d1b367f

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

drivers/Ticker.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,16 @@ void Ticker::handler()
5353
}
5454
}
5555

56+
void Ticker::attach_us(Callback<void()> func, us_timestamp_t t)
57+
{
58+
core_util_critical_section_enter();
59+
// lock only for the initial callback setup and this is not low power ticker
60+
if (!_function && _lock_deepsleep) {
61+
sleep_manager_lock_deep_sleep();
62+
}
63+
_function = func;
64+
setup(t);
65+
core_util_critical_section_exit();
66+
}
67+
5668
} // namespace mbed

drivers/Ticker.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,7 @@ class Ticker : public TimerEvent, private NonCopyable<Ticker> {
117117
* for threads scheduling.
118118
*
119119
*/
120-
void attach_us(Callback<void()> func, us_timestamp_t t)
121-
{
122-
core_util_critical_section_enter();
123-
// lock only for the initial callback setup and this is not low power ticker
124-
if (!_function && _lock_deepsleep) {
125-
sleep_manager_lock_deep_sleep();
126-
}
127-
_function = func;
128-
setup(t);
129-
core_util_critical_section_exit();
130-
}
120+
void attach_us(Callback<void()> func, us_timestamp_t t);
131121

132122
/** Attach a member function to be called by the Ticker, specifying the interval in microseconds
133123
*

0 commit comments

Comments
 (0)