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
33using OsTimer = SysTimer<std::ratio<1, OS_TICK_FREQ>>;
35using OsTimer = SysTimer<std::milli>;
41extern OsTimer *os_timer;
42OsTimer *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()
101 static time_point now_with_init_done()
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>;
115OsClock::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
120OsClock::duration_u32 do_timed_sleep_relative_to_acknowledged_ticks(OsClock::duration_u32 wake_delay,
bool (*wake_predicate)(
void *) = NULL,
void *wake_predicate_handle = NULL);
123void do_untimed_sleep(
bool (*wake_predicate)(
void *),
void *wake_predicate_handle = NULL);
127void do_timed_sleep_relative_or_forever(OsClock::duration_u32 wake_delay,
bool (*wake_predicate)(
void *) = NULL,
void *wake_predicate_handle = NULL);
void set_wake_time(time_point at)
Set the wake time.
time_point get_tick() const
Get the current tick count.
std::chrono::duration< int, period > unacknowledged_ticks() const
Check unacknowledged ticks.
time_point update_and_get_tick()
Update and get the current tick count.
A C++11 chrono TrivialClock for os_timer.