avrinput/time.c
2019-01-01 16:48:54 +01:00

29 lines
350 B
C

#include "time.h"
#include "conf.h"
#include <avr/interrupt.h>
#include <avr/io.h>
volatile unsigned int _eigentime_ms;
void
time_init(void)
{
_eigentime_ms = 0;
TCCR1B = _BV(CS10);
OCR1A = TIMER1_COMPA_VALUE;
TIMSK |= _BV(OCIE1A);
}
unsigned int
get_eigentime(void)
{
return _eigentime_ms;
}
ISR(TIMER1_COMPA_vect)
{
_eigentime_ms++;
}