From b2b32eb4f37545480c1738a46d5ff8ecf142ae96 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Sat, 8 Nov 2008 21:57:48 +0000 Subject: [PATCH] Updating libraries for atmega328 (adding it to a couple of #if's, etc.). --- hardware/libraries/Firmata/Firmata.h | 2 +- hardware/libraries/Servo/Servo.cpp | 6 +++--- hardware/libraries/Wire/utility/twi.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hardware/libraries/Firmata/Firmata.h b/hardware/libraries/Firmata/Firmata.h index a0a6513fc..a9264623a 100644 --- a/hardware/libraries/Firmata/Firmata.h +++ b/hardware/libraries/Firmata/Firmata.h @@ -141,7 +141,7 @@ extern FirmataClass Firmata; #define setFirmwareVersion(x, y) setFirmwareNameAndVersion(__FILE__, x, y) // total number of pins currently supported -#if defined(__AVR_ATmega168__) // Arduino NG and Diecimila +#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) // Arduino NG and Diecimila #define TOTAL_ANALOG_PINS 8 #define TOTAL_DIGITAL_PINS 22 // 14 digital + 8 analog #define TOTAL_PORTS 3 // total number of ports for the board diff --git a/hardware/libraries/Servo/Servo.cpp b/hardware/libraries/Servo/Servo.cpp index ac654c3ac..8578fefb6 100755 --- a/hardware/libraries/Servo/Servo.cpp +++ b/hardware/libraries/Servo/Servo.cpp @@ -40,10 +40,10 @@ void Servo::seizeTimer1() ICR1 = clockCyclesPerMicrosecond()*(20000L/8); // 20000 uS is a bit fast for the refresh, 20ms, but // it keeps us from overflowing ICR1 at 20MHz clocks // That "/8" at the end is the prescaler. -#if defined(__AVR_ATmega168__) - TIMSK1 &= ~(_BV(OCIE1A) | _BV(OCIE1B) | _BV(TOIE1) ); -#else +#if defined(__AVR_ATmega8__) TIMSK &= ~(_BV(TICIE1) | _BV(OCIE1A) | _BV(OCIE1B) | _BV(TOIE1) ); +#else + TIMSK1 &= ~(_BV(OCIE1A) | _BV(OCIE1B) | _BV(TOIE1) ); #endif SREG = oldSREG; // undo cli() diff --git a/hardware/libraries/Wire/utility/twi.c b/hardware/libraries/Wire/utility/twi.c index 3e5489ffa..82a25c043 100644 --- a/hardware/libraries/Wire/utility/twi.c +++ b/hardware/libraries/Wire/utility/twi.c @@ -64,7 +64,7 @@ void twi_init(void) // initialize state twi_state = TWI_READY; - #if defined(__AVR_ATmega168__) || defined(__AVR_ATmega8__) + #if defined(__AVR_ATmega168__) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega328P__) // activate internal pull-ups for twi // as per note from atmega8 manual pg167 sbi(PORTC, 4); @@ -329,7 +329,7 @@ void twi_releaseBus(void) twi_state = TWI_READY; } -SIGNAL(SIG_2WIRE_SERIAL) +SIGNAL(TWI_vect) { switch(TW_STATUS){ // All Master