Trident IoT SDK
Loading...
Searching...
No Matches
Wall clock

Wall clock APIs that avoid reprogramming the hardware calendar. More...

Collaboration diagram for Wall clock:

Functions

uint64_t tr_rtc_wallclock_ms_get (void)
 Get the wall‑clock time (ms since 2000‑01‑01).
void tr_rtc_wallclock_ms_set (uint64_t ms_since_2000)
 Set the wall‑clock (ms since 2000‑01‑01) using the offset model.

Detailed Description

Wall clock APIs that avoid reprogramming the hardware calendar.

Function Documentation

◆ tr_rtc_wallclock_ms_get()

uint64_t tr_rtc_wallclock_ms_get ( void )

Get the wall‑clock time (ms since 2000‑01‑01).

Returns wall = now_ms + wallclock_offset. The offset lives in retention RAM, thus persists across deep‑sleep but is cleared on cold resets (power/external/watchdog). Use this if you need a “human time” representation without changing the hardware calendar.

Returns
Wall‑clock in ms since 2000‑01‑01.

◆ tr_rtc_wallclock_ms_set()

void tr_rtc_wallclock_ms_set ( uint64_t ms_since_2000)

Set the wall‑clock (ms since 2000‑01‑01) using the offset model.

Parameters
[in]ms_since_2000Desired wall‑clock time (ms since 2000‑01‑01).

Computes and stores wallclock_offset = desired_ms - HW_now_ms. Subsequent tr_rtc_wallclock_ms_get() calls will return the desired timeline without touching the hardware calendar. The offset is stored in retention RAM.

Example
// After receiving synchronized time as ms-since-2000:
uint64_t now_wall = tr_rtc_wallclock_ms_get();
void tr_rtc_wallclock_ms_set(uint64_t ms_since_2000)
Set the wall‑clock (ms since 2000‑01‑01) using the offset model.
uint64_t tr_rtc_wallclock_ms_get(void)
Get the wall‑clock time (ms since 2000‑01‑01).