summaryrefslogtreecommitdiff
path: root/timer.c
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2011-01-29 00:44:05 +0900
committertmk <nobody@nowhere>2011-02-22 03:08:49 +0900
commit4f5f1a53d449172263e83c5769c92976e0d3332e (patch)
tree53c87958a30812cd548d83768c1348680e224c3d /timer.c
parentc07408a44784c0fdbca33567926a2c0aa4e8e17e (diff)
added PS/2 to USB converter use V-USB as protocol stack
Diffstat (limited to 'timer.c')
-rw-r--r--timer.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/timer.c b/timer.c
index 23663042c7..21dda523c1 100644
--- a/timer.c
+++ b/timer.c
@@ -3,7 +3,7 @@
#include <stdint.h>
#include "timer.h"
-uint16_t timer_count = 0;
+volatile uint16_t timer_count = 0;
// Configure timer 0 to generate a timer overflow interrupt every
// 256*1024 clock cycles, or approx 61 Hz when using 16 MHz clock
@@ -19,20 +19,21 @@ void timer_init(void)
inline
void timer_clear(void)
{
+ uint8_t sreg = SREG;
cli();
timer_count = 0;
- sei();
+ SREG = sreg;
}
inline
uint16_t timer_read(void)
{
- uint8_t _sreg = SREG;
uint16_t t;
+ uint8_t sreg = SREG;
cli();
t = timer_count;
- SREG = _sreg;
+ SREG = sreg;
return t;
}
@@ -40,12 +41,12 @@ uint16_t timer_read(void)
inline
uint16_t timer_elapsed(uint16_t last)
{
- uint8_t _sreg = SREG;
uint16_t t;
+ uint8_t sreg = SREG;
cli();
t = timer_count;
- SREG = _sreg;
+ SREG = sreg;
return TIMER_DIFF(t, last);
}
@@ -58,4 +59,3 @@ ISR(TIMER0_OVF_vect)
{
timer_count++;
}
-