X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp.git/blobdiff_plain/7f552300815ccadd45ebb3e7f0ae72a3b2e0c4e5..5f7f3586b0444116d5c1340465ecae8d6daa2461:/avr/timer.c diff --git a/avr/timer.c b/avr/timer.c index 6fb19a8..f45f267 100644 --- a/avr/timer.c +++ b/avr/timer.c @@ -1,29 +1,28 @@ /* + * (C) Copyright 2014 Leo C. + * + * SPDX-License-Identifier: GPL-2.0+ */ - #include "common.h" - #include #include - -//#include - - +#include "time.h" #include "timer.h" /* timer interrupt/overflow counter */ -volatile uint32_t timestamp; - - -/*---------------------------------------------------------*/ -/* 1000Hz timer interrupt generated by OC3A */ -/*---------------------------------------------------------*/ +/* counts up every ms. */ +static volatile +uint32_t timestamp; +/* + * 1000Hz timer interrupt generated by OC3A + */ ISR(TIMER3_COMPA_vect) { static int_fast8_t tick_10ms; - int_fast8_t i; + static int_fast8_t tick_1s; + int_fast8_t i, j; extern void disk_timerproc(void); @@ -31,33 +30,25 @@ ISR(TIMER3_COMPA_vect) i = tick_10ms + 1; if (i == 10) { - i = 0; Stat |= S_10MS_TO; /* Drive timer procedure of low level disk I/O module */ disk_timerproc(); + + j = tick_1s - 1; + if (j == 0) { + system_tick(); + j = 100; + } + tick_1s = j; + i = 0; } tick_10ms = i; - } - /*--------------------------------------------------------------------------*/ -#if 0 - -void do_10ms(void) -{ - if (to_counter) - to_counter--; -} - -#endif - -/*--------------------------------------------------------------------------*/ - - #if 0 void timer_setup(void) { @@ -74,10 +65,11 @@ void timer_setup(void) } #endif +/*--------------------------------------------------------------------------*/ + uint32_t get_timer(uint32_t base) { uint32_t ret; - ATOMIC_BLOCK(ATOMIC_FORCEON) { ret = timestamp;