mbed library sources. Supersedes mbed-src.
Dependents: Hobbyking_Cheetah_Compact Hobbyking_Cheetah_Compact_DRV8323_14bit Hobbyking_Cheetah_Compact_DRV8323_V51_201907 HKC_MiniCheetah ... more
Fork of mbed-dev by
Diff: drivers/Ticker.h
- Revision:
- 174:b96e65c34a4d
- Parent:
- 168:9672193075cf
- Child:
- 175:af195413fb11
--- a/drivers/Ticker.h Fri Sep 15 14:59:18 2017 +0100 +++ b/drivers/Ticker.h Mon Oct 02 15:33:19 2017 +0100 @@ -20,6 +20,7 @@ #include "platform/Callback.h" #include "platform/mbed_toolchain.h" #include "platform/NonCopyable.h" +#include "platform/mbed_sleep.h" namespace mbed { /** \addtogroup drivers */ @@ -63,10 +64,10 @@ class Ticker : public TimerEvent, private NonCopyable<Ticker> { public: - Ticker() : TimerEvent() { + Ticker() : TimerEvent(), _function(0) { } - Ticker(const ticker_data_t *data) : TimerEvent(data) { + Ticker(const ticker_data_t *data) : TimerEvent(data), _function(0) { data->interface->init(); } @@ -102,6 +103,10 @@ * @param t the time between calls in micro-seconds */ void attach_us(Callback<void()> func, us_timestamp_t t) { + // lock only for the initial callback setup + if (!_function) { + sleep_manager_lock_deep_sleep(); + } _function = func; setup(t); }