test
Fork of mbed-dev by
Diff: drivers/Ticker.h
- Revision:
- 175:b96e65c34a4d
- Parent:
- 169:9672193075cf
- Child:
- 176:af195413fb11
diff -r e131a1973e81 -r b96e65c34a4d drivers/Ticker.h --- 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); }