main.c - не конечный результат, нужно адаптировать под новый кольцевой буфер, загружу позже кроме этого тут circular_buf.c и timer.c
		
			
				
	
	
		
			23 lines
		
	
	
		
			377 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
		
			377 B
		
	
	
	
		
			C
		
	
	
	
	
	
#include <avr/io.h>
 | 
						|
#include <avr/interrupt.h>
 | 
						|
 | 
						|
static volatile unsigned long timerMillis = 0;
 | 
						|
 | 
						|
void timerInit() {
 | 
						|
	TCCR1B |= (1 << WGM12) | (1 << CS11) | (1 << CS10);
 | 
						|
	OCR1A = 249;
 | 
						|
	TIMSK1 |= (1 << OCIE1A);
 | 
						|
	sei();
 | 
						|
}
 | 
						|
 | 
						|
unsigned long millis() {
 | 
						|
	unsigned long ms;
 | 
						|
	cli();
 | 
						|
	ms = timerMillis;
 | 
						|
	sei();
 | 
						|
	return ms;
 | 
						|
}
 | 
						|
 | 
						|
ISR(TIMER1_COMPA_vect) {
 | 
						|
	timerMillis++;
 | 
						|
} |