23#include "nimble/porting/nimble/include/os/os_cputime.h"
30#define USECS_PER_TICK ((1000000 + MYNEWT_VAL(OS_CPUTIME_FREQ) - 1) / \
31 MYNEWT_VAL(OS_CPUTIME_FREQ))
33#define LL_TMR_LT(_t1, _t2) ((int32_t)((_t1) - (_t2)) < 0)
34#define LL_TMR_GT(_t1, _t2) ((int32_t)((_t1) - (_t2)) > 0)
35#define LL_TMR_GEQ(_t1, _t2) ((int32_t)((_t1) - (_t2)) >= 0)
36#define LL_TMR_LEQ(_t1, _t2) ((int32_t)((_t1) - (_t2)) <= 0)
38typedef void (ble_ll_tmr_cb)(
void *arg);
51ble_ll_tmr_t2u(uint32_t ticks)
53#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 31250
61ble_ll_tmr_u2t(uint32_t usecs)
63#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 31250
66#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
68 return (usecs * 137439) / 4194304;
76ble_ll_tmr_u2t_up(uint32_t usecs)
78 return ble_ll_tmr_u2t(usecs + (USECS_PER_TICK - 1));
82ble_ll_tmr_u2t_r(uint32_t usecs, uint8_t *rem_us)
86 ticks = ble_ll_tmr_u2t(usecs);
87 *rem_us = usecs - ble_ll_tmr_t2u(ticks);
88 if (*rem_us == USECS_PER_TICK) {
97ble_ll_tmr_add(uint32_t *ticks, uint8_t *rem_us, uint32_t usecs)
102 t_ticks = ble_ll_tmr_u2t_r(usecs, &t_rem_us);
106 if (*rem_us >= USECS_PER_TICK) {
107 *rem_us -= USECS_PER_TICK;
113ble_ll_tmr_add_u(uint32_t *ticks, uint8_t *rem_us, uint8_t usecs)
115 BLE_LL_ASSERT(usecs < USECS_PER_TICK);
118 if (*rem_us >= USECS_PER_TICK) {
119 *rem_us -= USECS_PER_TICK;
125ble_ll_tmr_sub(uint32_t *ticks, uint8_t *rem_us, uint32_t usecs)
130 if (usecs <= *rem_us) {
138 t_ticks = ble_ll_tmr_u2t_r(usecs, &t_rem_us);
141 *rem_us = USECS_PER_TICK - t_rem_us;
148ble_ll_tmr_init(
struct ble_ll_tmr *tmr, ble_ll_tmr_cb *cb,
void *arg)
154ble_ll_tmr_start(
struct ble_ll_tmr *tmr, uint32_t tgt)
160ble_ll_tmr_stop(
struct ble_ll_tmr *tmr)
uint32_t os_cputime_ticks_to_usecs(uint32_t ticks)
int os_cputime_timer_start(struct hal_timer *timer, uint32_t cputime)
Definition os_cputime.c:90
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
uint32_t os_cputime_get32(void)
Definition os_cputime.c:119
Definition hal_timer.h:51