|
|
|
@ -113,7 +113,7 @@ void _xtimer_set64(xtimer_t *timer, uint32_t offset, uint32_t long_offset)
|
|
|
|
|
|
|
|
|
|
void xtimer_set(xtimer_t *timer, uint32_t offset) |
|
|
|
|
{ |
|
|
|
|
DEBUG("timer_set(): offset=%" PRIu32 " now=%" PRIu32 " (%" PRIu32 ")\n", offset, xtimer_now(), _xtimer_now()); |
|
|
|
|
DEBUG("timer_set(): offset=%" PRIu32 " now=%" PRIu32 " (%" PRIu32 ")\n", offset, xtimer_now(), _lltimer_now()); |
|
|
|
|
if (!timer->callback) { |
|
|
|
|
DEBUG("timer_set(): timer has no callback.\n"); |
|
|
|
|
return; |
|
|
|
@ -275,7 +275,7 @@ int xtimer_remove(xtimer_t *timer)
|
|
|
|
|
|
|
|
|
|
static uint32_t _time_left(uint32_t target, uint32_t reference) |
|
|
|
|
{ |
|
|
|
|
uint32_t now = _xtimer_now(); |
|
|
|
|
uint32_t now = _lltimer_now(); |
|
|
|
|
|
|
|
|
|
if (now < reference) { |
|
|
|
|
return 0; |
|
|
|
@ -438,14 +438,14 @@ static void _timer_callback(void)
|
|
|
|
|
|
|
|
|
|
/* make sure the timer counter also arrived
|
|
|
|
|
* in the next timer period */ |
|
|
|
|
while (_xtimer_now() == _lltimer_mask(0xFFFFFFFF)); |
|
|
|
|
while (_lltimer_now() == _lltimer_mask(0xFFFFFFFF)); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
/* we ended up in _timer_callback and there is
|
|
|
|
|
* a timer waiting. |
|
|
|
|
*/ |
|
|
|
|
/* set our period reference to the current time. */ |
|
|
|
|
reference = _xtimer_now(); |
|
|
|
|
reference = _lltimer_now(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
overflow: |
|
|
|
@ -472,7 +472,7 @@ overflow:
|
|
|
|
|
* time to overflow. In that case we advance to |
|
|
|
|
* next timer period and check again for expired |
|
|
|
|
* timers.*/ |
|
|
|
|
if (reference > _xtimer_now()) { |
|
|
|
|
if (reference > _lltimer_now()) { |
|
|
|
|
DEBUG("_timer_callback: overflowed while executing callbacks. %i\n", timer_list_head != 0); |
|
|
|
|
_next_period(); |
|
|
|
|
reference = 0; |
|
|
|
@ -484,7 +484,7 @@ overflow:
|
|
|
|
|
next_target = timer_list_head->target - XTIMER_OVERHEAD; |
|
|
|
|
|
|
|
|
|
/* make sure we're not setting a time in the past */ |
|
|
|
|
if (next_target < (_xtimer_now() + XTIMER_ISR_BACKOFF)) { |
|
|
|
|
if (next_target < (_lltimer_now() + XTIMER_ISR_BACKOFF)) { |
|
|
|
|
goto overflow; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -492,7 +492,7 @@ overflow:
|
|
|
|
|
/* there's no timer planned for this timer period */ |
|
|
|
|
/* schedule callback on next overflow */ |
|
|
|
|
next_target = _lltimer_mask(0xFFFFFFFF); |
|
|
|
|
uint32_t now = _xtimer_now(); |
|
|
|
|
uint32_t now = _lltimer_now(); |
|
|
|
|
|
|
|
|
|
/* check for overflow again */ |
|
|
|
|
if (now < reference) { |
|
|
|
@ -504,7 +504,7 @@ overflow:
|
|
|
|
|
/* check if the end of this period is very soon */ |
|
|
|
|
if (_lltimer_mask(now + XTIMER_ISR_BACKOFF) < now) { |
|
|
|
|
/* spin until next period, then advance */ |
|
|
|
|
while (_xtimer_now() >= now); |
|
|
|
|
while (_lltimer_now() >= now); |
|
|
|
|
_next_period(); |
|
|
|
|
reference = 0; |
|
|
|
|
goto overflow; |
|
|
|
|