Real-time clock class: hardware that keeps the wall clock across resets.
More...
|
| | POSIX |
| | RTC following the host clock.
|
| |
| | QEMU |
| | QEMU RTC, following the host clock.
|
| |
| | Retained RAM |
| | RTC for SoCs without a calendar: the time last set, kept in retained RAM.
|
| |
| | SF32LB |
| | SiFli SF32LB calendar RTC, counting clk_rtc at its calibrated rate.
|
| |
Real-time clock class: hardware that keeps the wall clock across resets.
An RTC is a struct pbl_rtc device that counts UTC time in seconds on its own, through resets and, with a backup supply, power loss. The kernel keeps the running wall clock (pbl_realtime()); the clock service sets it from the board's RTC at boot and writes it back when the time changes and periodically.
time_t t;
}
const struct pbl_rtc *const RTC
The board's RTC.
int pbl_rtc_get_time(const struct pbl_rtc *rtc, time_t *t)
Read the time.
void pbl_realtime_set(time_t t)
Set the wall clock time.
◆ pbl_rtc
◆ PBL_RTC_INIT
| #define PBL_RTC_INIT |
( |
|
sym, |
|
|
|
_name, |
|
|
|
_init, |
|
|
|
_parent, |
|
|
|
_ops |
|
) |
| |
Value: { \
.ops = (_ops), \
}
#define PBL_DEVICE_INIT_CLASS(sym, _name, _init, _parent, _cls)
Initializer for the struct pbl_device of device instance sym, in class _cls.
Definition device.h:153
Initialize a struct pbl_rtc.
- Parameters
-
| sym | Symbol of the instance, with its state defined by PBL_DEVICE_STATE_DEFINE(). |
| _name | Device name. |
| _init | Init function, or NULL. |
| _parent | Parent device, or NULL. |
| _ops | Driver operations. |
◆ pbl_rtc_get_time()
| int pbl_rtc_get_time |
( |
const struct pbl_rtc * |
rtc, |
|
|
time_t * |
t |
|
) |
| |
Read the time.
- Parameters
-
| rtc | RTC. |
| [out] | t | UTC time in seconds since the epoch. |
- Returns
- 0, -ENODEV if the RTC is not ready, or a negative errno.
◆ pbl_rtc_set_time()
| int pbl_rtc_set_time |
( |
const struct pbl_rtc * |
rtc, |
|
|
time_t |
t |
|
) |
| |
Set the time.
- Parameters
-
| rtc | RTC. |
| t | UTC time in seconds since the epoch. |
- Returns
- 0, -ENODEV if the RTC is not ready, -EINVAL if the RTC cannot hold
t, or a negative errno.
◆ RTC