v2.0.0
Data Structures | Macros | Typedefs | Functions | Variables
time.h File Reference
`#include "pico.h"`
`#include "hardware/timer.h"`
Include dependency graph for time.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures
struct | repeating_timer
| Information about a repeating timer. More...

## Macros
#define | PARAM_ASSERTIONS_ENABLED_PICO_TIME 0
#define | PICO_TIME_SLEEP_OVERHEAD_ADJUST_US 6
#define | PICO_TIME_DEFAULT_ALARM_POOL_DISABLED 0
| If 1 then the default alarm pool is disabled (so no timer_alarm is claimed for the pool) More...
#define | PICO_TIME_DEFAULT_ALARM_POOL_HARDWARE_ALARM_NUM 3
| Selects which timer_alarm is used for the default alarm pool. More...
#define | PICO_TIME_DEFAULT_ALARM_POOL_MAX_TIMERS 16
| Selects the maximum number of concurrent timers in the default alarm pool. More...

## Typedefs
typedef int32_t | alarm_id_t
| The identifier for an alarm. More...
typedef int64_t(* | alarm_callback_t) (alarm_id_t id, void *user_data)
| User alarm callback. More...
typedef struct alarm_pool | alarm_pool_t
typedef void | alarm_pool_timer_t
typedef struct repeating_timer | repeating_timer_t
typedef bool(* | repeating_timer_callback_t) (repeating_timer_t *rt)
| Callback for a repeating timer. More...

## Functions
static absolute_time_t | get_absolute_time (void)
| Return a representation of the current time. More...
static uint32_t | us_to_ms (uint64_t us)
static uint32_t | to_ms_since_boot (absolute_time_t t)
| Convert a timestamp into a number of milliseconds since boot. More...
static absolute_time_t | delayed_by_us (const absolute_time_t t, uint64_t us)
| Return a timestamp value obtained by adding a number of microseconds to another timestamp. More...
static absolute_time_t | delayed_by_ms (const absolute_time_t t, uint32_t ms)
| Return a timestamp value obtained by adding a number of milliseconds to another timestamp. More...
static absolute_time_t | make_timeout_time_us (uint64_t us)
| Convenience method to get the timestamp a number of microseconds from the current time. More...
static absolute_time_t | make_timeout_time_ms (uint32_t ms)
| Convenience method to get the timestamp a number of milliseconds from the current time. More...
static int64_t | absolute_time_diff_us (absolute_time_t from, absolute_time_t to)
| Return the difference in microseconds between two timestamps. More...
static absolute_time_t | absolute_time_min (absolute_time_t a, absolute_time_t b)
| Return the earlier of two timestamps. More...
static bool | is_at_the_end_of_time (absolute_time_t t)
| Determine if the given timestamp is "at_the_end_of_time". More...
static bool | is_nil_time (absolute_time_t t)
| Determine if the given timestamp is nil. More...
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...
void | alarm_pool_init_default (void)
| Create the default alarm pool (if not already created or disabled)
void | runtime_init_default_alarm_pool (void)
alarm_pool_t * | alarm_pool_get_default (void)
| The default alarm pool used when alarms are added without specifying an alarm pool, and also used by the SDK to support lower power sleeps and timeouts. More...
alarm_pool_t * | alarm_pool_create_on_timer (alarm_pool_timer_t *timer, uint timer_alarm_num, uint max_timers)
alarm_pool_timer_t * | alarm_pool_timer_for_timer_num (uint timer_num)
alarm_pool_timer_t * | alarm_pool_get_default_timer (void)
static alarm_pool_t * | alarm_pool_create (uint timer_alarm_num, uint max_timers)
| Create an alarm pool. More...
alarm_pool_t * | alarm_pool_create_on_timer_with_unused_hardware_alarm (alarm_pool_timer_t *timer, uint max_timers)
static alarm_pool_t * | alarm_pool_create_with_unused_hardware_alarm (uint max_timers)
| Create an alarm pool, claiming an used timer_alarm to back it. More...
uint | alarm_pool_timer_alarm_num (alarm_pool_t *pool)
| Return the timer alarm used by an alarm pool. More...
static uint | alarm_pool_hardware_alarm_num (alarm_pool_t *pool)
uint | alarm_pool_core_num (alarm_pool_t *pool)
| Return the core number the alarm pool was initialized on (and hence callbacks are called on) More...
void | alarm_pool_destroy (alarm_pool_t *pool)
| Destroy the alarm pool, cancelling all alarms and freeing up the underlying timer_alarm. More...
alarm_id_t | alarm_pool_add_alarm_at (alarm_pool_t *pool, absolute_time_t time, alarm_callback_t callback, void *user_data, bool fire_if_past)
| Add an alarm callback to be called at a specific time. More...
alarm_id_t | alarm_pool_add_alarm_at_force_in_context (alarm_pool_t *pool, absolute_time_t time, alarm_callback_t callback, void *user_data)
| Add an alarm callback to be called at or after a specific time. More...
static alarm_id_t | alarm_pool_add_alarm_in_us (alarm_pool_t *pool, uint64_t us, alarm_callback_t callback, void *user_data, bool fire_if_past)
| Add an alarm callback to be called after a delay specified in microseconds. More...
static alarm_id_t | alarm_pool_add_alarm_in_ms (alarm_pool_t *pool, uint32_t ms, alarm_callback_t callback, void *user_data, bool fire_if_past)
| Add an alarm callback to be called after a delay specified in milliseconds. More...
int64_t | alarm_pool_remaining_alarm_time_us (alarm_pool_t *pool, alarm_id_t alarm_id)
| Return the time remaining before the next trigger of an alarm. More...
int32_t | alarm_pool_remaining_alarm_time_ms (alarm_pool_t *pool, alarm_id_t alarm_id)
| Return the time remaining before the next trigger of an alarm. More...
bool | alarm_pool_cancel_alarm (alarm_pool_t *pool, alarm_id_t alarm_id)
| Cancel an alarm. More...
static alarm_id_t | add_alarm_at (absolute_time_t time, alarm_callback_t callback, void *user_data, bool fire_if_past)
| Add an alarm callback to be called at a specific time. More...
static alarm_id_t | add_alarm_in_us (uint64_t us, alarm_callback_t callback, void *user_data, bool fire_if_past)
| Add an alarm callback to be called after a delay specified in microseconds. More...
static alarm_id_t | add_alarm_in_ms (uint32_t ms, alarm_callback_t callback, void *user_data, bool fire_if_past)
| Add an alarm callback to be called after a delay specified in milliseconds. More...
static bool | cancel_alarm (alarm_id_t alarm_id)
| Cancel an alarm from the default alarm pool. More...
int64_t | remaining_alarm_time_us (alarm_id_t alarm_id)
| Return the time remaining before the next trigger of an alarm. More...
int32_t | remaining_alarm_time_ms (alarm_id_t alarm_id)
| Return the time remaining before the next trigger of an alarm. More...
bool | alarm_pool_add_repeating_timer_us (alarm_pool_t *pool, int64_t delay_us, repeating_timer_callback_t callback, void *user_data, repeating_timer_t *out)
| Add a repeating timer that is called repeatedly at the specified interval in microseconds. More...
static bool | alarm_pool_add_repeating_timer_ms (alarm_pool_t *pool, int32_t delay_ms, repeating_timer_callback_t callback, void *user_data, repeating_timer_t *out)
| Add a repeating timer that is called repeatedly at the specified interval in milliseconds. More...
static bool | add_repeating_timer_us (int64_t delay_us, repeating_timer_callback_t callback, void *user_data, repeating_timer_t *out)
| Add a repeating timer that is called repeatedly at the specified interval in microseconds. More...
static bool | add_repeating_timer_ms (int32_t delay_ms, repeating_timer_callback_t callback, void *user_data, repeating_timer_t *out)
| Add a repeating timer that is called repeatedly at the specified interval in milliseconds. More...
bool | cancel_repeating_timer (repeating_timer_t *timer)
| Cancel a repeating timer. More...

## Variables
const absolute_time_t | at_the_end_of_time
| The timestamp representing the end of time; this is actually not the maximum possible timestamp, but is set to 0x7fffffff_ffffffff microseconds to avoid sign overflows with time arithmetic. This is almost 300,000 years, so should be sufficient.
const absolute_time_t | nil_time
| The timestamp representing a null timestamp.