diff --git a/src/main.c b/src/main.c index 09e47a0..35e534d 100644 --- a/src/main.c +++ b/src/main.c @@ -1,3 +1,18 @@ +/* + * Author: Jake G Email: jakegoodwin@gorge.works + * FileName: main.c + * Date: 2025 + * Descripton: Program for Atiny13A controllers + */ + +#ifndef MCU +#define MCU atiny13a +#endif + +#ifndef F_CPU +#define F_CPU 4800000UL +#endif + #include "stdio.h" #include @@ -9,6 +24,10 @@ //Globals //############################# + +//Debounce check number. +#define MAX_CHECKS 10 + #define LED_PORT (1<<5) #define LED_PIN PB5 #define BLINK_DELAY_MS 5000 @@ -72,19 +91,81 @@ int main(int argc, char **argv) //FUNCTIONS //############################# -/* - * Input: None - * Output: None - * Description: Toggles the pin for the LED indicator. - */ -void led_blink(void) { - //Set the DDR for output. - DDRB |= LED_PORT; - PORTB ^= (1<= MAX_CHECKS) { + idx = 0; + } } + + +/*Setup the timer0 on the AVR*/ +static inline void init_timer0() { + /*Zero out the tick_count var*/ + tick_count = 0; + + /*config to normal mode.*/ + TCCR0A = 0x00; //stop timer + TCCR0B = 0x00; //zero timer + + /*set prescaler*/ + //Set to div64 + TCCR0B |= (1<