diff --git a/led.c b/led.c new file mode 100644 index 0000000..a477db4 --- /dev/null +++ b/led.c @@ -0,0 +1,77 @@ +#include +#include +#include "led.h" + +#define SET_LED(PORT, IDX, NUM) PORT = ((PORT & ~(1<<(IDX))) | (~(NUM) & 1<<(IDX))) + +volatile uint8_t led_hour; +volatile uint8_t led_minute; +volatile uint8_t led_second; + +void led_init(void) +{ + // Set outputs + ANODES_DIR |= HOUR_ANODE | MINUTE_ANODE | SECOND_ANODE; + LED0_DIR |= LED0; + LED1_DIR |= LED1; + LED2_DIR |= LED2; + LED3_DIR |= LED3; + LED4_DIR |= LED4; + LED5_DIR |= LED5; + + // Clear LEDs + ANODES_PORT = HOUR_ANODE | MINUTE_ANODE | SECOND_ANODE; + LED0_PORT |= LED0; + LED1_PORT |= LED1; + LED2_PORT |= LED2; + LED3_PORT |= LED3; + LED4_PORT |= LED4; + LED5_PORT |= LED5; + + TCCR0 |= (1< 4) + { + counter = 1; + } +} \ No newline at end of file diff --git a/led.h b/led.h new file mode 100644 index 0000000..7fbeb3b --- /dev/null +++ b/led.h @@ -0,0 +1,35 @@ +#ifndef __LED_H__ +#define __LED_H__ + +#define LED0_PORT PORTA +#define LED0_DIR DDRA +#define LED0 (1<<0) +#define LED1_PORT PORTA +#define LED1_DIR DDRA +#define LED1 (1<<1) +#define LED2_PORT PORTA +#define LED2_DIR DDRA +#define LED2 (1<<2) +#define LED3_PORT PORTA +#define LED3_DIR DDRA +#define LED3 (1<<3) +#define LED4_PORT PORTA +#define LED4_DIR DDRA +#define LED4 (1<<4) +#define LED5_PORT PORTA +#define LED5_DIR DDRA +#define LED5 (1<<5) + +#define ANODES_PORT PORTD +#define ANODES_DIR DDRD +#define HOUR_ANODE (1< +#include +#include "led.h" + +int main() +{ + led_init(); + + sei(); + + led_hour = 0; + led_minute = 0; + led_second = 0; + + while(1) + { + + } +} \ No newline at end of file