Trident IoT SDK
Loading...
Searching...
No Matches
Time sources

Hardware time and monotonic uptime. More...

Collaboration diagram for Time sources:

Functions

uint64_t tr_rtc_get_hw_ms (void)
 Get the current hardware RTC time in milliseconds since 2000‑01‑01.
uint64_t tr_rtc_get_uptime_ms (void)
 Get the 64‑bit monotonic uptime in milliseconds.

Detailed Description

Hardware time and monotonic uptime.

Function Documentation

◆ tr_rtc_get_hw_ms()

uint64_t tr_rtc_get_hw_ms ( void )

Get the current hardware RTC time in milliseconds since 2000‑01‑01.

Returns
Current hardware time (linear ms‑since‑2000).
Note
This reflects the hardware calendar and therefore changes if the calendar is set via tr_rtc_calendar_set(). It does not include any wall‑clock offset.

◆ tr_rtc_get_uptime_ms()

uint64_t tr_rtc_get_uptime_ms ( void )

Get the 64‑bit monotonic uptime in milliseconds.

Computed as uptime = base + (now_ms - ref_ms), where (base, ref_ms) are maintained in retention RAM. Uptime:

  • Increases while powered and across deep‑sleep (retained) resets.
  • Resets to 0 only on POWER/EXTERNAL/WATCHDOG resets.
  • Is preserved when the calendar is set; the driver re‑anchors the internal baseline so there is no glitch in uptime continuity.
Returns
Monotonic uptime in milliseconds.
Example
uint64_t t0 = tr_rtc_get_uptime_ms();
// ... do work or sleep ...
uint64_t dt = tr_rtc_get_uptime_ms() - t0;
uint64_t tr_rtc_get_uptime_ms(void)
Get the 64‑bit monotonic uptime in milliseconds.