17#ifndef MBED_SYS_TIMER_H
18#define MBED_SYS_TIMER_H
20#include "platform/NonCopyable.h"
21#include "platform/mbed_atomic.h"
22#include "drivers/TimerEvent.h"
27#if defined(TARGET_CORTEX_A)
49template <
class Period,
bool IRQ = true>
55 using period = Period;
56 using duration = std::chrono::duration<uint64_t, period>;
57 using time_point = std::chrono::time_point<SysTimer>;
58 static const bool is_steady =
false;
67 static_assert(std::ratio_divide<period, highres_period>::den == 1,
"Tick period must be an exact multiple of highres time period");
88 static IRQn_ID_t get_irq_number();
95 static IRQn_Type get_irq_number();
130 return core_util_atomic_load_bool(&_wake_time_passed);
140 return core_util_atomic_load_bool(&_wake_time_set);
184 return core_util_atomic_load_bool(&_ticking);
200 return std::chrono::duration<int, period>(core_util_atomic_load_u32(&_unacknowledged_ticks));
247 using highres_duration_u32 = std::chrono::duration<uint32_t, highres_period>;
248 void handler()
override;
249 void _increment_tick();
250 void _schedule_tick();
251 duration _elapsed_ticks()
const;
252 static void _set_irq_pending();
253 static void _clear_irq_pending();
257 uint32_t _unacknowledged_ticks;
259 bool _wake_time_passed;
262 bool _deep_sleep_locked;
Prevents generation of copy constructor and copy assignment operator in derived classes.
Base abstraction for timer interrupts.
The SysTimer class is used to provide timing for system suspension, and the idle loop in TICKLESS mod...
bool wake_time_set() const
Check whether wake timer is active.
bool wake_time_passed() const
Check whether the wake time has passed.
SysTimer()
Default constructor uses LPTICKER if available (so the timer will continue to run in deep sleep),...
void acknowledge_tick()
Acknowledge an os tick.
void set_wake_time(time_point at)
Set the wake time.
highres_duration get_time_since_tick() const
Returns time since last tick.
bool ticking() const
Check whether ticker is active.
highres_time_point get_time() const
Get the time.
time_point get_tick() const
Get the current tick count.
std::chrono::duration< int, period > unacknowledged_ticks() const
Check unacknowledged ticks.
void cancel_tick()
Prevent any more scheduled ticks from triggering.
TickerDataClock::duration highres_duration
duration type used for underlying high-res timer
void cancel_wake()
Cancel any pending wake.
time_point update_and_get_tick()
Update and get the current tick count.
TickerDataClock::period highres_period
period of underlying high-res timer
TickerDataClock::time_point highres_time_point
time_point type used for underlying high-res timer
void start_tick()
Schedule an os tick to fire.