]>
cloudbase.mooo.com Git - z180-stamp.git/blob - avr/timer.c
56c7bedd5d0609f548c762cdff549e19e8046e2b
7 //#include <avr/power.h>
8 //#include <avr/pgmspace.h>
9 #include <avr/interrupt.h>
10 #include <util/atomic.h>
17 /* timer interrupt/overflow counter */
18 volatile uint32_t timestamp
;
21 /*---------------------------------------------------------*/
22 /* 1000Hz timer interrupt generated by OC2A */
23 /*---------------------------------------------------------*/
25 ISR(TIMER2_COMPA_vect
)
27 static int_fast8_t tick_10ms
;
38 /* Drive timer procedure of low level disk I/O module */
47 /*--------------------------------------------------------------------------*/
59 /*--------------------------------------------------------------------------*/
63 void timer_setup(void)
72 OCR1A
= F_CPU
/ 1000 - 1; // Timer1: 1000Hz interval (OC1A)
74 TIMSK1
= _BV(OCIE1A
); // Enable TC1.oca interrupt
78 uint32_t get_timer(uint32_t base
)
82 ATOMIC_BLOCK(ATOMIC_FORCEON
)