]>
cloudbase.mooo.com Git - z180-stamp.git/blob - avr/timer.c
e222e68792fa8d89527c9942b91cb638cbeae81f
5 #include <avr/interrupt.h>
6 #include <util/atomic.h>
10 /* timer interrupt/overflow counter */
11 /* counts up every ms. */
15 /*---------------------------------------------------------*/
16 /* 1000Hz timer interrupt generated by OC3A */
17 /*---------------------------------------------------------*/
19 ISR(TIMER3_COMPA_vect
)
21 static int_fast8_t tick_10ms
;
22 static int_fast8_t tick_1s
;
25 extern void disk_timerproc(void);
33 /* Drive timer procedure of low level disk I/O module */
48 /*--------------------------------------------------------------------------*/
51 void timer_setup(void)
60 OCR1A
= F_CPU
/ 1000 - 1; // Timer1: 1000Hz interval (OC1A)
62 TIMSK1
= _BV(OCIE1A
); // Enable TC1.oca interrupt
66 /*--------------------------------------------------------------------------*/
68 uint32_t get_timer(uint32_t base
)
71 ATOMIC_BLOCK(ATOMIC_FORCEON
)