#include "config.h" #include "Port.h" #include #include #define SET_LED() PORTB &= ~_BV(LEDPIN) #define CLR_LED() PORTB |= _BV(LEDPIN) #define DELAY_1S 15 void inline io_init(void) { PORTB |= _BV(LEDPIN); //HIGH DDRB |= _BV(LEDPIN); //OUTPUT } void inline timer0_init(void) { TCNT0 = 0; TCCR0 = _BV(CS02)|_BV(CS00); //FCLK i/o/1024 TIMSK |= _BV(TOV0); } void inline interrupt_set(void) { sei(); } void inline blinky(void) { static uint8 led_flag=0; if (led_flag) { led_flag = 0; SET_LED(); } else { led_flag=1; CLR_LED(); } } SIGNAL(SIG_OVERFLOW0) { static uint8 timer_count=0; timer_count++; if (timer_count==(DELAY_1S-1)) { timer_count=0; blinky(); } } int main(void) { io_init(); timer0_init(); interrupt_set(); while (1) { } }