X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fattiny%2Fao_clock.c;h=e5681edbc66858356370df185c08da9c1864a6ce;hb=4da8e047c4df06a0fec2c0cd47d26d5f1bef0e31;hp=b40f59d4cc36711ce8744cd1632b14440ee23c25;hpb=371da0c909098092db7b596496df9d58eed43703;p=fw%2Faltos diff --git a/src/attiny/ao_clock.c b/src/attiny/ao_clock.c index b40f59d4..e5681edb 100644 --- a/src/attiny/ao_clock.c +++ b/src/attiny/ao_clock.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -22,16 +23,15 @@ static volatile AO_TICK_TYPE ao_wakeup_count; ISR(TIMER1_COMPA_vect) { - PORTB ^= 2; ++ao_tick_count; - if ((int16_t) (ao_tick_count - ao_wakeup_count) >= 0) + if ((AO_TICK_SIGNED) (ao_tick_count - ao_wakeup_count) >= 0) ao_wakeup((void *) &ao_tick_count); } -uint16_t +AO_TICK_TYPE ao_time(void) { - uint16_t r; + AO_TICK_TYPE r; cli(); r = ao_tick_count; @@ -127,17 +127,17 @@ void ao_delay_us(uint16_t us) } void -ao_delay_until(uint16_t target) +ao_delay_until(AO_TICK_TYPE target) { cli(); ao_wakeup_count = target; - while ((int16_t) (target - ao_tick_count) > 0) + while ((AO_TICK_SIGNED) (target - ao_tick_count) > 0) ao_sleep((void *) &ao_tick_count); sei(); } void -ao_delay(uint16_t ticks) +ao_delay(AO_TICK_TYPE ticks) { ao_delay_until(ao_time() + ticks); }