Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
sys_clock.h File Reference

Variables needed for system clock. More...

#include <zephyr/sys/util.h>
#include <zephyr/sys/dlist.h>
#include <zephyr/toolchain.h>
#include <zephyr/types.h>
#include <zephyr/sys/time_units.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)   ((a).ticks == (b).ticks)
 Compare timeouts for equality.
 
#define NSEC_PER_USEC   1000U
 number of nanoseconds per micorsecond
 
#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 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)    (uint32_t)(k_cyc_to_ns_floor64(X) / NCYCLES)
 SYS_CLOCK_HW_CYCLES_TO_NS_AVG converts CPU clock cycles to nanoseconds and calculates the average cycle time.
 

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 uint64_t sys_clock_timeout_end_calc (k_timeout_t timeout)
 Provided for backward compatibility.
 
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.
 

Detailed Description

Variables needed for system clock.

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