Skip to content

Commit

Permalink
Merge pull request #9483 from mprse/ticker_sleep_lock_fix
Browse files Browse the repository at this point in the history
Fix for Issue #7308 (Deep_sleep_lock Ticker.h Issue)
  • Loading branch information
0xc0170 committed Jan 29, 2019
2 parents e965aa6 + af02b23 commit d1b367f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
12 changes: 12 additions & 0 deletions drivers/Ticker.cpp
Expand Up @@ -53,4 +53,16 @@ void Ticker::handler()
}
}

void Ticker::attach_us(Callback<void()> func, us_timestamp_t t)
{
core_util_critical_section_enter();
// lock only for the initial callback setup and this is not low power ticker
if (!_function && _lock_deepsleep) {
sleep_manager_lock_deep_sleep();
}
_function = func;
setup(t);
core_util_critical_section_exit();
}

} // namespace mbed
12 changes: 1 addition & 11 deletions drivers/Ticker.h
Expand Up @@ -117,17 +117,7 @@ class Ticker : public TimerEvent, private NonCopyable<Ticker> {
* for threads scheduling.
*
*/
void attach_us(Callback<void()> func, us_timestamp_t t)
{
core_util_critical_section_enter();
// lock only for the initial callback setup and this is not low power ticker
if (!_function && _lock_deepsleep) {
sleep_manager_lock_deep_sleep();
}
_function = func;
setup(t);
core_util_critical_section_exit();
}
void attach_us(Callback<void()> func, us_timestamp_t t);

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

0 comments on commit d1b367f

Please sign in to comment.