summaryrefslogtreecommitdiff
path: root/digital/ai/src/utils/timer.avr.c
diff options
context:
space:
mode:
authorNicolas Schodet2011-05-05 23:09:19 +0200
committerNicolas Schodet2011-05-05 23:09:19 +0200
commitf40ae7cb90faff71daaebe3d4c011002339a3834 (patch)
treef5ba227dd06031a288a7c8520c13df8619aac507 /digital/ai/src/utils/timer.avr.c
parentf490ee060442542df0d4abc082bdec6f295dbc38 (diff)
digital/avr, digital/ai: add AT90USB1287 support
Diffstat (limited to 'digital/ai/src/utils/timer.avr.c')
-rw-r--r--digital/ai/src/utils/timer.avr.c13
1 files changed, 11 insertions, 2 deletions
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;
}