Zephyr API Documentation 4.2.99
A Scalable Open Source RTOS
 4.2.99
clock.h File Reference

System clock APIs. More...

#include <zephyr/sys/dlist.h>
#include <zephyr/sys/time_units.h>
#include <zephyr/sys/util.h>
#include <zephyr/toolchain.h>
#include <zephyr/types.h>
#include <zephyr/syscalls/clock.h>

Go to the source code of this file.

Data Structures

struct  k_timeout_t
 Kernel timeout type. More...
struct  k_timepoint_t
 Kernel timepoint type. More...

Macros

#define K_TICKS_FOREVER   ((k_ticks_t)(-1))
#define K_TIMEOUT_EQ(a, b)
 Compare timeouts for equality.
#define NSEC_PER_USEC   1000U
 number of nanoseconds per microsecond
#define NSEC_PER_MSEC   1000000U
 number of nanoseconds per millisecond
#define USEC_PER_MSEC   1000U
 number of microseconds per millisecond
#define MSEC_PER_SEC   1000U
 number of milliseconds per second
#define SEC_PER_MIN   60U
 number of seconds per minute
#define SEC_PER_HOUR   3600U
 number of seconds per hour
#define SEC_PER_DAY   86400U
 number of seconds per day
#define MIN_PER_HOUR   60U
 number of minutes per hour
#define HOUR_PER_DAY   24U
 number of hours per day
#define USEC_PER_SEC   ((USEC_PER_MSEC) * (MSEC_PER_SEC))
 number of microseconds per second
#define NSEC_PER_SEC   ((NSEC_PER_USEC) * (USEC_PER_MSEC) * (MSEC_PER_SEC))
 number of nanoseconds per second
#define SYS_CLOCK_HW_CYCLES_TO_NS_AVG(X, NCYCLES)
 SYS_CLOCK_HW_CYCLES_TO_NS_AVG converts CPU clock cycles to nanoseconds and calculates the average cycle time.
#define SYS_CLOCK_REALTIME   1
 The real-time clock (i.e.
#define SYS_CLOCK_MONOTONIC   4
 The monotonic clock.
#define SYS_TIMER_ABSTIME   4
 The flag used for specifying absolute timeouts.

Typedefs

typedef uint32_t k_ticks_t
 Tick precision used in timeout APIs.

Functions

uint32_t sys_clock_tick_get_32 (void)
 Return the lower part of the current system tick count.
int64_t sys_clock_tick_get (void)
 Return the current system tick count.
k_timepoint_t sys_timepoint_calc (k_timeout_t timeout)
 Calculate a timepoint value.
k_timeout_t sys_timepoint_timeout (k_timepoint_t timepoint)
 Remaining time to given timepoint.
static int sys_timepoint_cmp (k_timepoint_t a, k_timepoint_t b)
 Compare two timepoint values.
static bool sys_timepoint_expired (k_timepoint_t timepoint)
 Indicates if timepoint is expired.
void sys_clock_getrtoffset (struct timespec *tp)
 INTERNAL_HIDDEN.
int sys_clock_gettime (int clock_id, struct timespec *tp)
 Get the current time from the specified clock.
int sys_clock_settime (int clock_id, const struct timespec *tp)
 Set the current time for the specified clock.
int sys_clock_nanosleep (int clock_id, int flags, const struct timespec *rqtp, struct timespec *rmtp)
 Sleep for the specified amount of time with respect to the specified clock.

Detailed Description

System clock APIs.

Declare variables used by both system timer device driver and kernel components that use timer functionality.

APIs for getting, setting, and sleeping with respect to system clocks.