xtimer: define XTIMER_RSHIFT() and XTIMER_LSHIFT() macros to avoid using XTIMER_SHIFT directly.

pr/gpio
Ian Martin 7 years ago
parent 4176d04b02
commit f86c118594

@ -342,6 +342,9 @@ int xtimer_msg_receive_timeout64(msg_t *msg, uint64_t us);
#define XTIMER_SHIFT (0)
#endif
#define XTIMER_RSHIFT(value) ( (value) >> XTIMER_SHIFT )
#define XTIMER_LSHIFT(value) ( (value) << XTIMER_SHIFT )
/**
* @brief set xtimer default timer configuration
* @{
@ -375,7 +378,7 @@ int xtimer_msg_receive_timeout64(msg_t *msg, uint64_t us);
*/
#define XTIMER_MASK (0)
#endif
#define XTIMER_MASK_SHIFTED (XTIMER_MASK << XTIMER_SHIFT)
#define XTIMER_MASK_SHIFTED XTIMER_LSHIFT(XTIMER_MASK)
#ifndef XTIMER_USLEEP_UNTIL_OVERHEAD
/**
@ -404,7 +407,7 @@ extern volatile uint32_t _high_cnt;
static inline uint32_t _lltimer_now(void)
{
#if XTIMER_SHIFT
return ((uint32_t)timer_read(XTIMER)) << XTIMER_SHIFT;
return XTIMER_LSHIFT((uint32_t)timer_read(XTIMER));
#else
return timer_read(XTIMER);
#endif
@ -452,7 +455,7 @@ static inline void xtimer_spin_until(uint32_t value);
/**
* @brief Minimal value xtimer_spin() can spin
*/
#define XTIMER_MIN_SPIN (1<<XTIMER_SHIFT)
#define XTIMER_MIN_SPIN XTIMER_LSHIFT(1)
#endif
static inline uint32_t xtimer_now(void)

@ -56,7 +56,7 @@ static inline int _is_set(xtimer_t *timer)
void xtimer_init(void)
{
/* initialize low-level timer */
timer_init(XTIMER, (1000000ul >> XTIMER_SHIFT), _periph_timer_callback, NULL);
timer_init(XTIMER, XTIMER_RSHIFT(1000000ul), _periph_timer_callback, NULL);
/* register initial overflow tick */
_lltimer_set(0xFFFFFFFF);
@ -150,7 +150,7 @@ static inline void _lltimer_set(uint32_t target)
}
DEBUG("_lltimer_set(): setting %" PRIu32 "\n", _lltimer_mask(target));
#ifdef XTIMER_SHIFT
target >>= XTIMER_SHIFT;
target = XTIMER_RSHIFT(target);
if (!target) {
target++;
}

Loading…
Cancel
Save