Timeout driver for event at absolute time

Dependents:   demo_TimeoutAbs i2c_lora_slave

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TimeoutAbs.cpp Source File

TimeoutAbs.cpp

00001 
00002 #include "TimeoutAbs.h"
00003 #include "drivers/TimerEvent.h"
00004 #include "platform/FunctionPointer.h"
00005 #include "hal/ticker_api.h"
00006 #include "platform/mbed_critical.h"
00007 
00008 namespace mbed {
00009 
00010 void TimeoutAbs::detach()
00011 {
00012     core_util_critical_section_enter();
00013     remove();
00014     // unlocked only if we were attached (we locked it) and this is not low power ticker
00015     if (_function && _lock_deepsleep) {
00016         sleep_manager_unlock_deep_sleep();
00017     }
00018     _function = 0;
00019     core_util_critical_section_exit();
00020 }
00021 
00022 void TimeoutAbs::abs_setup(us_timestamp_t t)
00023 {
00024     core_util_critical_section_enter();
00025     remove();
00026     insert_absolute(t);
00027     core_util_critical_section_exit();
00028 }
00029 
00030 void TimeoutAbs::handler()
00031 {
00032     Callback<void()> local = _function;
00033     detach();
00034     local.call();
00035 }
00036 
00037 } // namespace mbed