From: batt Date: Thu, 11 Oct 2007 15:39:35 +0000 (+0000) Subject: Move avr simple timer driver. X-Git-Tag: 1.0.0~372 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=4ae907083cd95f7eaac6b0a0a4ee7862af782ac4;p=bertos.git Move avr simple timer driver. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@869 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/cpu/avr/drv/timer_simple_avr.c b/cpu/avr/drv/timer_simple_avr.c new file mode 100644 index 00000000..2c076414 --- /dev/null +++ b/cpu/avr/drv/timer_simple_avr.c @@ -0,0 +1,108 @@ +/** + * \file + * + * + * \brief Some simple delay routines. + * + * Simple serial driver + * \version $Id$ + * \author Francesco Sacchi + */ + +/*#* + *#* $Log$ + *#* Revision 1.2 2006/07/19 12:56:26 bernie + *#* Convert to new Doxygen style. + *#* + *#* Revision 1.1 2005/04/12 01:37:50 bernie + *#* Import into DevLib. + *#* + *#* Revision 1.8 2005/04/12 01:18:09 bernie + *#* time_t -> mtime_t. + *#* + *#* Revision 1.7 2005/03/20 04:18:41 bernie + *#* Fixes for CONFIG_WATCHDOG == 0. + *#* + *#* Revision 1.6 2004/10/27 09:38:07 aleph + *#* Bootloader working with watchdog enabled + *#* + *#* Revision 1.5 2004/10/20 10:00:37 customer_pw + *#* Add newline at eof + *#* + *#* Revision 1.4 2004/10/14 14:13:09 batt + *#* Add comment. + *#* + *#* Revision 1.3 2004/10/14 13:29:20 batt + *#* Fix 0ms delay bug. + *#* + *#* Revision 1.2 2004/10/13 17:53:05 batt + *#* Delay with hw timer. + *#* + *#* Revision 1.1 2004/10/13 16:36:32 batt + *#* Simplified timer delay routines. + *#* + *#*/ +#include "hw.h" +#include "timer_simple.h" +#include +#include +#include +#include /* BV() */ + +#include + + +#define MS_PER_SEC 1000UL +#define TIMER_PRESCALER 64UL +#define TIMER_DELAY_1MS (255 - CLOCK_FREQ / TIMER_PRESCALER / MS_PER_SEC) + +/** + * Wait \a time ms using timer 0. + * + */ +void timer_delay(mtime_t time) +{ + /* Set timer clock to clock_freq/64 */ + TCCR0 = BV(CS02); + + while (time--) + { + /* Initialize timer counter register */ + TCNT0 = TIMER_DELAY_1MS; + /* Clear overflow bit. */ + TIFR |= BV(TOV0); + /* Wait overflow. */ + while (!(TIFR & BV(TOV0))); +#if CONFIG_WATCHDOG + wdt_reset(); +#endif + } +} diff --git a/cpu/avr/drv/timer_simple_avr.h b/cpu/avr/drv/timer_simple_avr.h new file mode 100644 index 00000000..4815389e --- /dev/null +++ b/cpu/avr/drv/timer_simple_avr.h @@ -0,0 +1,60 @@ +/** + * \file + * + * + * \brief Simple delay routine + * + * \version $Id$ + * \author Francesco Sacchi + */ + +/*#* + *#* $Log$ + *#* Revision 1.2 2006/07/19 12:56:26 bernie + *#* Convert to new Doxygen style. + *#* + *#* Revision 1.1 2005/04/12 01:37:50 bernie + *#* Import into DevLib. + *#* + *#* Revision 1.2 2005/04/12 01:18:09 bernie + *#* time_t -> mtime_t. + *#* + *#* Revision 1.1 2004/10/13 16:36:32 batt + *#* Simplified timer delay routines. + *#* + *#* + */ +#ifndef TIMER_SIMPLE_H +#include + +extern void timer_delay(mtime_t time); +#define TIMER_SIMPLE_H + +#endif /* TIMER_SIMPLE_H */ diff --git a/drv/timer_simple_avr.c b/drv/timer_simple_avr.c deleted file mode 100644 index 2c076414..00000000 --- a/drv/timer_simple_avr.c +++ /dev/null @@ -1,108 +0,0 @@ -/** - * \file - * - * - * \brief Some simple delay routines. - * - * Simple serial driver - * \version $Id$ - * \author Francesco Sacchi - */ - -/*#* - *#* $Log$ - *#* Revision 1.2 2006/07/19 12:56:26 bernie - *#* Convert to new Doxygen style. - *#* - *#* Revision 1.1 2005/04/12 01:37:50 bernie - *#* Import into DevLib. - *#* - *#* Revision 1.8 2005/04/12 01:18:09 bernie - *#* time_t -> mtime_t. - *#* - *#* Revision 1.7 2005/03/20 04:18:41 bernie - *#* Fixes for CONFIG_WATCHDOG == 0. - *#* - *#* Revision 1.6 2004/10/27 09:38:07 aleph - *#* Bootloader working with watchdog enabled - *#* - *#* Revision 1.5 2004/10/20 10:00:37 customer_pw - *#* Add newline at eof - *#* - *#* Revision 1.4 2004/10/14 14:13:09 batt - *#* Add comment. - *#* - *#* Revision 1.3 2004/10/14 13:29:20 batt - *#* Fix 0ms delay bug. - *#* - *#* Revision 1.2 2004/10/13 17:53:05 batt - *#* Delay with hw timer. - *#* - *#* Revision 1.1 2004/10/13 16:36:32 batt - *#* Simplified timer delay routines. - *#* - *#*/ -#include "hw.h" -#include "timer_simple.h" -#include -#include -#include -#include /* BV() */ - -#include - - -#define MS_PER_SEC 1000UL -#define TIMER_PRESCALER 64UL -#define TIMER_DELAY_1MS (255 - CLOCK_FREQ / TIMER_PRESCALER / MS_PER_SEC) - -/** - * Wait \a time ms using timer 0. - * - */ -void timer_delay(mtime_t time) -{ - /* Set timer clock to clock_freq/64 */ - TCCR0 = BV(CS02); - - while (time--) - { - /* Initialize timer counter register */ - TCNT0 = TIMER_DELAY_1MS; - /* Clear overflow bit. */ - TIFR |= BV(TOV0); - /* Wait overflow. */ - while (!(TIFR & BV(TOV0))); -#if CONFIG_WATCHDOG - wdt_reset(); -#endif - } -} diff --git a/drv/timer_simple_avr.h b/drv/timer_simple_avr.h deleted file mode 100644 index 4815389e..00000000 --- a/drv/timer_simple_avr.h +++ /dev/null @@ -1,60 +0,0 @@ -/** - * \file - * - * - * \brief Simple delay routine - * - * \version $Id$ - * \author Francesco Sacchi - */ - -/*#* - *#* $Log$ - *#* Revision 1.2 2006/07/19 12:56:26 bernie - *#* Convert to new Doxygen style. - *#* - *#* Revision 1.1 2005/04/12 01:37:50 bernie - *#* Import into DevLib. - *#* - *#* Revision 1.2 2005/04/12 01:18:09 bernie - *#* time_t -> mtime_t. - *#* - *#* Revision 1.1 2004/10/13 16:36:32 batt - *#* Simplified timer delay routines. - *#* - *#* - */ -#ifndef TIMER_SIMPLE_H -#include - -extern void timer_delay(mtime_t time); -#define TIMER_SIMPLE_H - -#endif /* TIMER_SIMPLE_H */