]>
cloudbase.mooo.com Git - z180-stamp.git/blob - avr/timer.c
2 * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
4 * SPDX-License-Identifier: GPL-2.0+
8 #include <avr/interrupt.h>
9 #include <util/atomic.h>
13 /* timer interrupt/overflow counter */
14 /* counts up every ms. */
19 * 1000Hz timer interrupt generated by OC3A
21 ISR(TIMER3_COMPA_vect
)
23 static int_fast8_t tick_10ms
;
24 static int_fast8_t tick_1s
;
27 extern void disk_timerproc(void);
35 /* Drive timer procedure of low level disk I/O module */
50 /*--------------------------------------------------------------------------*/
53 void timer_setup(void)
62 OCR1A
= F_CPU
/ 1000 - 1; // Timer1: 1000Hz interval (OC1A)
64 TIMSK1
= _BV(OCIE1A
); // Enable TC1.oca interrupt
68 /*--------------------------------------------------------------------------*/
70 uint32_t get_timer(uint32_t base
)
73 ATOMIC_BLOCK(ATOMIC_FORCEON
)