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):
- Delays/waiting in critical sections
- Bit-banging input/output
- Performance profiling
◆ 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_us | timeout 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] | timer | precise timer object to query |
- Returns
- time elapsed since the timer creation, in microseconds
◆ precise_timer_is_expired()
Check whether a precise timer is past its timeout.
- Parameters
-
| [in] | timer | precise timer object to check |
- Returns
true if the timeout has passed, false otherwise
◆ precise_timer_wait()
Block the current execution context until the timer is expired.
- Parameters
-
| [in] | timer | precise timer object to use |
◆ precise_timer_wait_for()
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] | timer | precise timer object to use |
| [in] | condition_cb | pointer to the condition check (predicate) function |
| [in,out] | context | pointer to the user-specific object (will be passed to the callback) |
- Returns
true if the condition has been reached before the timeout, false otherwise