mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys/evtimer: make use of xtimer_left_usec()
This commit is contained in:
parent
c9c8c98a4b
commit
df520a70a7
@ -114,20 +114,9 @@ static void _update_timer(evtimer_t *evtimer)
|
||||
|
||||
static uint32_t _get_offset(xtimer_t *timer)
|
||||
{
|
||||
uint64_t now_us = xtimer_now_usec64();
|
||||
uint64_t start_us = _xtimer_usec_from_ticks64(
|
||||
((uint64_t)timer->long_start_time << 32) | timer->start_time);
|
||||
uint64_t target_us = start_us + _xtimer_usec_from_ticks64(
|
||||
((uint64_t)timer->long_offset) << 32 | timer->offset);
|
||||
|
||||
if (target_us <= now_us) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
target_us -= now_us;
|
||||
/* add half of 125 so integer division rounds to nearest */
|
||||
return div_u64_by_125((target_us >> 3) + 62);
|
||||
}
|
||||
uint64_t left = xtimer_left_usec(timer);
|
||||
/* add half of 125 so integer division rounds to nearest */
|
||||
return div_u64_by_125((left >> 3) + 62);
|
||||
}
|
||||
|
||||
static void _update_head_offset(evtimer_t *evtimer)
|
||||
|
Loading…
Reference in New Issue
Block a user