From 41fabc21b8fb8b1a3b9bf65fb2d6d91bf4ce7892 Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Wed, 4 Jul 2007 15:19:44 +0000 Subject: [PATCH] Use only one version of getticks. --- kokare.c | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/kokare.c b/kokare.c index 8d151df..38662bb 100644 --- a/kokare.c +++ b/kokare.c @@ -147,36 +147,18 @@ void disphex(unsigned char num) dsp[1] = font[num & 0x0f]; } -/* - * This version is used outside interrupts. - * It spins until no overflow has happened. - */ unsigned long getticks(void) { uint16_t v; unsigned long r; - do { - v = oticks; - r = TCNT1 + (((unsigned long)oticks) << 16); - } while(v != oticks); - return(r); -} - -/* - * This version is used in interrupts - */ -unsigned long getticks2(void) -{ - uint16_t v; - unsigned long r; - + cli(); v = TCNT1; r = v + (((unsigned long)oticks) << 16); if((TIFR1 & 0x01) && !(v & 0x8000)) - return(r + 0x10000); - else - return(r); + r += 0x10000; + sei(); + return(r); } void ledcycle(void) @@ -475,7 +457,7 @@ ISR(SIG_INTERRUPT1) { unsigned long now; - now = getticks2(); + now = getticks(); if(tstate == 0) { tstate = 1; if(tlock != 2) -- 2.11.0