mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys/xtimer: eliminate XTIMER_SHIFT_ON_COMPARE
This commit is contained in:
parent
4f3a40fb74
commit
963f8a495d
@ -34,7 +34,6 @@
|
||||
#define XTIMER (0)
|
||||
#define XTIMER_CHAN (0)
|
||||
#define XTIMER_MASK (0xff000000)
|
||||
#define XTIMER_SHIFT_ON_COMPARE (2)
|
||||
#define XTIMER_BACKOFF (40)
|
||||
/** @} */
|
||||
|
||||
|
@ -53,7 +53,6 @@ extern "C" {
|
||||
*/
|
||||
#define XTIMER_MASK (0xffff0000)
|
||||
#define XTIMER_SHIFT (2)
|
||||
#define XTIMER_SHIFT_ON_COMPARE (8)
|
||||
#define XTIMER_BACKOFF (40)
|
||||
/** @} */
|
||||
|
||||
|
@ -41,7 +41,6 @@ extern "C" {
|
||||
#define XTIMER (0)
|
||||
#define XTIMER_CHAN (0)
|
||||
#define XTIMER_MASK (0xffff0000)
|
||||
#define XTIMER_SHIFT_ON_COMPARE (4)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
|
@ -40,7 +40,6 @@ extern "C" {
|
||||
#define XTIMER (0)
|
||||
#define XTIMER_CHAN (0)
|
||||
#define XTIMER_MASK (0xffff0000)
|
||||
#define XTIMER_SHIFT_ON_COMPARE (4)
|
||||
#define XTIMER_BACKOFF (40)
|
||||
/** @} */
|
||||
|
||||
|
@ -35,7 +35,6 @@ extern "C" {
|
||||
#define XTIMER (0)
|
||||
#define XTIMER_CHAN (0)
|
||||
#define XTIMER_MASK (0xff000000)
|
||||
#define XTIMER_SHIFT_ON_COMPARE (2)
|
||||
#define XTIMER_BACKOFF (40)
|
||||
/** @} */
|
||||
|
||||
|
@ -35,7 +35,6 @@ extern "C" {
|
||||
#define XTIMER (0)
|
||||
#define XTIMER_CHAN (0)
|
||||
#define XTIMER_MASK (0xff000000)
|
||||
#define XTIMER_SHIFT_ON_COMPARE (2)
|
||||
#define XTIMER_BACKOFF (40)
|
||||
/** @} */
|
||||
|
||||
|
@ -35,7 +35,6 @@ extern "C" {
|
||||
#define XTIMER (0)
|
||||
#define XTIMER_CHAN (0)
|
||||
#define XTIMER_MASK (0xff000000)
|
||||
#define XTIMER_SHIFT_ON_COMPARE (2)
|
||||
#define XTIMER_BACKOFF (40)
|
||||
/** @} */
|
||||
|
||||
|
@ -57,7 +57,6 @@ extern "C" {
|
||||
#define XTIMER (0)
|
||||
#define XTIMER_CHAN (0)
|
||||
#define XTIMER_MASK (0xffff0000)
|
||||
#define XTIMER_SHIFT_ON_COMPARE (4)
|
||||
#define XTIMER_BACKOFF (40)
|
||||
/** @} */
|
||||
|
||||
|
@ -40,7 +40,6 @@ extern "C" {
|
||||
#define XTIMER (0)
|
||||
#define XTIMER_CHAN (0)
|
||||
#define XTIMER_MASK (0xffff0000)
|
||||
#define XTIMER_SHIFT_ON_COMPARE (4)
|
||||
#define XTIMER_BACKOFF (40)
|
||||
/** @} */
|
||||
|
||||
|
@ -34,7 +34,6 @@ extern "C" {
|
||||
#define XTIMER (0)
|
||||
#define XTIMER_CHAN (0)
|
||||
#define XTIMER_MASK (0xff000000)
|
||||
#define XTIMER_SHIFT_ON_COMPARE (2)
|
||||
#define XTIMER_BACKOFF (40)
|
||||
/** @} */
|
||||
|
||||
|
@ -51,7 +51,6 @@ extern "C" {
|
||||
#define XTIMER (0)
|
||||
#define XTIMER_CHAN (0)
|
||||
#define XTIMER_MASK (0xffff0000)
|
||||
#define XTIMER_SHIFT_ON_COMPARE (4)
|
||||
#define XTIMER_BACKOFF (40)
|
||||
/** @} */
|
||||
|
||||
|
@ -432,25 +432,6 @@ void _xtimer_sleep(uint32_t offset, uint32_t long_offset);
|
||||
static inline void xtimer_spin_until(uint32_t value);
|
||||
/** @} */
|
||||
|
||||
#if XTIMER_MASK
|
||||
#ifndef XTIMER_SHIFT_ON_COMPARE
|
||||
/**
|
||||
* @brief ignore some bits when comparing timer values
|
||||
*
|
||||
* (only relevant when XTIMER_MASK != 0, e.g., timers < 32bit.)
|
||||
*
|
||||
* When combining _lltimer_now() and _high_cnt, we have to get the same value in
|
||||
* order to work around a race between overflowing _lltimer_now() and OR'ing the
|
||||
* resulting values.
|
||||
* But some platforms are too slow to get the same timer
|
||||
* value twice, so we use this define to ignore some of the bits.
|
||||
*
|
||||
* Use tests/xtimer_shift_on_compare to find the correct value for your MCU.
|
||||
*/
|
||||
#define XTIMER_SHIFT_ON_COMPARE (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef XTIMER_MIN_SPIN
|
||||
/**
|
||||
* @brief Minimal value xtimer_spin() can spin
|
||||
@ -461,12 +442,18 @@ static inline void xtimer_spin_until(uint32_t value);
|
||||
static inline uint32_t xtimer_now(void)
|
||||
{
|
||||
#if XTIMER_MASK
|
||||
uint32_t a, b;
|
||||
uint32_t latched_high_cnt, now;
|
||||
|
||||
/* _high_cnt can change at any time, so check the value before
|
||||
* and after reading the low-level timer. If it hasn't changed,
|
||||
* then it can be safely applied to the timer count. */
|
||||
|
||||
do {
|
||||
a = _lltimer_now() | _high_cnt;
|
||||
b = _lltimer_now() | _high_cnt;
|
||||
} while ((a >> XTIMER_SHIFT_ON_COMPARE) != (b >> XTIMER_SHIFT_ON_COMPARE));
|
||||
return b;
|
||||
latched_high_cnt = _high_cnt;
|
||||
now = _lltimer_now();
|
||||
} while (_high_cnt != latched_high_cnt);
|
||||
|
||||
return latched_high_cnt | now;
|
||||
#else
|
||||
return _lltimer_now();
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user