17 #ifndef MBED_MBED_SLEEP_TIMER_H 18 #define MBED_MBED_SLEEP_TIMER_H 21 #include "platform/internal/SysTimer.h" 23 #if MBED_CONF_RTOS_PRESENT 32 #if MBED_CONF_RTOS_PRESENT 33 using OsTimer = SysTimer<std::ratio<1, OS_TICK_FREQ>>;
35 using OsTimer = SysTimer<std::milli>;
41 extern OsTimer *os_timer;
42 OsTimer *init_os_timer();
73 using period = OsTimer::period;
74 using rep = std::chrono::milliseconds::rep;
75 using duration = std::chrono::duration<rep, period>;
76 using time_point = std::chrono::time_point<OsClock, duration>;
77 static constexpr
bool is_steady =
true;
81 static time_point now()
86 return time_point(init_os_timer()->update_and_get_tick().time_since_epoch());
91 static time_point reported_ticks()
93 return time_point(os_timer->get_tick().time_since_epoch());
96 static time_point acknowledged_ticks()
98 return reported_ticks() - os_timer->unacknowledged_ticks();
101 static time_point now_with_init_done()
103 return time_point(os_timer->update_and_get_tick().time_since_epoch());
105 static void set_wake_time(time_point wake_time)
107 return os_timer->set_wake_time(OsTimer::time_point(wake_time.time_since_epoch()));
111 using duration_u32 = std::chrono::duration<uint32_t, period>;
115 OsClock::time_point do_timed_sleep_absolute(OsClock::time_point wake_time,
bool (*wake_predicate)(
void *) = NULL,
void *wake_predicate_handle = NULL);
117 #if MBED_CONF_RTOS_PRESENT 120 OsClock::duration_u32 do_timed_sleep_relative_to_acknowledged_ticks(OsClock::duration_u32 wake_delay,
bool (*wake_predicate)(
void *) = NULL,
void *wake_predicate_handle = NULL);
123 void do_untimed_sleep(
bool (*wake_predicate)(
void *),
void *wake_predicate_handle = NULL);
127 void do_timed_sleep_relative_or_forever(OsClock::duration_u32 wake_delay,
bool (*wake_predicate)(
void *) = NULL,
void *wake_predicate_handle = NULL);
A C++11 chrono TrivialClock for os_timer.