7#ifndef ZEPHYR_INCLUDE_SLEEP_H_
8#define ZEPHYR_INCLUDE_SLEEP_H_
78#define Z_SLEEP_TICK_HZ ((uint32_t)CONFIG_SYS_CLOCK_TICKS_PER_SEC)
83#define Z_SLEEP_IS_SIMPLE(to_hz) \
84 (Z_SLEEP_TICK_HZ % (to_hz) == 0 || (to_hz) % Z_SLEEP_TICK_HZ == 0)
87#define Z_SLEEP_MAX_TICKS(to_hz) ((uint64_t)INT32_MAX * Z_SLEEP_TICK_HZ / (to_hz))
92#define Z_SLEEP_NO_OVERFLOW(to_hz) \
93 ((uint64_t)Z_SLEEP_TICK_HZ * ((to_hz) + 1U) <= UINT32_MAX)
98#define Z_SLEEP_SPLIT(t, to_hz) \
99 (((t) / Z_SLEEP_TICK_HZ) * (to_hz) + \
100 DIV_ROUND_UP(((t) % Z_SLEEP_TICK_HZ) * (to_hz), Z_SLEEP_TICK_HZ))
180 return z_sleep_ticks_to_int32_us_split(t);
213 return z_sleep_ticks_to_int32_ms(ticks);
229 return k_sleep(Z_TIMEOUT_MS(ms));
252 return z_sleep_ticks_to_int32_us(ticks);
261#include <zephyr/syscalls/sleep.h>
#define MSEC_PER_SEC
number of milliseconds per second
Definition clock.h:92
#define USEC_PER_MSEC
number of microseconds per millisecond
Definition clock.h:89
#define K_TICKS_FOREVER
Definition clock.h:51
#define USEC_PER_SEC
number of microseconds per second
Definition clock.h:110
uint32_t k_ticks_t
Tick precision used in timeout APIs.
Definition clock.h:48
#define K_TIMEOUT_EQ(a, b)
Compare timeouts for equality.
Definition clock.h:80
#define IS_ENABLED(config_macro)
Check for macro definition in compiler-visible expressions.
Definition util_macro.h:154
#define MIN(a, b)
Obtain the minimum of two values.
Definition util.h:406
#define DIV_ROUND_UP(n, d)
Divide and round up.
Definition util.h:348
static int32_t k_sleep(k_timeout_t timeout)
Put the current thread to sleep.
Definition sleep.h:204
static int32_t k_usleep(int32_t us)
Put the current thread to sleep with microsecond resolution.
Definition sleep.h:248
static int32_t k_msleep(int32_t ms)
Put the current thread to sleep.
Definition sleep.h:227
k_ticks_t k_sleep_ticks(k_timeout_t timeout)
Put the current thread to sleep, with tick resolution.
#define k_ticks_to_ms_ceil64(t)
Convert ticks to milliseconds.
Definition time_units.h:1798
#define k_ticks_to_us_ceil64(t)
Convert ticks to microseconds.
Definition time_units.h:1894
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__INT32_TYPE__ int32_t
Definition stdint.h:74
#define INT32_MAX
Definition stdint.h:18
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
Kernel timeout type.
Definition clock.h:65