4 * Copyright 2004 Develer S.r.l. (http://www.develer.com/)
8 * \brief Some simple delay routines.
10 * Simple serial driver
12 * \author Francesco Sacchi <batt@develer.com>
17 *#* Revision 1.1 2005/04/12 01:37:50 bernie
18 *#* Import into DevLib.
20 *#* Revision 1.8 2005/04/12 01:18:09 bernie
21 *#* time_t -> mtime_t.
23 *#* Revision 1.7 2005/03/20 04:18:41 bernie
24 *#* Fixes for CONFIG_WATCHDOG == 0.
26 *#* Revision 1.6 2004/10/27 09:38:07 aleph
27 *#* Bootloader working with watchdog enabled
29 *#* Revision 1.5 2004/10/20 10:00:37 customer_pw
30 *#* Add newline at eof
32 *#* Revision 1.4 2004/10/14 14:13:09 batt
35 *#* Revision 1.3 2004/10/14 13:29:20 batt
36 *#* Fix 0ms delay bug.
38 *#* Revision 1.2 2004/10/13 17:53:05 batt
39 *#* Delay with hw timer.
41 *#* Revision 1.1 2004/10/13 16:36:32 batt
42 *#* Simplified timer delay routines.
46 #include "timer_simple.h"
50 #include <macros.h> /* BV() */
55 #define MS_PER_SEC 1000UL
56 #define TIMER_PRESCALER 64UL
57 #define TIMER_DELAY_1MS (255 - CLOCK_FREQ / TIMER_PRESCALER / MS_PER_SEC)
60 * Wait \a time ms using timer 0.
63 void timer_delay(mtime_t time)
65 /* Set timer clock to clock_freq/64 */
70 /* Initialize timer counter register */
71 TCNT0 = TIMER_DELAY_1MS;
72 /* Clear overflow bit. */
75 while (!(TIFR & BV(TOV0)));