34#include "../syscfg/syscfg.h"
35#include "../hal/hal_timer.h"
46#if (MYNEWT_VAL(OS_CPUTIME_FREQ) == 1000000)
48#define OS_CPUTIME_FREQ_1MHZ
50#elif MYNEWT_VAL(OS_CPUTIME_FREQ) == 256 || \
51 MYNEWT_VAL(OS_CPUTIME_FREQ) == 512 || \
52 MYNEWT_VAL(OS_CPUTIME_FREQ) == 1024 || \
53 MYNEWT_VAL(OS_CPUTIME_FREQ) == 2048 || \
54 MYNEWT_VAL(OS_CPUTIME_FREQ) == 4096 || \
55 MYNEWT_VAL(OS_CPUTIME_FREQ) == 8192 || \
56 MYNEWT_VAL(OS_CPUTIME_FREQ) == 16384 || \
57 MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768 || \
58 MYNEWT_VAL(OS_CPUTIME_FREQ) == 32000 || \
59 MYNEWT_VAL(OS_CPUTIME_FREQ) == 65536 || \
60 MYNEWT_VAL(OS_CPUTIME_FREQ) == 131072 || \
61 MYNEWT_VAL(OS_CPUTIME_FREQ) == 262144 || \
62 MYNEWT_VAL(OS_CPUTIME_FREQ) == 524288
64#define OS_CPUTIME_FREQ_PWR2
66#elif MYNEWT_VAL(OS_CPUTIME_FREQ) > 1000000
68#define OS_CPUTIME_FREQ_HIGH
72#error "Invalid OS_CPUTIME_FREQ value. Value must be one of a) a power of 2" \
73 ">= 256Hz, or b) any value >= 1MHz"
77#if defined(OS_CPUTIME_FREQ_HIGH)
81 uint32_t ticks_per_usec;
83extern struct os_cputime_data g_os_cputime;
88#define CPUTIME_LT(__t1, __t2) ((int32_t) ((__t1) - (__t2)) < 0)
90#define CPUTIME_GT(__t1, __t2) ((int32_t) ((__t1) - (__t2)) > 0)
92#define CPUTIME_GEQ(__t1, __t2) ((int32_t) ((__t1) - (__t2)) >= 0)
94#define CPUTIME_LEQ(__t1, __t2) ((int32_t) ((__t1) - (__t2)) <= 0)
114#if !defined(OS_CPUTIME_FREQ_PWR2)
145#if defined(OS_CPUTIME_FREQ_1MHZ)
146#define os_cputime_usecs_to_ticks(x) (x)
147#define os_cputime_ticks_to_usecs(x) (x)
int os_cputime_timer_relative(struct hal_timer *timer, uint32_t usecs)
Definition os_cputime.c:99
uint32_t os_cputime_ticks_to_usecs(uint32_t ticks)
void os_cputime_delay_usecs(uint32_t usecs)
Definition os_cputime.c:72
int os_cputime_init(uint32_t clock_freq)
Definition os_cputime.c:32
int os_cputime_timer_start(struct hal_timer *timer, uint32_t cputime)
Definition os_cputime.c:90
uint32_t os_cputime_ticks_to_nsecs(uint32_t ticks)
void os_cputime_timer_stop(struct hal_timer *timer)
Definition os_cputime.c:113
uint32_t os_cputime_usecs_to_ticks(uint32_t usecs)
void os_cputime_timer_init(struct hal_timer *timer, hal_timer_cb fp, void *arg)
Definition os_cputime.c:81
void os_cputime_delay_nsecs(uint32_t nsecs)
Definition os_cputime.c:62
void os_cputime_delay_ticks(uint32_t ticks)
Definition os_cputime.c:50
uint32_t os_cputime_nsecs_to_ticks(uint32_t nsecs)
uint32_t os_cputime_get32(void)
Definition os_cputime.c:119
Definition hal_timer.h:51