Sleep functions for delaying execution in a lower power state. More...
Functions | |
void | sleep_until (absolute_time_t target) |
Wait until after the given timestamp to return. More... | |
void | sleep_us (uint64_t us) |
Wait for the given number of microseconds before returning. More... | |
void | sleep_ms (uint32_t ms) |
Wait for the given number of milliseconds before returning. More... | |
bool | best_effort_wfe_or_timeout (absolute_time_t timeout_timestamp) |
Helper method for blocking on a timeout. More... | |
Sleep functions for delaying execution in a lower power state.
These functions allow the calling core to sleep. This is a lower powered sleep; waking and re-checking time on every processor event (WFE)
bool best_effort_wfe_or_timeout | ( | absolute_time_t | timeout_timestamp | ) |
Helper method for blocking on a timeout.
This method will return in response to an event (as per __wfe) or when the target time is reached, or at any point before.
This method can be used to implement a lower power polling loop waiting on some condition signalled by an event (__sev()).
This is called best_effort because under certain circumstances (notably the default timer pool being disabled or full) the best effort is simply to return immediately without a __wfe, thus turning the calling code into a busy wait.
Example usage:
timeout_timestamp | the timeout time |
void sleep_ms | ( | uint32_t | ms | ) |
Wait for the given number of milliseconds before returning.
ms | the number of milliseconds to sleep |
void sleep_until | ( | absolute_time_t | target | ) |
Wait until after the given timestamp to return.
target | the time after which to return |
void sleep_us | ( | uint64_t | us | ) |
Wait for the given number of microseconds before returning.
us | the number of microseconds to sleep |