You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
323 B
C
21 lines
323 B
C
#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;
|
|
}
|