From f40ae7cb90faff71daaebe3d4c011002339a3834 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Thu, 5 May 2011 23:09:19 +0200 Subject: digital/avr, digital/ai: add AT90USB1287 support --- digital/ai/src/utils/timer.avr.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'digital/ai/src') diff --git a/digital/ai/src/utils/timer.avr.c b/digital/ai/src/utils/timer.avr.c index b8756d88..63aa7bdc 100644 --- a/digital/ai/src/utils/timer.avr.c +++ b/digital/ai/src/utils/timer.avr.c @@ -39,8 +39,17 @@ timer_init (void) * -> Tov = 1 / Fov * Note: if you change the TCCR0 register value, please also update * TIMER_TC0_PRESCALER and TIMER_TC0_TOP. */ +#ifdef TCCR0 +# define TIFR_reg TIFR TCCR0 = regv (FOC0, WGM00, COM01, COM0, WGM01, CS02, CS01, CS00, 0, 0, 0, 0, 0, 1, 1, 0); +#else +# define TIFR_reg TIFR0 + TCCR0A = regv (COM0A1, COM0A0, COM0B1, COM0B0, 3, 2, WGM01, WGM00, + 0, 0, 0, 0, 0, 0, 0, 0); + TCCR0B = regv (FOC0A, FOC0B, 5, 4, WGM02, CS02, CS01, CS00, + 0, 0, 0, 0, 0, 1, 0, 0); +#endif } uint8_t @@ -49,11 +58,11 @@ timer_wait (void) /* Let's pretend we have reached overflow before calling this function. */ uint8_t count_before_ov = 1; /* Loop until an overflow of the timer occurs. */ - while (!(TIFR & _BV (TOV0))) + while (!(TIFR_reg & _BV (TOV0))) /* We have not reached overflow. */ count_before_ov = 0; /* Write 1 to clear overflow. */ - TIFR = _BV (TOV0); + TIFR_reg = _BV (TOV0); return count_before_ov; } -- cgit v1.2.3