Flesh out more stuff, including AVR timer setup

This commit is contained in:
XANTRONIX Development 2016-05-25 21:48:39 -05:00
parent cc01a283fe
commit 915d3c3510
3 changed files with 50 additions and 8 deletions

42
avr/main.c Normal file
View file

@ -0,0 +1,42 @@
#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;
}

View file

@ -1,16 +1,16 @@
#ifndef _TABBY_CLOCK_H #ifndef _TABBY_CLOCK_H
#define _TABBY_CLOCK_H #define _TABBY_CLOCK_H
typedef enum tabby_clock_mode { typedef enum {
TABBY_CLOCK_SOURCE_INTERNAL = 0x01, TABBY_CLOCK_SOURCE_INTERNAL = 0x01,
TABBY_CLOCK_SOURCE_EXTERNAL = 0x02 TABBY_CLOCK_SOURCE_EXTERNAL = 0x02
}; } tabby_clock_mode;
typedef enum tabby_clock_speed { typedef enum {
TABBY_CLOCK_SPEED_8192HZ = 0x01, TABBY_CLOCK_SPEED_8192HZ = 0x01,
TABBY_CLOCK_SPEED_16384HZ = 0x02, TABBY_CLOCK_SPEED_16384HZ = 0x02,
TABBY_CLOCK_SPEED_262144HZ = 0x20, TABBY_CLOCK_SPEED_262144HZ = 0x03,
TABBY_CLOCK_SPEED_524288HZ = 0x40 TABBY_CLOCK_SPEED_524288HZ = 0x04
}; } tabby_clock_speed;
#endif /* _TABBY_CLOCK_H */ #endif /* _TABBY_CLOCK_H */

View file

@ -1,10 +1,10 @@
#ifndef _TABBY_COMMAND_H #ifndef _TABBY_COMMAND_H
#define _TABBY_COMMAND_H #define _TABBY_COMMAND_H
typedef enum tabby_command { typedef enum {
TABBY_COMMAND_SEND = 0x01, TABBY_COMMAND_SEND = 0x01,
TABBY_COMMAND_CLOCK_SOURCE = 0x02, TABBY_COMMAND_CLOCK_SOURCE = 0x02,
TABBY_COMMAND_CLOCK_SPEED = 0x03 TABBY_COMMAND_CLOCK_SPEED = 0x03
}; } tabby_command;
#endif /* _TABBY_COMMAND_H */ #endif /* _TABBY_COMMAND_H */