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 +++++++++++-- digital/avr/modules/twi/twi_hard.avr.c | 6 +++++- digital/avr/modules/uart/uart.avr.c | 4 ++++ 3 files changed, 20 insertions(+), 3 deletions(-) (limited to 'digital') 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; } diff --git a/digital/avr/modules/twi/twi_hard.avr.c b/digital/avr/modules/twi/twi_hard.avr.c index ff65d31e..8bd18d34 100644 --- a/digital/avr/modules/twi/twi_hard.avr.c +++ b/digital/avr/modules/twi/twi_hard.avr.c @@ -56,6 +56,10 @@ # if defined (__AVR_ATmega32__) # elif defined (__AVR_ATmega64__) # elif defined (__AVR_ATmega128__) +# elif defined (__AVR_AT90USB646__) +# elif defined (__AVR_AT90USB647__) +# elif defined (__AVR_AT90USB1286__) +# elif defined (__AVR_AT90USB1287__) # else # error "twi: not tested on this chip" # endif @@ -201,7 +205,7 @@ twi_master_wait (void) # endif /* AC_TWI_MASTER_ENABLE */ -SIGNAL (SIG_2WIRE_SERIAL) +SIGNAL (TWI_vect) { # if AC_TWI_SLAVE_ENABLE /** Slave work buffer. */ diff --git a/digital/avr/modules/uart/uart.avr.c b/digital/avr/modules/uart/uart.avr.c index e3ffb18c..359f9002 100644 --- a/digital/avr/modules/uart/uart.avr.c +++ b/digital/avr/modules/uart/uart.avr.c @@ -39,6 +39,10 @@ #elif defined (__AVR_ATmega64__) #elif defined (__AVR_ATmega128__) #elif defined (__AVR_AT90USB162__) +#elif defined (__AVR_AT90USB646__) +#elif defined (__AVR_AT90USB647__) +#elif defined (__AVR_AT90USB1286__) +#elif defined (__AVR_AT90USB1287__) #else # warning "uart: not tested on this chip" #endif -- cgit v1.2.3