Adjustable (non-steady) clock. More...
#include <cmsis-plus/rtos/os.h>
Public Types | |
Types & Constants | |
using | duration_t = port::clock::duration_t |
Type of variables holding clock durations. | |
using | timestamp_t = port::clock::timestamp_t |
Type of variables holding clock time stamps. | |
using | offset_t = port::clock::offset_t |
Type of variables holding clock offsets. | |
Public Member Functions | |
Constructors & Destructor | |
virtual | ~adjustable_clock () override |
Destruct the clock object instance. | |
Public Member Functions | |
virtual timestamp_t | now (void) override |
Tell the current time adjusted for epoch. | |
virtual result_t | sleep_until (timestamp_t timestamp) override |
Sleep until an absolute timestamp. | |
virtual offset_t | offset (void) override |
Get adjustment offset. | |
virtual offset_t | offset (offset_t value) override |
Set adjustment offset. | |
void | internal_check_timestamps (void) |
Public Member Functions | |
virtual void | start (void)=0 |
Start the clock. | |
timestamp_t | steady_now (void) |
Tell the current time since startup. | |
result_t | sleep_for (duration_t duration) |
Sleep for a relative duration. | |
result_t | wait_for (duration_t timeout) |
Timed wait for an event. | |
timestamp_t | update_for_slept_time (duration_t duration) |
Increase the internal count after a deep sleep. | |
Public Member Functions | |
const char * | name (void) const |
Get object name. | |
Adjustable (non-steady) clock.
Definition at line 322 of file os-clocks.h.
|
overridevirtual |
Destruct the clock object instance.
Definition at line 421 of file os-clocks.cpp.
void os::rtos::adjustable_clock::internal_check_timestamps | ( | void | ) |
|
inlineinherited |
Get object name.
All objects return a non-null string; anonymous objects return "-"
.
Definition at line 759 of file os-decls.h.
|
overridevirtual |
Tell the current time adjusted for epoch.
Reimplemented from os::rtos::clock.
Definition at line 434 of file os-clocks.cpp.
|
overridevirtual |
Set adjustment offset.
[in] | value | Integer representing the offset to epoch (positive). |
Definition at line 504 of file os-clocks.cpp.
|
overridevirtual |
Get adjustment offset.
Definition at line 495 of file os-clocks.cpp.
|
inherited |
Sleep for a relative duration.
[in] | duration | The number of clock units (ticks or seconds) to sleep. |
ETIMEDOUT | The sleep lasted the entire duration. |
EPERM | Cannot be invoked from an Interrupt Service Routines. |
EINTR | The sleep was interrupted. |
Definition at line 190 of file os-clocks.cpp.
|
overridevirtual |
Sleep until an absolute timestamp.
[in] | timestamp | The absolute moment in time, in clock units. |
ETIMEDOUT | The sleep lasted the entire duration. |
EPERM | Cannot be invoked from an Interrupt Service Routines. |
EINTR | The sleep was interrupted. |
Reimplemented from os::rtos::clock.
Definition at line 456 of file os-clocks.cpp.
|
pure virtualinherited |
Start the clock.
For system clocks it is called from the system startup code.
Implemented in os::rtos::clock_systick, os::rtos::clock_rtc, and os::rtos::clock_highres.
Definition at line 154 of file os-clocks.cpp.
|
inherited |
Tell the current time since startup.
Definition at line 176 of file os-clocks.cpp.
|
inherited |
Increase the internal count after a deep sleep.
duration | Number of ticks lost during sleep. |
During deep sleep the interrupts used to count clock ticks are usually disabled and an external RTC is configured to wake-up the device, so a number of clock ticks are lost.
To keep the clocks accurate, it is recommended to sample the external RTC before entering deep sleep and again when the device is back to life, compute the time slept as difference, and use this function to update the internal clock counter.
Definition at line 329 of file os-clocks.cpp.
|
inherited |
Timed wait for an event.
[in] | timeout | The timeout in clock units. |
result::ok | An event occurred before the timeout. |
ETIMEDOUT | The wait lasted the entire duration. |
EPERM | Cannot be invoked from an Interrupt Service Routines. |
EINTR | The sleep was interrupted. |
Definition at line 279 of file os-clocks.cpp.