]>
git.gir.st - tmk_keyboard.git/blob - timer.c
2 Copyright 2011 Jun Wako <wakojun@gmail.com>
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include <avr/interrupt.h>
23 volatile uint16_t timer_count
= 0;
25 // Configure timer 0 to generate a timer overflow interrupt every
26 // 256*1024 clock cycles, or approx 61 Hz when using 16 MHz clock
27 // This demonstrates how to use interrupts to implement a simple
28 // inactivity timeout.
37 void timer_clear(void)
46 uint16_t timer_read(void)
59 uint16_t timer_elapsed(uint16_t last
)
68 return TIMER_DIFF(t
, last
);
71 // This interrupt routine is run approx 61 times per second.
72 // A very simple inactivity timeout is implemented, where we
73 // will send a space character and print a message to the
74 // hid_listen debug message window.