diff --git a/docs/feather_pinout.png b/docs/feather_pinout.png new file mode 100644 index 0000000..df97793 Binary files /dev/null and b/docs/feather_pinout.png differ diff --git a/docs/feather_schematic.png b/docs/feather_schematic.png new file mode 100644 index 0000000..35c2b24 Binary files /dev/null and b/docs/feather_schematic.png differ diff --git a/src/include/timer.h b/src/include/timer.h new file mode 100644 index 0000000..a751398 --- /dev/null +++ b/src/include/timer.h @@ -0,0 +1,3 @@ +void initCtcTimer0(void); +void initOverflowTimer0(void); +void initOverflowTimer1(void); \ No newline at end of file diff --git a/src/include/uart.h b/src/include/uart.h new file mode 100644 index 0000000..edbfb28 --- /dev/null +++ b/src/include/uart.h @@ -0,0 +1,5 @@ +#include + +void uart_init(unsigned int baud); +void uart_sendByte(uint8_t byte); +int uart_printf(char var, FILE *stream); \ No newline at end of file diff --git a/src/timer.c b/src/timer.c new file mode 100644 index 0000000..1a46741 --- /dev/null +++ b/src/timer.c @@ -0,0 +1,37 @@ +#include +#include "include/timer.h" + +void initCtcTimer0(void) +{ + /* Initialize counter 0 */ + TCNT0 = 0; + + /* Enable Counter0 Compare Match A Interrupt */ + TIMSK0 |= (1 << OCIE0A); + + /* Select clock. Prescaler of 1024 */ + TCCR0B |= (1 << CS02) | (1 << CS00); + + /* Use CTC Mode */ + TCCR0A |= (1 << WGM01); + + /* + * OCR0A contains TOP value for counter: + */ + OCR0A = 78; +} + +void initOverflowTimer0(void) +{ + /* Prescaler = 0 */ + TCCR0B |= (1< + +#include "include/uart.h" + +static FILE stream = FDEV_SETUP_STREAM(uart_printf, NULL, _FDEV_SETUP_WRITE); + +void uart_init(unsigned int baud) +{ + stdout = &stream; + + /* Set baud rate */ + UBRR1H = (unsigned char)(baud>>8); + UBRR1L = (unsigned char)baud; + + /* Enable receiver and transmitter */ + UCSR1B = (1<