# xmpl_timer.c - Using the Timer Macros

## Timer Macro Example

    /* $Id: xmpl_timer.c,v 1.2 2008/04/25 21:30:12 awachtler Exp $ */
    /* Example for using the timer macros */
    #include "board.h"
    #include "timer.h"
    #include "ioutil.h"

    #ifndef NO_TIMER
    int main(void)
    {
        LED_INIT();
        TIMER_INIT();
        sei();
        while(1)
        {
            DELAY_MS(100);
        }
    }

    ISR(TIMER_IRQ_vect)
    {
    static time_t  ticktime = 0;
        ticktime ++;
        /* LED_0 blinks with the calling frequency of the IRQ routine */
        LED_TOGGLE(0);
        if (ticktime > MSEC(500))
        {
            /* LED_1 blinks with a period of 1s */
            LED_TOGGLE(1);
            ticktime  = 0;
        }
    }
    #endif
    /*EOF*/