X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fdrv%2Ftimer.c;h=4d1309466da6b37fb870ad244aa4f802df57f74a;hb=9d47a03d8251b57383a391325022b7890f463f09;hp=dfc27aefb53ccee74c8edaa141052e0b98010ee5;hpb=62c64455f33dd53639f04d35014ef5e50f9acd50;p=bertos.git diff --git a/bertos/drv/timer.c b/bertos/drv/timer.c index dfc27aef..4d130946 100644 --- a/bertos/drv/timer.c +++ b/bertos/drv/timer.c @@ -52,7 +52,7 @@ #include #include // cpu_relax() -#include // proc_decQuantun() +#include // proc_decQuantun() /* * Include platform-specific binding code if we're hosted. @@ -286,15 +286,10 @@ void timer_busyWait(hptime_t delay) hptime_t now, prev = timer_hw_hpread(); hptime_t delta; - for(;;) + for (;;) { now = timer_hw_hpread(); - /* - * We rely on hptime_t being unsigned here to - * reduce the modulo to an AND in the common - * case of TIMER_HW_CNT. - */ - delta = (now - prev) % TIMER_HW_CNT; + delta = (now < prev) ? (TIMER_HW_CNT - prev + now) : (now - prev); if (delta >= delay) break; delay -= delta; @@ -357,7 +352,7 @@ DEFINE_TIMER_ISR /* Perform hw IRQ handling */ timer_hw_irq(); - + TIMER_STROBE_OFF; }