summaryrefslogtreecommitdiffstats
path: root/timer.cpp
blob: b4a1b121d9d67327afe6f055eb2328221dc57e5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "timer.h"
#include "global.h"

#include <avr/interrupt.h>


static volatile unsigned long ticks = 0;


SIGNAL(SIG_OVERFLOW0) {
	ticks++;	
}

void sleep(unsigned long ms) {
	unsigned long t = ticks + ms * (F_CPU/TIMER_PRESCALER/256000);
	
	while(ticks < t);
}