Mbed OS Reference
|
An implementation of a C++11 Clock representing the HAL real-time clock. More...
#include <RealTimeClock.h>
Static Public Member Functions | |
static void | init () |
Initialize the RTC peripheral. More... | |
static void | free () |
Deinitialize RTC. More... | |
static bool | isenabled () noexcept |
Check if the RTC has the time set and is counting. More... | |
static time_point | now () noexcept |
Get the current time from the RTC peripheral. More... | |
static void | write (time_point t) noexcept |
Write the current time in seconds to the RTC peripheral. More... | |
static time_point | from_time_t (time_t t) noexcept |
Convert a C time_t to C++ Chrono time_point. More... | |
static time_t | to_time_t (const time_point &t) noexcept |
Convert a C++ Chrono time_point to a C time_t. More... | |
static void | lock () |
Lock the clock to ensure it stays running; dummy for API compatibility with HighResClock. More... | |
static void | unlock () |
Unlock the clock, allowing it to stop during power saving; dummy for API compatibility with HighResClock. More... | |
An implementation of a C++11 Clock representing the HAL real-time clock.
This is intended to be usable as a substitute for std::chrono::system_clock
, but is provided as a separate class, due to inconsistencies in retargetting support between toolchains.
This is only a thin wrapper around the HAL RTC API, and as such it requires the same use of initialization.
Definition at line 41 of file RealTimeClock.h.
|
static |
Initialize the RTC peripheral.
Power up the RTC in preparation for access. This function must be called before any other RealTimeClock methods are called. This does not change the state of the RTC. It just enables access to it.
Definition at line 57 of file RealTimeClock.h.
|
static |
Deinitialize RTC.
Powerdown the RTC in preparation for sleep, powerdown or reset. That should only affect the CPU domain and not the time keeping logic. After this function is called no other RealTimeClock methods should be called except for RealTimeClock::init.
Definition at line 71 of file RealTimeClock.h.
|
staticnoexcept |
Check if the RTC has the time set and is counting.
false | The time reported by the RTC is not valid |
true | The time has been set and the RTC is counting |
Definition at line 83 of file RealTimeClock.h.
|
staticnoexcept |
Get the current time from the RTC peripheral.
Definition at line 94 of file RealTimeClock.h.
|
staticnoexcept |
Write the current time in seconds to the RTC peripheral.
t | The current time to be set in seconds. |
Definition at line 105 of file RealTimeClock.h.
|
staticnoexcept |
Convert a C time_t to C++ Chrono time_point.
t | a time_t object |
t
. Definition at line 115 of file RealTimeClock.h.
|
staticnoexcept |
Convert a C++ Chrono time_point to a C time_t.
t | a RealTimeClock::time_point object |
time_t
object that represents the same point in time as t
. Definition at line 125 of file RealTimeClock.h.
|
static |
Lock the clock to ensure it stays running; dummy for API compatibility with HighResClock.
Definition at line 131 of file RealTimeClock.h.
|
static |
Unlock the clock, allowing it to stop during power saving; dummy for API compatibility with HighResClock.
Definition at line 136 of file RealTimeClock.h.