Callbacks run every N seconds or every N minutes.
More...
Callbacks run every N seconds or every N minutes.
All regular timers share one timer aligned to the RTC second boundary, so periodic work wakes the system at the same time. Second callbacks run shortly after each second boundary, minute callbacks when the wall-clock minute changes. Callbacks run on the NewTimers task and must not block for long.
The caller owns the RegularTimerInfo, which must stay valid while registered:
static void prv_tick(void *data) {
}
};
...
regular_timer_remove_callback(&s_timer);
RegularTimerCallback cb
Callback to run.
Definition regular_timer.h:49
Regular timer registration, owned by the caller.
Definition regular_timer.h:44
void regular_timer_add_multisecond_callback(RegularTimerInfo *cb, uint16_t seconds)
Run a callback every seconds seconds.
◆ RegularTimerInfo
Regular timer registration, owned by the caller.
◆ RegularTimerCallback
| typedef void(* RegularTimerCallback) (void *data) |
Regular timer callback.
- Parameters
-
◆ regular_timer_add_minutes_callback()
Run a callback every minute.
- Parameters
-
◆ regular_timer_add_multiminute_callback()
| void regular_timer_add_multiminute_callback |
( |
RegularTimerInfo * |
cb, |
|
|
uint16_t |
minutes |
|
) |
| |
Run a callback every minutes minutes.
Can also change the period of a registered minutes timer, from inside or outside its callback. Re-adding a timer pending deletion cancels the deletion. A timer cannot be both a seconds and a minutes timer.
- Parameters
-
| cb | Timer to register. |
| minutes | Period in minutes. |
◆ regular_timer_add_multisecond_callback()
| void regular_timer_add_multisecond_callback |
( |
RegularTimerInfo * |
cb, |
|
|
uint16_t |
seconds |
|
) |
| |
Run a callback every seconds seconds.
Can also change the period of a registered seconds timer, from inside or outside its callback. Re-adding a timer pending deletion cancels the deletion. A timer cannot be both a seconds and a minutes timer.
- Parameters
-
| cb | Timer to register. |
| seconds | Period in seconds. |
◆ regular_timer_add_seconds_callback()
Run a callback every second.
- Parameters
-
◆ regular_timer_deinit()
| void regular_timer_deinit |
( |
void |
| ) |
|
Stop the shared timer, for tests.
◆ regular_timer_fire_minutes()
| void regular_timer_fire_minutes |
( |
uint8_t |
mins | ) |
|
Fire the minutes timers whose period is a multiple of mins, for tests.
- Parameters
-
◆ regular_timer_fire_seconds()
| void regular_timer_fire_seconds |
( |
uint8_t |
secs | ) |
|
Fire the seconds timers whose period is a multiple of secs, for tests.
- Parameters
-
◆ regular_timer_init()
| void regular_timer_init |
( |
void |
| ) |
|
Initialize the service and start the shared timer.
◆ regular_timer_is_scheduled()
Check whether a timer is registered.
- Parameters
-
- Returns
- True if registered, including when pending deletion.
◆ regular_timer_minutes_count()
| uint32_t regular_timer_minutes_count |
( |
void |
| ) |
|
Count the registered minutes timers, for tests.
- Returns
- Number of timers.
◆ regular_timer_pending_deletion()
Check whether a timer is pending deletion.
A timer is pending deletion when it was removed while its callback was running.
- Parameters
-
- Returns
- True if pending deletion.
◆ regular_timer_remove_callback()
Unregister a seconds or minutes timer.
If the callback is running, the timer is only marked for deletion and is removed when the callback returns. When called from the callback itself, the RegularTimerInfo must not be freed until the callback has returned.
- Parameters
-
- Return values
-
| true | The timer was removed. |
| false | The timer was not registered, or is running and was marked for deletion. |
◆ regular_timer_seconds_count()
| uint32_t regular_timer_seconds_count |
( |
void |
| ) |
|
Count the registered seconds timers, for tests.
- Returns
- Number of timers.