diff --git a/74hc165_piso/Makefile b/74hc165_piso/Makefile index cba8518..9c08693 100644 --- a/74hc165_piso/Makefile +++ b/74hc165_piso/Makefile @@ -51,7 +51,7 @@ FORMAT = ihex TARGET = main # List C source files here. (C dependencies are automatically generated.) -SRC = $(TARGET).c uart_async.c timer.c +SRC = $(TARGET).c uart_async.c # List Assembler source files here. # Make them always end in a capital .S. Files ending in a lowercase .s diff --git a/74hc165_piso/timer.c b/74hc165_piso/timer.c deleted file mode 100644 index 17db4d0..0000000 --- a/74hc165_piso/timer.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Low resolution implementation of timer using a 8 bit clock with prescaler, - * etc. Clicks approximately every millisecond. Microseconds are not available, - * and any queries to the function will just return milliseconds * 1000. - * You can use this file when you don't need high resolution timing, and don't care - * about slight clock drift, inaccuracy, etc. For timing most human-related activities, - * though, it should be more than sufficient. - */ -#include "timer.h" - -static volatile uint64_t _timer_millis; - -/* - * Initializes the timer, and resets the timer count to 0. Sets up the ISRs - * linked with timer0. - */ -void timer_init(){ - //Set up the timer to run at F_CPU / 256, in normal mode (we reset TCNT0 in the ISR) - TCCR0A = 0x0; - TCCR0B |= _BV(CS02); - - //Set compare value to be F_CPU / 1000 -- fire interrupt every millisecond - OCR0A = F_CPU / 256 / 1000; - - //Enable compare interrupt - TIMSK0 = _BV(OCIE0A); - - //Reset count variables - _timer_millis = 0; - - //Enable interrupts if the NO_INTERRUPT_ENABLE define is not set. If it is, you need to call sei() elsewhere. -#ifndef NO_INTERRUPT_ENABLE - sei(); -#endif - - DDRB = 0xFF; -} - -/* - * Returns the number of milliseconds which have elapsed since the - * last time timer_init() was called. Overflows after about 49 days. - */ -uint64_t timer_millis(){ - return _timer_millis; -} - -/* - * Returns the number of microseconds which have elapsed since the - * last time timer_init() was called. Overflows after about 71 minutes. - */ -uint64_t timer_micros(){ - return (_timer_millis * 1000); -} - - -/* - * The ISR for timer0 overflow. Increment the _timer_count here, and do the calculcations - * to increment _timer_millis as needed. - */ -ISR(TIMER0_COMPA_vect){ - TCNT0 = 0; - _timer_millis++; -} diff --git a/74hc165_piso/timer.h b/74hc165_piso/timer.h deleted file mode 100644 index 448c03d..0000000 --- a/74hc165_piso/timer.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef TIMER_H -#define TIMER_H - -#include -#include - -/* - * Initializes the timer, and resets the timer count to 0. Sets up the ISRs - * linked with timer1. - */ -void timer_init(); - -/* - * Returns the number of milliseconds which have elapsed since the - * last time timer_init() was called. Overflows after about 49 days. - */ -uint64_t timer_millis(); - -/* - * Returns the number of microseconds which have elapsed since the - * last time timer_init() was called. Overflows after about 71 minutes. - */ -uint64_t timer_micros(); - -#endif