18#ifndef XTIMER_TICK_CONVERSION_H
19#define XTIMER_TICK_CONVERSION_H
22#error "Do not include this file directly! Use xtimer.h instead"
32#if (XTIMER_SHIFT != 0)
33#if (XTIMER_HZ % 15625 != 0)
34#error XTIMER_HZ must be a multiple of 15625 (5^6) when using XTIMER_SHIFT
36#if (XTIMER_HZ > 1000000ul)
37#if (XTIMER_HZ != (1000000ul << XTIMER_SHIFT))
38#error XTIMER_HZ != (1000000ul << XTIMER_SHIFT)
42static inline uint32_t _xtimer_ticks_from_usec(uint32_t usec) {
46static inline uint64_t _xtimer_ticks_from_usec64(uint64_t usec) {
50static inline uint32_t _xtimer_usec_from_ticks(uint32_t ticks) {
54static inline uint64_t _xtimer_usec_from_ticks64(uint64_t ticks) {
59#if ((XTIMER_HZ << XTIMER_SHIFT) != 1000000ul)
60#error (XTIMER_HZ << XTIMER_SHIFT) != 1000000ul
64static inline uint32_t _xtimer_ticks_from_usec(uint32_t usec) {
68static inline uint64_t _xtimer_ticks_from_usec64(uint64_t usec) {
72static inline uint32_t _xtimer_usec_from_ticks(uint32_t ticks) {
76static inline uint64_t _xtimer_usec_from_ticks64(uint64_t ticks) {
80#elif (XTIMER_HZ == (1000000ul)) || defined(MODULE_XTIMER_ON_ZTIMER)
83static inline uint32_t _xtimer_usec_from_ticks(uint32_t ticks) {
87static inline uint64_t _xtimer_usec_from_ticks64(uint64_t ticks) {
91static inline uint32_t _xtimer_ticks_from_usec(uint32_t usec) {
95static inline uint64_t _xtimer_ticks_from_usec64(uint64_t usec) {
99#elif XTIMER_HZ == (32768ul)
104static inline uint32_t _xtimer_ticks_from_usec(uint32_t usec) {
108static inline uint64_t _xtimer_ticks_from_usec64(uint64_t usec) {
112static inline uint32_t _xtimer_usec_from_ticks(uint32_t ticks) {
115 uint64_t usec = (uint64_t)ticks * 15625ul;
119static inline uint64_t _xtimer_usec_from_ticks64(uint64_t ticks) {
121 uint64_t usec = (uint64_t)ticks * 15625ul;
127#if ((XTIMER_HZ % 15625) == 0)
128#error Unsupported hardware timer frequency (XTIMER_HZ), missing XTIMER_SHIFT in board.h? See xtimer.h documentation for more info
130#error Unknown hardware timer frequency (XTIMER_HZ), check board.h and/or add an implementation in sys/include/xtimer/tick_conversion.h
static uint32_t div_u32_by_15625div512(uint32_t val)
Divide val by (15625/512)
static uint64_t div_u64_by_15625div512(uint64_t val)
Divide val by (15625/512)
#define XTIMER_SHIFT
xtimer prescaler value