Trident IoT SDK
Loading...
Searching...
No Matches
Initialization
Collaboration diagram for Initialization:

Functions

void tr_rtc_driver_init (uint32_t reset_reason)
 Initialize the RTC driver and reconstruct internal state.

Detailed Description

Function Documentation

◆ tr_rtc_driver_init()

void tr_rtc_driver_init ( uint32_t reset_reason)

Initialize the RTC driver and reconstruct internal state.

Parameters
[in]reset_reasonOne of TR_HAL_RESET_REASON_POWER, TR_HAL_RESET_REASON_EXTERNAL_RESET, TR_HAL_RESET_REASON_WATCHDOG, TR_HAL_RESET_REASON_SOFT, or TR_HAL_RESET_REASON_DEEP_SLEEP.

Call once per boot, as early as possible in main() and before any time‑related APIs (including FreeRTOS start or tickless hooks).

  • On POWER/EXTERNAL/WATCHDOG, retention state is reinitialized, monotonic uptime is set to 0, wall‑clock offset cleared, and the reference time is captured from the current RTC value.
  • On SOFT/DEEP_SLEEP, retention state is preserved and the driver reconstructs uptime/wall‑clock from (base,ref,offset).
Example
int main(void)
{
// ... clocks, board init ...
uint32_t cause = platform_read_reset_cause();
tr_rtc_driver_init(cause); // must be called early
// ... other drivers ...
vTaskStartScheduler();
}
void tr_rtc_driver_init(uint32_t reset_reason)
Initialize the RTC driver and reconstruct internal state.