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.2 2006/07/19 12:56:26 bernie
18 *#* Convert to new Doxygen style.
20 *#* Revision 1.1 2005/04/12 01:37:50 bernie
21 *#* Import into DevLib.
23 *#* Revision 1.8 2005/04/12 01:18:09 bernie
24 *#* time_t -> mtime_t.
26 *#* Revision 1.7 2005/03/20 04:18:41 bernie
27 *#* Fixes for CONFIG_WATCHDOG == 0.
29 *#* Revision 1.6 2004/10/27 09:38:07 aleph
30 *#* Bootloader working with watchdog enabled
32 *#* Revision 1.5 2004/10/20 10:00:37 customer_pw
33 *#* Add newline at eof
35 *#* Revision 1.4 2004/10/14 14:13:09 batt
38 *#* Revision 1.3 2004/10/14 13:29:20 batt
39 *#* Fix 0ms delay bug.
41 *#* Revision 1.2 2004/10/13 17:53:05 batt
42 *#* Delay with hw timer.
44 *#* Revision 1.1 2004/10/13 16:36:32 batt
45 *#* Simplified timer delay routines.
49 #include "timer_simple.h"
53 #include <macros.h> /* BV() */
58 #define MS_PER_SEC 1000UL
59 #define TIMER_PRESCALER 64UL
60 #define TIMER_DELAY_1MS (255 - CLOCK_FREQ / TIMER_PRESCALER / MS_PER_SEC)
63 * Wait \a time ms using timer 0.
66 void timer_delay(mtime_t time)
68 /* Set timer clock to clock_freq/64 */
73 /* Initialize timer counter register */
74 TCNT0 = TIMER_DELAY_1MS;
75 /* Clear overflow bit. */
78 while (!(TIFR & BV(TOV0)));