X-Git-Url: http://dolda2000.com/gitweb/?p=kokare.git;a=blobdiff_plain;f=kokare.c;fp=kokare.c;h=38662bbd287dbf6ce0dfba6f3abd6312b440cf6e;hp=8d151dfab08f9705bac3276a2500f83ff31a56e4;hb=41fabc21b8fb8b1a3b9bf65fb2d6d91bf4ce7892;hpb=cd17a21182462dcb2944ea2fe23ee3b833e4dae2 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)