diff -w -r -u arduino-0018/app/src/processing/app/Base.java arduino-gator-mods/app/src/processing/app/Base.java --- arduino-0018/app/src/processing/app/Base.java 2010-06-15 10:44:54.000000000 -0400 +++ arduino-gator-mods/app/src/processing/app/Base.java 2010-06-15 14:51:17.000000000 -0400 @@ -42,7 +42,7 @@ */ public class Base { public static final int REVISION = 18; - static String VERSION_NAME = "0018"; + static String VERSION_NAME = "0018-gator"; static HashMap platformNames = new HashMap(); static { diff -w -r -u arduino-0018/app/src/processing/app/Sketch.java arduino-gator-mods/app/src/processing/app/Sketch.java --- arduino-0018/app/src/processing/app/Sketch.java 2010-06-15 10:44:54.000000000 -0400 +++ arduino-gator-mods/app/src/processing/app/Sketch.java 2010-06-15 14:51:17.000000000 -0400 @@ -1462,6 +1462,13 @@ // } size(appletFolder.getPath(), foundName); + + // GATOR: Give the user a chance to bring up the bootloader on + // boards that aren't automatically waiting for code. + if (Preferences.getBoolean("upload.reset_dialog")) { + Base.showMessage("Compilation complete", "Press the reset button on your board then click OK"); + } + upload(appletFolder.getPath(), foundName, verbose); return true; diff -w -r -u arduino-0018/build/shared/lib/preferences.txt arduino-gator-mods/build/shared/lib/preferences.txt --- arduino-0018/build/shared/lib/preferences.txt 2010-06-15 10:38:24.000000000 -0400 +++ arduino-gator-mods/build/shared/lib/preferences.txt 2010-06-15 14:51:17.000000000 -0400 @@ -220,6 +220,10 @@ upload.using = bootloader +# If true, pop up a dialog box asking the user to reset their board prior to +# uploading a new sketch (GATOR). +upload.reset_dialog=true + serial.port=COM1 serial.databits=8 serial.stopbits=1 diff -w -r -u arduino-0018/hardware/arduino/boards.txt arduino-gator-mods/hardware/arduino/boards.txt --- arduino-0018/hardware/arduino/boards.txt 2010-06-15 10:45:33.000000000 -0400 +++ arduino-gator-mods/hardware/arduino/boards.txt 2010-06-15 22:38:58.000000000 -0400 @@ -1,4 +1,25 @@ ############################################################## +gator.name=Rugged Circuits Gator Board + +# You can set the protocol to 'arduino' for AVRDUDE version +# 5.6 or later +gator.upload.protocol=stk500v1 +gator.upload.maximum_size=30720 +gator.upload.speed=38400 + +gator.bootloader.low_fuses=0xF7 +gator.bootloader.high_fuses=0xD2 +gator.bootloader.extended_fuses=0x05 +gator.bootloader.path=gator +gator.bootloader.file=GATORBOOT.hex +gator.bootloader.unlock_bits=0xFF +gator.bootloader.lock_bits=0xEF + +gator.build.mcu=atmega324p +gator.build.f_cpu=20000000L +gator.build.core=arduino + +############################################################## atmega328.name=Arduino Duemilanove or Nano w/ ATmega328 diff -w -r -u arduino-0018/hardware/arduino/cores/arduino/HardwareSerial.cpp arduino-gator-mods/hardware/arduino/cores/arduino/HardwareSerial.cpp --- arduino-0018/hardware/arduino/cores/arduino/HardwareSerial.cpp 2010-06-15 10:45:30.000000000 -0400 +++ arduino-gator-mods/hardware/arduino/cores/arduino/HardwareSerial.cpp 2010-06-15 18:33:17.000000000 -0400 @@ -41,8 +41,10 @@ ring_buffer rx_buffer = { { 0 }, 0, 0 }; -#if defined(__AVR_ATmega1280__) +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega324P__) ring_buffer rx_buffer1 = { { 0 }, 0, 0 }; +#endif +#if defined(__AVR_ATmega1280__) ring_buffer rx_buffer2 = { { 0 }, 0, 0 }; ring_buffer rx_buffer3 = { { 0 }, 0, 0 }; #endif @@ -61,7 +63,20 @@ } } -#if defined(__AVR_ATmega1280__) +#if defined(__AVR_ATmega324P__) // GATOR +SIGNAL(USART0_RX_vect) +{ + unsigned char c = UDR0; + store_char(c, &rx_buffer); +} + +SIGNAL(USART1_RX_vect) +{ + unsigned char c = UDR1; + store_char(c, &rx_buffer1); +} + +#elif defined(__AVR_ATmega1280__) SIGNAL(SIG_USART0_RECV) { @@ -219,8 +234,10 @@ HardwareSerial Serial(&rx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRE0, U2X0); #endif -#if defined(__AVR_ATmega1280__) +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega324P__) // GATOR HardwareSerial Serial1(&rx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UDR1, RXEN1, TXEN1, RXCIE1, UDRE1, U2X1); +#endif +#if defined(__AVR_ATmega1280__) HardwareSerial Serial2(&rx_buffer2, &UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UDR2, RXEN2, TXEN2, RXCIE2, UDRE2, U2X2); HardwareSerial Serial3(&rx_buffer3, &UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UDR3, RXEN3, TXEN3, RXCIE3, UDRE3, U2X3); #endif diff -w -r -u arduino-0018/hardware/arduino/cores/arduino/HardwareSerial.h arduino-gator-mods/hardware/arduino/cores/arduino/HardwareSerial.h --- arduino-0018/hardware/arduino/cores/arduino/HardwareSerial.h 2010-06-15 10:45:30.000000000 -0400 +++ arduino-gator-mods/hardware/arduino/cores/arduino/HardwareSerial.h 2010-06-15 18:33:17.000000000 -0400 @@ -57,8 +57,10 @@ extern HardwareSerial Serial; -#if defined(__AVR_ATmega1280__) +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega324P__) // GATOR extern HardwareSerial Serial1; +#endif +#if defined(__AVR_ATmega1280__) extern HardwareSerial Serial2; extern HardwareSerial Serial3; #endif diff -w -r -u arduino-0018/hardware/arduino/cores/arduino/pins_arduino.c arduino-gator-mods/hardware/arduino/cores/arduino/pins_arduino.c --- arduino-0018/hardware/arduino/cores/arduino/pins_arduino.c 2010-06-15 10:45:30.000000000 -0400 +++ arduino-gator-mods/hardware/arduino/cores/arduino/pins_arduino.c 2010-06-15 18:33:17.000000000 -0400 @@ -355,6 +355,173 @@ NOT_ON_TIMER , // PK 6 ** 68 ** A14 NOT_ON_TIMER , // PK 7 ** 69 ** A15 }; +#elif defined(__AVR_ATmega324P__) // GATOR +/* On an ATmega324P, the pin mappings are as shown below. The + * first 20 pins (D0-D19) are for compatibility with ATmega8 + * and ATmega168 Arduinos. Specifically, the timer pins + * correspond as do the analog pin numbers to their digital + * pin counterparts (e.g., AI0-->D14, etc.) + * + * Analog Digital PWM Pin + * -------+-------+-------+------- + * | D 0 | | PC0 + * | D 1 | | PC1 + * | D 2 | | PC2 + * | D 3 |TIMER2B| PD6 + * | D 4 | | PC3 + * | D 5 |TIMER0B| PB4 + * | D 6 |TIMER0A| PB3 + * | D 7 | | PD2 + * | D 8 | | PD3 + * | D 9 |TIMER1A| PD5 + * | D 10 |TIMER1B| PD4 + * | D 11 |TIMER2A| PD7 + * | D 12 | | PC4 + * | D 13 | | PC6 + * AI 0 | D 14 | | PA0 + * AI 1 | D 15 | | PA1 + * AI 2 | D 16 | | PA2 + * AI 3 | D 17 | | PA3 + * AI 4 | D 18 | | PA4 + * AI 5 | D 19 | | PA5 + * AI 6 | D 20 | | PA6 + * AI 7 | D 21 | | PA7 + * | D 22 | | PC5 + * | D 23 | | PB0 + * | D 24 | | PB1 + * | D 25 | | PB2 + * | D 26 | | PB5 + * | D 27 | | PB6 + * | D 28 | | PB7 + */ + +#define PA 1 +#define PB 2 +#define PC 3 +#define PD 4 + +// these arrays map port names (e.g. port B) to the +// appropriate addresses for various functions (e.g. reading +// and writing) +const uint16_t PROGMEM port_to_mode_PGM[] = { + NOT_A_PORT, + &DDRA, + &DDRB, + &DDRC, + &DDRD, +}; + +const uint16_t PROGMEM port_to_output_PGM[] = { + NOT_A_PORT, + &PORTA, + &PORTB, + &PORTC, + &PORTD, +}; + +const uint16_t PROGMEM port_to_input_PGM[] = { + NOT_A_PORT, + &PINA, + &PINB, + &PINC, + &PIND, +}; + +const uint8_t PROGMEM digital_pin_to_port_PGM[] = { + PC, /* D0 : PC0 */ + PC, /* D1 : PC1 */ + PC, /* D2 : PC2 */ + PD, /* D3 : PD6 */ + PC, /* D4 : PC3 */ + PB, /* D5 : PB4 */ + PB, /* D6 : PB3 */ + PD, /* D7 : PD2 */ + PD, /* D8 : PD3 */ + PD, /* D9 : PD5 */ + PD, /* D10 : PD4 */ + PD, /* D11 : PD7 */ + PC, /* D12 : PC4 */ + PC, /* D13 : PC6 */ + PA, /* D14 : PA0 */ + PA, /* D15 : PA1 */ + PA, /* D16 : PA2 */ + PA, /* D17 : PA3 */ + PA, /* D18 : PA4 */ + PA, /* D19 : PA5 */ + PA, /* D20 : PA6 */ + PA, /* D21 : PA7 */ + PC, /* D22 : PC5 */ + PB, /* D23 : PB0 */ + PB, /* D24 : PB1 */ + PB, /* D25 : PB2 */ + PB, /* D26 : PB5 */ + PB, /* D27 : PB6 */ + PB /* D28 : PB7 */ +}; + +const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = { + _BV(0), /* D0 : PC0 */ + _BV(1), /* D1 : PC1 */ + _BV(2), /* D2 : PC2 */ + _BV(6), /* D3 : PD6 */ + _BV(3), /* D4 : PC3 */ + _BV(4), /* D5 : PB4 */ + _BV(3), /* D6 : PB3 */ + _BV(2), /* D7 : PD2 */ + _BV(3), /* D8 : PD3 */ + _BV(5), /* D9 : PD5 */ + _BV(4), /* D10 : PD4 */ + _BV(7), /* D11 : PD7 */ + _BV(4), /* D12 : PC4 */ + _BV(6), /* D13 : PC6 */ + _BV(0), /* D14 : PA0 */ + _BV(1), /* D15 : PA1 */ + _BV(2), /* D16 : PA2 */ + _BV(3), /* D17 : PA3 */ + _BV(4), /* D18 : PA4 */ + _BV(5), /* D19 : PA5 */ + _BV(6), /* D20 : PA6 */ + _BV(7), /* D21 : PA7 */ + _BV(5), /* D22 : PC5 */ + _BV(0), /* D23 : PB0 */ + _BV(1), /* D24 : PB1 */ + _BV(2), /* D25 : PB2 */ + _BV(5), /* D26 : PB5 */ + _BV(6), /* D27 : PB6 */ + _BV(7) /* D28 : PB7 */ +}; + +const uint8_t PROGMEM digital_pin_to_timer_PGM[] = { + NOT_ON_TIMER, /* D0 : PC0 */ + NOT_ON_TIMER, /* D1 : PC1 */ + NOT_ON_TIMER, /* D2 : PC2 */ + TIMER2B, /* D3 : PD6 (TIMER2B) */ + NOT_ON_TIMER, /* D4 : PC3 */ + TIMER0B, /* D5 : PB4 (TIMER0B) */ + TIMER0A, /* D6 : PB3 (TIMER0A) */ + NOT_ON_TIMER, /* D7 : PD2 */ + NOT_ON_TIMER, /* D8 : PD3 */ + TIMER1A, /* D9 : PD5 (TIMER1A) */ + TIMER1B, /* D10 : PD4 (TIMER1B) */ + TIMER2A, /* D11 : PD7 (TIMER2A) */ + NOT_ON_TIMER, /* D12 : PC4 */ + NOT_ON_TIMER, /* D13 : PC6 */ + NOT_ON_TIMER, /* D14 : PA0 */ + NOT_ON_TIMER, /* D15 : PA1 */ + NOT_ON_TIMER, /* D16 : PA2 */ + NOT_ON_TIMER, /* D17 : PA3 */ + NOT_ON_TIMER, /* D18 : PA4 */ + NOT_ON_TIMER, /* D19 : PA5 */ + NOT_ON_TIMER, /* D20 : PA6 */ + NOT_ON_TIMER, /* D21 : PA7 */ + NOT_ON_TIMER, /* D22 : PC5 */ + NOT_ON_TIMER, /* D23 : PB0 */ + NOT_ON_TIMER, /* D24 : PB1 */ + NOT_ON_TIMER, /* D25 : PB2 */ + NOT_ON_TIMER, /* D26 : PB5 */ + NOT_ON_TIMER, /* D27 : PB6 */ + NOT_ON_TIMER, /* D28 : PB7 */ +}; #else // these arrays map port names (e.g. port B) to the // appropriate addresses for various functions (e.g. reading diff -w -r -u arduino-0018/hardware/arduino/cores/arduino/wiring.c arduino-gator-mods/hardware/arduino/cores/arduino/wiring.c --- arduino-0018/hardware/arduino/cores/arduino/wiring.c 2010-06-15 10:45:30.000000000 -0400 +++ arduino-gator-mods/hardware/arduino/cores/arduino/wiring.c 2010-06-15 18:33:17.000000000 -0400 @@ -24,6 +24,16 @@ #include "wiring_private.h" +#ifdef __AVR_ATmega324P__ // 20 MHz Gator board...standard code is off by a factor of 255/256 + // so we use a 16-bit timer0_fract for higher resolution. +# if F_CPU != 20000000L +# error "This code is only configured for 20 MHz operation" +# endif +# define MILLIS_INC 0 +# define FRACT_INC 8192 // 819.2us per timer tick given 20e6/64/256==1220.703125 Hz==1/819.2us +# define FRACT_MAX 10000 // 1000.0us per millisecond + static unsigned short timer0_fract = 0; +#else // Arduinos <= 16 MHz // the prescaler is set so that timer0 ticks every 64 clock cycles, and the // the overflow handler is called every 256 ticks. #define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(64 * 256)) @@ -36,17 +46,22 @@ // about - 8 and 16 MHz - this doesn't lose precision.) #define FRACT_INC ((MICROSECONDS_PER_TIMER0_OVERFLOW % 1000) >> 3) #define FRACT_MAX (1000 >> 3) + static unsigned char timer0_fract = 0; +#endif volatile unsigned long timer0_overflow_count = 0; volatile unsigned long timer0_millis = 0; -static unsigned char timer0_fract = 0; SIGNAL(TIMER0_OVF_vect) { // copy these to local variables so they can be stored in registers // (volatile variables must be read from memory on every access) unsigned long m = timer0_millis; +#ifdef __AVR_ATmega324P__ // 20 MHz Gator board + unsigned short f = timer0_fract; +#else unsigned char f = timer0_fract; +#endif m += MILLIS_INC; f += FRACT_INC; diff -w -r -u arduino-0018/hardware/arduino/cores/arduino/wiring.h arduino-gator-mods/hardware/arduino/cores/arduino/wiring.h --- arduino-0018/hardware/arduino/cores/arduino/wiring.h 2010-06-15 10:45:30.000000000 -0400 +++ arduino-gator-mods/hardware/arduino/cores/arduino/wiring.h 2010-06-15 23:59:29.000000000 -0400 @@ -57,7 +57,13 @@ #define FALLING 2 #define RISING 3 +#if defined(__AVR_ATmega324P__) // GATOR +# define INTERNAL2_56V 3 +# define INTERNAL1_1V 2 +# define INTERNAL INTERNAL1_1V // For compatibility with ATmega328 +#else #define INTERNAL 3 +#endif #define DEFAULT 1 #define EXTERNAL 0 diff -w -r -u arduino-0018/libraries/Firmata/Firmata.h arduino-gator-mods/libraries/Firmata/Firmata.h --- arduino-0018/libraries/Firmata/Firmata.h 2010-06-15 10:45:09.000000000 -0400 +++ arduino-gator-mods/libraries/Firmata/Firmata.h 2010-06-15 14:51:20.000000000 -0400 @@ -215,6 +215,13 @@ #define ANALOG_PORT 4 // port# of analog used as digital #define FIRST_ANALOG_PIN 36 // pin# corresponding to analog 0 #define VERSION_BLINK_PIN 13 // digital pin to blink version on +#elif defined(__AVR_ATmega324P__) // GATOR +#define TOTAL_ANALOG_PINS 8 +#define TOTAL_DIGITAL_PINS 28 +#define TOTAL_PORTS 4 +#define ANALOG_PORT 1 +#define FIRST_ANALOG_PIN 14 +#define VERSION_BLINK_PIN 13 #else // anything else #define TOTAL_ANALOG_PINS 6 #define TOTAL_DIGITAL_PINS 14 diff -w -r -u arduino-0018/libraries/Wire/utility/twi.c arduino-gator-mods/libraries/Wire/utility/twi.c --- arduino-0018/libraries/Wire/utility/twi.c 2010-06-15 10:45:11.000000000 -0400 +++ arduino-gator-mods/libraries/Wire/utility/twi.c 2010-06-15 14:51:20.000000000 -0400 @@ -69,6 +69,9 @@ // as per note from atmega8 manual pg167 sbi(PORTC, 4); sbi(PORTC, 5); + #elif defined(__AVR_ATmega324P__) // GATOR + sbi(PORTC, 0); + sbi(PORTC, 1); #else // activate internal pull-ups for twi // as per note from atmega128 manual pg204