PebbleOS v4.47.0-512-g5285d4236
Loading...
Searching...
No Matches

Real-time clock class: hardware that keeps the wall clock across resets. More...

Modules

 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.
 

Data Structures

struct  pbl_rtc_ops
 RTC driver operations. More...
 
struct  pbl_rtc
 RTC. More...
 

Macros

#define PBL_RTC_INIT(sym, _name, _init, _parent, _ops)
 Initialize a struct pbl_rtc.
 

Functions

int pbl_rtc_get_time (const struct pbl_rtc *rtc, time_t *t)
 Read the time.
 
int pbl_rtc_set_time (const struct pbl_rtc *rtc, time_t t)
 Set the time.
 

Variables

const struct pbl_rtc *const RTC
 The board's RTC.
 

Detailed Description

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;
if (pbl_rtc_get_time(RTC, &t) == 0) {
}
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.

Data Structure Documentation

◆ pbl_rtc

struct pbl_rtc

RTC.

Data Fields
struct pbl_device dev Device.
const struct pbl_rtc_ops * ops Driver operations.

Macro Definition Documentation

◆ PBL_RTC_INIT

#define PBL_RTC_INIT (   sym,
  _name,
  _init,
  _parent,
  _ops 
)
Value:
{ \
.dev = PBL_DEVICE_INIT_CLASS(sym, _name, _init, _parent, &pbl_rtc_class), \
.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
symSymbol of the instance, with its state defined by PBL_DEVICE_STATE_DEFINE().
_nameDevice name.
_initInit function, or NULL.
_parentParent device, or NULL.
_opsDriver operations.

Function Documentation

◆ pbl_rtc_get_time()

int pbl_rtc_get_time ( const struct pbl_rtc *  rtc,
time_t *  t 
)

Read the time.

Parameters
rtcRTC.
[out]tUTC 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
rtcRTC.
tUTC 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.

Variable Documentation

◆ RTC

const struct pbl_rtc* const RTC
extern

The board's RTC.