One-shot software timers expiring in the tick interrupt.
More...
One-shot software timers expiring in the tick interrupt.
The callback runs in the tick ISR, so it must not block. Timers keep the idle thread from sleeping past their expiry. All functions may be called from ISRs, including from a callback to restart its own timer.
static void prv_expired(
struct pbl_timer *timer) {
...
}
Software timer.
Definition timer.h:35
void pbl_timer_init(struct pbl_timer *timer, pbl_timer_fn_t fn)
Initialize a timer.
void pbl_timer_start(struct pbl_timer *timer, pbl_timeout_t delay)
Start a timer, or restart it if it is active.
#define PBL_MSEC(ms)
Timeout in milliseconds, rounded down to whole ticks.
Definition types.h:61
#define container_of(ptr, type, member)
Get the structure that contains a member.
Definition misc.h:44
◆ pbl_timer
◆ PBL_TIMER_INITIALIZER
| #define PBL_TIMER_INITIALIZER |
( |
|
_fn | ) |
{.fn = (_fn)} |
Static initializer for a timer.
- Parameters
-
◆ pbl_timer_fn_t
| typedef void(* pbl_timer_fn_t) (struct pbl_timer *timer) |
Timer callback, run in the tick ISR.
◆ pbl_timer_init()
Initialize a timer.
- Parameters
-
| [out] | timer | Timer. |
| fn | Callback. |
◆ pbl_timer_is_active()
| bool pbl_timer_is_active |
( |
const struct pbl_timer * |
timer | ) |
|
Check whether a timer is active.
- Parameters
-
- Returns
- True from pbl_timer_start() until it expires or is stopped.
◆ pbl_timer_start()
Start a timer, or restart it if it is active.
- Parameters
-
| timer | Timer. |
| delay | Time until the callback runs, at least one tick; must not be PBL_FOREVER. |
◆ pbl_timer_stop()
| void pbl_timer_stop |
( |
struct pbl_timer * |
timer | ) |
|
Stop a timer.
Does nothing if it is not active.
- Parameters
-