43 lines
652 B
C
43 lines
652 B
C
|
#include <avr/interrupt.h>
|
||
|
|
||
|
#include <tabby/clock.h>
|
||
|
|
||
|
uint16_t timer_counter_intervals[4] = {
|
||
|
1953, 977, 61, 31
|
||
|
};
|
||
|
|
||
|
void setup_internal_clock(tabby_clock_speed speed) {
|
||
|
/*
|
||
|
* Enable timer interrupt vector
|
||
|
*/
|
||
|
TIMSK = (1 << TOIE1);
|
||
|
|
||
|
/*
|
||
|
* Reset timer counter to zero
|
||
|
*/
|
||
|
TCNT1 = 0;
|
||
|
|
||
|
/*
|
||
|
* Set timer interval
|
||
|
*/
|
||
|
OCR1A = timer_counter_intervals[speed];
|
||
|
|
||
|
/*
|
||
|
* Set timer clock divider to 1/1
|
||
|
*/
|
||
|
TCCR1B = (1 << CS10);
|
||
|
}
|
||
|
|
||
|
void setup_external_clock() {
|
||
|
/*
|
||
|
* Disable internal timer interrupts
|
||
|
*/
|
||
|
TCCR1B = 0;
|
||
|
OCR1A = 0;
|
||
|
TIMSK = 0;
|
||
|
}
|
||
|
|
||
|
int main() {
|
||
|
return 0;
|
||
|
}
|