BSB Developer Docs
Loading...
Searching...
No Matches
Precise timers

Data Structures

struct  PreciseTimer
 PreciseTimer structure definition. More...
 

Functions

PreciseTimer FURI_WARN_UNUSED precise_timer_create (uint32_t timeout_us)
 Create a precise timer with the designated timeout.
 
uint32_t precise_timer_get_elapsed (const PreciseTimer timer)
 Get the time elapsed since the timer creation, in microseconds.
 
bool precise_timer_is_expired (const PreciseTimer timer)
 Check whether a precise timer is past its timeout.
 
void precise_timer_wait (const PreciseTimer timer)
 Block the current execution context until the timer is expired.
 
bool precise_timer_wait_for (const PreciseTimer timer, TimerConditionCallback condition_cb, void *context)
 Block the caller until the timer is expired OR a condition is reached.
 

Detailed Description

Timers with microsecond (μs) precision.

Can be used anytime anywhere (including critical sections), but the maximum timeout is limited usually to several seconds, depending on the system configuration.

Typical applications include (but not limited to):

Function Documentation

◆ precise_timer_create()

PreciseTimer FURI_WARN_UNUSED precise_timer_create ( uint32_t timeout_us)

Create a precise timer with the designated timeout.

Note
Passing 0 as timeout_ms will cause the timer to expire immediately
Parameters
[in]timeout_ustimeout value, in microseconds
Returns
initialised PreciseTimer object

◆ precise_timer_get_elapsed()

uint32_t precise_timer_get_elapsed ( const PreciseTimer timer)

Get the time elapsed since the timer creation, in microseconds.

Parameters
[in]timerprecise timer object to query
Returns
time elapsed since the timer creation, in microseconds

◆ precise_timer_is_expired()

bool precise_timer_is_expired ( const PreciseTimer timer)

Check whether a precise timer is past its timeout.

Parameters
[in]timerprecise timer object to check
Returns
true if the timeout has passed, false otherwise

◆ precise_timer_wait()

void precise_timer_wait ( const PreciseTimer timer)

Block the current execution context until the timer is expired.

Parameters
[in]timerprecise timer object to use

◆ precise_timer_wait_for()

bool precise_timer_wait_for ( const PreciseTimer timer,
TimerConditionCallback condition_cb,
void * context )

Block the caller until the timer is expired OR a condition is reached.

Note
If the timer has expired, this function will always return false even if the callback returns true.
Parameters
[in]timerprecise timer object to use
[in]condition_cbpointer to the condition check (predicate) function
[in,out]contextpointer to the user-specific object (will be passed to the callback)
Returns
true if the condition has been reached before the timeout, false otherwise