The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
Diff: drivers/Ticker.h
- Revision:
- 152:235179ab3f27
- Parent:
- 146:22da6e220af6
- Child:
- 153:b484a57bc302
--- a/drivers/Ticker.h Fri Sep 15 14:46:57 2017 +0100 +++ b/drivers/Ticker.h Mon Oct 02 15:20:36 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); }