Initialize the RTC driver and reconstruct internal state.
- Parameters
-
| [in] | reset_reason | One 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)
{
uint32_t cause = platform_read_reset_cause();
vTaskStartScheduler();
}
void tr_rtc_driver_init(uint32_t reset_reason)
Initialize the RTC driver and reconstruct internal state.