Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
timer_convert.c File Reference
#include <ztest.h>
#include <zephyr/types.h>
#include <sys/time_units.h>
#include <random/rand32.h>

Data Structures

struct  test_rec
 

Macros

#define NUM_RANDOM   100
 
#define TESTREC(src, dst, round, prec)
 

Enumerations

enum  units {
  UNIT_ticks , UNIT_cyc , UNIT_ms , UNIT_us ,
  UNIT_ns
}
 
enum  round { ROUND_floor , ROUND_ceil , ROUND_near }
 

Functions

uint32_t get_hz (enum units u)
 
void test_conversion (struct test_rec *t, uint64_t val)
 
void test_time_conversions (void)
 

Variables

static const char *const round_s []
 
static struct test_rec tests []
 

Macro Definition Documentation

◆ NUM_RANDOM

#define NUM_RANDOM   100

◆ TESTREC

#define TESTREC (   src,
  dst,
  round,
  prec 
)
Value:
{ \
UNIT_##src, UNIT_##dst, prec, ROUND_##round, \
(void *)k_##src##_to_##dst##_##round##prec \
} \
round
Definition: timer_convert.c:15

Enumeration Type Documentation

◆ round

enum round
Enumerator
ROUND_floor 
ROUND_ceil 
ROUND_near 

◆ units

enum units
Enumerator
UNIT_ticks 
UNIT_cyc 
UNIT_ms 
UNIT_us 
UNIT_ns 

Function Documentation

◆ get_hz()

uint32_t get_hz ( enum units  u)

◆ test_conversion()

void test_conversion ( struct test_rec t,
uint64_t  val 
)

◆ test_time_conversions()

void test_time_conversions ( void  )

Variable Documentation

◆ round_s

const char* const round_s[]
static
Initial value:
= {
[ROUND_floor] = "floor",
[ROUND_ceil] = "ceil",
[ROUND_near] = "near",
}
@ ROUND_ceil
Definition: timer_convert.c:15
@ ROUND_near
Definition: timer_convert.c:15
@ ROUND_floor
Definition: timer_convert.c:15

◆ tests

struct test_rec tests[]
static
Initial value:
= {
}
static uint32_t k_ms_to_cyc_floor32(uint32_t t)
Convert milliseconds to hardware cycles.
Definition: time_units.h:215
static uint64_t k_cyc_to_ns_near64(uint64_t t)
Convert hardware cycles to nanoseconds.
Definition: time_units.h:929
static uint64_t k_ticks_to_ns_floor64(uint64_t t)
Convert ticks to nanoseconds.
Definition: time_units.h:1237
static uint64_t k_ms_to_cyc_near64(uint64_t t)
Convert milliseconds to hardware cycles.
Definition: time_units.h:257
static uint64_t k_ms_to_cyc_ceil64(uint64_t t)
Convert milliseconds to hardware cycles.
Definition: time_units.h:285
static uint32_t k_ticks_to_ms_near32(uint32_t t)
Convert ticks to milliseconds.
Definition: time_units.h:1083
static uint32_t k_ns_to_cyc_floor32(uint32_t t)
Convert nanoseconds to hardware cycles.
Definition: time_units.h:551
static uint32_t k_ticks_to_ns_near32(uint32_t t)
Convert ticks to nanoseconds.
Definition: time_units.h:1251
static uint32_t k_us_to_ticks_near32(uint32_t t)
Convert microseconds to ticks.
Definition: time_units.h:495
static uint32_t k_ns_to_ticks_floor32(uint32_t t)
Convert nanoseconds to ticks.
Definition: time_units.h:635
static uint64_t k_ns_to_ticks_ceil64(uint64_t t)
Convert nanoseconds to ticks.
Definition: time_units.h:705
static uint64_t k_cyc_to_ticks_floor64(uint64_t t)
Convert hardware cycles to ticks.
Definition: time_units.h:985
static uint64_t k_ticks_to_ns_near64(uint64_t t)
Convert ticks to nanoseconds.
Definition: time_units.h:1265
static uint64_t k_cyc_to_ms_floor64(uint64_t t)
Convert hardware cycles to milliseconds.
Definition: time_units.h:733
static uint64_t k_us_to_cyc_ceil64(uint64_t t)
Convert microseconds to hardware cycles.
Definition: time_units.h:453
static uint64_t k_ns_to_cyc_floor64(uint64_t t)
Convert nanoseconds to hardware cycles.
Definition: time_units.h:565
static uint64_t k_us_to_ticks_floor64(uint64_t t)
Convert microseconds to ticks.
Definition: time_units.h:481
static uint32_t k_cyc_to_us_ceil32(uint32_t t)
Convert hardware cycles to microseconds.
Definition: time_units.h:859
static uint32_t k_cyc_to_ns_floor32(uint32_t t)
Convert hardware cycles to nanoseconds.
Definition: time_units.h:887
static uint64_t k_ms_to_ticks_floor64(uint64_t t)
Convert milliseconds to ticks.
Definition: time_units.h:313
static uint64_t k_cyc_to_ms_ceil64(uint64_t t)
Convert hardware cycles to milliseconds.
Definition: time_units.h:789
static uint32_t k_us_to_cyc_ceil32(uint32_t t)
Convert microseconds to hardware cycles.
Definition: time_units.h:439
static uint32_t k_ticks_to_ms_ceil32(uint32_t t)
Convert ticks to milliseconds.
Definition: time_units.h:1111
static uint32_t k_ticks_to_cyc_floor32(uint32_t t)
Convert ticks to hardware cycles.
Definition: time_units.h:1307
static uint64_t k_ticks_to_cyc_ceil64(uint64_t t)
Convert ticks to hardware cycles.
Definition: time_units.h:1377
static uint32_t k_us_to_ticks_floor32(uint32_t t)
Convert microseconds to ticks.
Definition: time_units.h:467
static uint32_t k_ns_to_ticks_near32(uint32_t t)
Convert nanoseconds to ticks.
Definition: time_units.h:663
static uint64_t k_ns_to_ticks_floor64(uint64_t t)
Convert nanoseconds to ticks.
Definition: time_units.h:649
static uint64_t k_ms_to_ticks_near64(uint64_t t)
Convert milliseconds to ticks.
Definition: time_units.h:341
static uint32_t k_ticks_to_ns_ceil32(uint32_t t)
Convert ticks to nanoseconds.
Definition: time_units.h:1279
static uint64_t k_us_to_cyc_near64(uint64_t t)
Convert microseconds to hardware cycles.
Definition: time_units.h:425
static uint32_t k_ns_to_cyc_near32(uint32_t t)
Convert nanoseconds to hardware cycles.
Definition: time_units.h:579
static uint64_t k_us_to_cyc_floor64(uint64_t t)
Convert microseconds to hardware cycles.
Definition: time_units.h:397
static uint32_t k_ticks_to_ns_floor32(uint32_t t)
Convert ticks to nanoseconds.
Definition: time_units.h:1223
static uint64_t k_cyc_to_ms_near64(uint64_t t)
Convert hardware cycles to milliseconds.
Definition: time_units.h:761
static uint32_t k_us_to_cyc_near32(uint32_t t)
Convert microseconds to hardware cycles.
Definition: time_units.h:411
static uint64_t k_ticks_to_ms_floor64(uint64_t t)
Convert ticks to milliseconds.
Definition: time_units.h:1069
static uint32_t k_ns_to_ticks_ceil32(uint32_t t)
Convert nanoseconds to ticks.
Definition: time_units.h:691
static uint32_t k_cyc_to_ms_near32(uint32_t t)
Convert hardware cycles to milliseconds.
Definition: time_units.h:747
static uint32_t k_cyc_to_ms_ceil32(uint32_t t)
Convert hardware cycles to milliseconds.
Definition: time_units.h:775
static uint64_t k_ns_to_ticks_near64(uint64_t t)
Convert nanoseconds to ticks.
Definition: time_units.h:677
static uint64_t k_ticks_to_us_near64(uint64_t t)
Convert ticks to microseconds.
Definition: time_units.h:1181
static uint32_t k_cyc_to_ticks_ceil32(uint32_t t)
Convert hardware cycles to ticks.
Definition: time_units.h:1027
static uint64_t k_ns_to_cyc_ceil64(uint64_t t)
Convert nanoseconds to hardware cycles.
Definition: time_units.h:621
static uint32_t k_ms_to_cyc_ceil32(uint32_t t)
Convert milliseconds to hardware cycles.
Definition: time_units.h:271
static uint32_t k_ticks_to_ms_floor32(uint32_t t)
Convert ticks to milliseconds.
Definition: time_units.h:1055
static uint32_t k_ms_to_ticks_floor32(uint32_t t)
Convert milliseconds to ticks.
Definition: time_units.h:299
static uint64_t k_cyc_to_ticks_near64(uint64_t t)
Convert hardware cycles to ticks.
Definition: time_units.h:1013
static uint64_t k_ticks_to_us_floor64(uint64_t t)
Convert ticks to microseconds.
Definition: time_units.h:1153
static uint64_t k_cyc_to_ns_floor64(uint64_t t)
Convert hardware cycles to nanoseconds.
Definition: time_units.h:901
static uint32_t k_cyc_to_ns_ceil32(uint32_t t)
Convert hardware cycles to nanoseconds.
Definition: time_units.h:943
static uint32_t k_cyc_to_us_floor32(uint32_t t)
Convert hardware cycles to microseconds.
Definition: time_units.h:803
static uint64_t k_cyc_to_us_floor64(uint64_t t)
Convert hardware cycles to microseconds.
Definition: time_units.h:817
static uint32_t k_us_to_cyc_floor32(uint32_t t)
Convert microseconds to hardware cycles.
Definition: time_units.h:383
static uint64_t k_ms_to_ticks_ceil64(uint64_t t)
Convert milliseconds to ticks.
Definition: time_units.h:369
static uint32_t k_us_to_ticks_ceil32(uint32_t t)
Convert microseconds to ticks.
Definition: time_units.h:523
static uint32_t k_ticks_to_us_near32(uint32_t t)
Convert ticks to microseconds.
Definition: time_units.h:1167
static uint32_t k_cyc_to_ticks_floor32(uint32_t t)
Convert hardware cycles to ticks.
Definition: time_units.h:971
static uint32_t k_ticks_to_us_ceil32(uint32_t t)
Convert ticks to microseconds.
Definition: time_units.h:1195
static uint32_t k_ms_to_ticks_near32(uint32_t t)
Convert milliseconds to ticks.
Definition: time_units.h:327
static uint64_t k_cyc_to_ns_ceil64(uint64_t t)
Convert hardware cycles to nanoseconds.
Definition: time_units.h:957
static uint32_t k_ns_to_cyc_ceil32(uint32_t t)
Convert nanoseconds to hardware cycles.
Definition: time_units.h:607
static uint32_t k_ticks_to_cyc_ceil32(uint32_t t)
Convert ticks to hardware cycles.
Definition: time_units.h:1363
static uint64_t k_cyc_to_us_ceil64(uint64_t t)
Convert hardware cycles to microseconds.
Definition: time_units.h:873
static uint32_t k_ms_to_cyc_near32(uint32_t t)
Convert milliseconds to hardware cycles.
Definition: time_units.h:243
static uint32_t k_ticks_to_us_floor32(uint32_t t)
Convert ticks to microseconds.
Definition: time_units.h:1139
static uint32_t k_cyc_to_ms_floor32(uint32_t t)
Convert hardware cycles to milliseconds.
Definition: time_units.h:719
static uint64_t k_ticks_to_ms_near64(uint64_t t)
Convert ticks to milliseconds.
Definition: time_units.h:1097
static uint64_t k_ticks_to_us_ceil64(uint64_t t)
Convert ticks to microseconds.
Definition: time_units.h:1209
static uint64_t k_us_to_ticks_near64(uint64_t t)
Convert microseconds to ticks.
Definition: time_units.h:509
static uint32_t k_cyc_to_ns_near32(uint32_t t)
Convert hardware cycles to nanoseconds.
Definition: time_units.h:915
static uint32_t k_ticks_to_cyc_near32(uint32_t t)
Convert ticks to hardware cycles.
Definition: time_units.h:1335
static uint64_t k_cyc_to_ticks_ceil64(uint64_t t)
Convert hardware cycles to ticks.
Definition: time_units.h:1041
static uint32_t k_ms_to_ticks_ceil32(uint32_t t)
Convert milliseconds to ticks.
Definition: time_units.h:355
static uint64_t k_ticks_to_ms_ceil64(uint64_t t)
Convert ticks to milliseconds.
Definition: time_units.h:1125
static uint64_t k_ticks_to_cyc_floor64(uint64_t t)
Convert ticks to hardware cycles.
Definition: time_units.h:1321
static uint64_t k_cyc_to_us_near64(uint64_t t)
Convert hardware cycles to microseconds.
Definition: time_units.h:845
static uint64_t k_ticks_to_cyc_near64(uint64_t t)
Convert ticks to hardware cycles.
Definition: time_units.h:1349
static uint64_t k_ms_to_cyc_floor64(uint64_t t)
Convert milliseconds to hardware cycles.
Definition: time_units.h:229
static uint64_t k_ticks_to_ns_ceil64(uint64_t t)
Convert ticks to nanoseconds.
Definition: time_units.h:1293
static uint32_t k_cyc_to_ticks_near32(uint32_t t)
Convert hardware cycles to ticks.
Definition: time_units.h:999
static uint64_t k_ns_to_cyc_near64(uint64_t t)
Convert nanoseconds to hardware cycles.
Definition: time_units.h:593
static uint64_t k_us_to_ticks_ceil64(uint64_t t)
Convert microseconds to ticks.
Definition: time_units.h:537
static uint32_t k_cyc_to_us_near32(uint32_t t)
Convert hardware cycles to microseconds.
Definition: time_units.h:831
@ UNIT_cyc
Definition: timer_convert.c:13
@ UNIT_ticks
Definition: timer_convert.c:13
@ UNIT_ms
Definition: timer_convert.c:13
@ UNIT_us
Definition: timer_convert.c:13
@ UNIT_ns
Definition: timer_convert.c:13