From 804e09b80b182b113d770811e543060ff53d3633 Mon Sep 17 00:00:00 2001 From: jake Date: Sun, 4 Aug 2024 12:10:36 -0700 Subject: [PATCH] updated to have helper function --- src/timer/timer.c | 30 ++++++++++++++++++++++++------ src/timer/timer.h | 12 ++++++++++-- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/timer/timer.c b/src/timer/timer.c index b1a56b3..cee538a 100644 --- a/src/timer/timer.c +++ b/src/timer/timer.c @@ -7,12 +7,30 @@ * @file module_name.h */ -#include "timer.h" +// Used during testing and for the LSP +#ifndef __AVR_ATtiny404__ +#define __AVR_ATtiny404__ +#endif -// dumb test function -int add_two(int a) +#include "timer.h" +#include "avr/io.h" + +void Timer_SelectClock(void) { - int b = a; - b += 2; - return b; + //set the timer to divde the clock by 256 + //Check datasheet page: 189 + TCA0.SINGLE.CTRLA |= 0x6; + } + +void Timer_Enable(void) +{ + TCA0.SINGLE.CTRLA |= (1<<0); +} + +void Timer_Period(void) +{ + TCA0.SINGLE.PER = 10000; +} + + diff --git a/src/timer/timer.h b/src/timer/timer.h index a915acf..d38e468 100644 --- a/src/timer/timer.h +++ b/src/timer/timer.h @@ -10,10 +10,18 @@ #ifndef TIMER #define TIMER +#include "inttypes.h" + /** - * A function that adds two to a number + * * @param a The first argument */ -int add_two(int a); + +/** + * The timer select clock function sets the divider to 256 assuming a + * default clock diver of 6 is applied to the 20MHz crystal. This gives a + * 13020.8333 Hz or approximatly 13.02Khz tick rate. + */ +void Timer_SelectClock(void); #endif // TIMER