The SysTimer class is used to provide timing for system suspension, and the idle loop in TICKLESS mode. More...
Public Member Functions
|Default constructor uses LPTICKER if available (so the timer will continue to run in deep sleep), else USTICKER. More...|
|void||set_wake_time (uint64_t at)|
|Get the interrupt number for the tick. More...|
|bool||wake_time_passed () const|
|Check whether the wake time has passed. More...|
|bool||wake_time_set () const|
|Check whether wake timer is active. More...|
|Cancel any pending wake. More...|
|Schedule an os tick to fire. More...|
|Acknowledge an os tick. More...|
|Prevent any more scheduled ticks from triggering. More...|
|bool||ticking () const|
|Check whether ticker is active. More...|
|int||unacknowledged_ticks () const|
|Check unacknowledged ticks. More...|
|uint64_t||get_tick () const|
|Get the current tick count. More...|
|Update and get the current tick count. More...|
|us_timestamp_t||get_time_since_tick () const|
|Returns time since last tick. More...|
|us_timestamp_t||get_time () const|
|Get the time. More...|
Static Private Member Functions
|static void||irq (uint32_t id)|
|The handler registered with the underlying timer interrupt. More...|
The SysTimer class is used to provide timing for system suspension, and the idle loop in TICKLESS mode.
Template for speed for testing - only one instance will be used normally.
Definition at line 49 of file SysTimer.h.
Default constructor uses LPTICKER if available (so the timer will continue to run in deep sleep), else USTICKER.
Acknowledge an os tick.
This will queue another os tick immediately if the os is running slow
Prevent any more scheduled ticks from triggering.
If called from OS tick context, there may be remaining unacknowledged ticks.
Cancel any pending wake.
Get the current tick count.
This count is updated by the ticker interrupt, if the ticker interrupt is running. It the ticker interrupt is not running, update_and_get_tick() should be used instead.
This indicates how many ticks have been generated by the tick interrupt. The os_timer should equal this number minus the number of unacknowledged ticks.
Get the time.
Returns the instantaneous precision time from underlying timer. This is a slow operation so should not be called from critical sections.
Returns time since last tick.
Get the interrupt number for the tick.
Schedules an interrupt to cause wake-up in time for the event. Interrupt may be arranged early to account for latency. If the time has already passed, no interrupt will be scheduled.
This is called from outside a critical section, as it is known to be a slow operation.
If the wake time is already set, this is a no-op. But that check is racy, which means wake_time_set() should be rechecked after taking a critical section.
As a side-effect, this clears the unacknowledged tick count - the caller is expected to use update_and_get_tick() after the suspend operation.
|at||Wake up tick|
Schedule an os tick to fire.
Ticks will be rescheduled automatically every tick until cancel_tick is called.
A tick will be fired immediately if there are any unacknowledged ticks.
Check whether ticker is active.
Each time the tick interrupt fires, it is automatically rescheduled, so this will remain true once the tick is started, except during processing.
Definition at line 157 of file SysTimer.h.
Check unacknowledged ticks.
Returns the count of how many times the OS timer has been queued minus the number of times is has been acknowledged.
get_tick() - unacknowledged_ticks() should equal the OS's tick count, although such a calculation is not atomic if the ticker is currently running.
Definition at line 173 of file SysTimer.h.
Update and get the current tick count.
This is a slow operation that reads the timer and adjusts for elapsed time. Can only be used when the ticker is not running, as there is no IRQ synchronization.
This clears the unacknowledged tick counter - the caller is assumed to update their timer based on this return.
Check whether the wake time has passed.
This is a fast operation, based on checking whether the wake interrupt has run.
Definition at line 103 of file SysTimer.h.
Check whether wake timer is active.
Definition at line 113 of file SysTimer.h.