Trident IoT SDK
Loading...
Searching...
No Matches
Alarm for tickless idle

Program wakeups for FreeRTOS tickless sleep. More...

Collaboration diagram for Alarm for tickless idle:

Functions

void tr_rtc_setup_alarm (uint64_t delta_ms)
 Program an RTC alarm to fire approximately delta_ms in the future.

Detailed Description

Program wakeups for FreeRTOS tickless sleep.

Function Documentation

◆ tr_rtc_setup_alarm()

void tr_rtc_setup_alarm ( uint64_t delta_ms)

Program an RTC alarm to fire approximately delta_ms in the future.

Parameters
[in]delta_msRelative delay in milliseconds. If 0, it is coerced to 1 ms.

Converts (HW_now_ms + max(delta_ms,1)) to an absolute calendar value and arms the hardware alarm via the HAL. Intended for FreeRTOS tickless idle, where the alarm interrupt wakes from WFI/Sleep or triggers a deep‑sleep wake/reset, depending on the platform power configuration.

Example (integration sketch)
void vPortSuppressTicksAndSleep(TickType_t expectedIdle)
{
if (expectedIdle == 0) return;
if (eTaskConfirmSleepModeStatus() == eAbortSleep) return;
const uint32_t tick_ms = 1000u / configTICK_RATE_HZ;
uint32_t sleep_ms = expectedIdle * tick_ms;
tr_rtc_setup_alarm(sleep_ms);
uint64_t before = tr_rtc_get_uptime_ms();
// enter low power: WFI / SLEEP / DEEP_SLEEP (platform policy)
platform_enter_low_power(expectedIdle);
uint64_t after = tr_rtc_get_uptime_ms();
TickType_t slept = (TickType_t)((after - before) / tick_ms);
if (slept > expectedIdle) slept = expectedIdle;
vTaskStepTick(slept);
}
void tr_rtc_setup_alarm(uint64_t delta_ms)
Program an RTC alarm to fire approximately delta_ms in the future.
uint64_t tr_rtc_get_uptime_ms(void)
Get the 64‑bit monotonic uptime in milliseconds.