timer_simple_avr.c

Go to the documentation of this file.
00001 
00040 #warning FIXME:This module is obsolete, yuo must refactor it.
00041 
00042 #if 0
00043 #include <hw/hw_cpufreq.h>
00044 #include "timer_simple_avr.h"
00045 #include <drv/wdt.h>
00046 #include <cfg/compiler.h>
00047 #include <cfg/macros.h> /* BV() */
00048 
00049 #include <avr/io.h>
00050 
00051 
00052 #define MS_PER_SEC       1000UL
00053 #define TIMER_PRESCALER  64UL
00054 #define TIMER_DELAY_1MS  (255 - CPU_FREQ / TIMER_PRESCALER / MS_PER_SEC)
00055 
00060 void timer_delay(mtime_t time)
00061 {
00062     /* Set timer clock to clock_freq/64 */
00063     TCCR0 = BV(CS02);
00064 
00065     while (time--)
00066     {
00067         /* Initialize timer counter register */
00068         TCNT0 = TIMER_DELAY_1MS;
00069         /* Clear overflow bit. */
00070         TIFR |= BV(TOV0);
00071         /* Wait overflow. */
00072         while (!(TIFR & BV(TOV0)));
00073 #if CONFIG_WATCHDOG
00074         wdt_reset();
00075 #endif
00076     }
00077 }
00078 #endif
00079