#include <avr/io.h>
#include <avr/interrupt.h>
#include "millis.h"

volatile unsigned long _millis; // for millis tick !! Overflow every ~49.7 days

ISR (TIMER0_COMPA_vect)
{
	_millis++; // INC millis tick
}

unsigned long millis(void)
{
	unsigned long i;
	cli();
	// Atomic tick reading
	i = _millis;
	sei();
	return i;
}
