From e77ee2903b276f350e69f12a008088de5a308211 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Thu, 28 Jun 2012 23:20:56 -0400 Subject: Print "ovf" if float to be printed doesn't fit in a long. http://code.google.com/p/arduino/issues/detail?id=967 --- cores/arduino/Print.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'cores') diff --git a/cores/arduino/Print.cpp b/cores/arduino/Print.cpp index 711251c..53961ec 100755 --- a/cores/arduino/Print.cpp +++ b/cores/arduino/Print.cpp @@ -228,6 +228,8 @@ size_t Print::printFloat(double number, uint8_t digits) if (isnan(number)) return print("nan"); if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically // Handle negative numbers if (number < 0.0) -- cgit v1.2.3-18-g5258 From 4293079076b319f1762481bb31c5fce74c97dc7a Mon Sep 17 00:00:00 2001 From: Shigeru KANEMOTO Date: Fri, 22 Jun 2012 11:27:56 +0900 Subject: Fix for tone() on Leonardo. --- cores/arduino/Arduino.h | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ cores/arduino/Tone.cpp | 31 +++++++++++++++++------ 2 files changed, 88 insertions(+), 8 deletions(-) (limited to 'cores') diff --git a/cores/arduino/Arduino.h b/cores/arduino/Arduino.h index 830c995..d592aab 100755 --- a/cores/arduino/Arduino.h +++ b/cores/arduino/Arduino.h @@ -11,6 +11,71 @@ #include "binary.h" +// Workaround for wrong definitions in "iom32u4.h". +// This should be fixed in the AVR toolchain. +#ifdef __AVR_ATmega32U4__ +#undef UHCON +#undef UHINT +#undef UHIEN +#undef UHADDR +#undef UHFNUM +#undef UHFNUML +#undef UHFNUMH +#undef UHFLEN +#undef UPINRQX +#undef UPINTX +#undef UPNUM +#undef UPRST +#undef UPCONX +#undef UPCFG0X +#undef UPCFG1X +#undef UPSTAX +#undef UPCFG2X +#undef UPIENX +#undef UPDATX +#undef TCCR2A +#undef WGM20 +#undef WGM21 +#undef COM2B0 +#undef COM2B1 +#undef COM2A0 +#undef COM2A1 +#undef TCCR2B +#undef CS20 +#undef CS21 +#undef CS22 +#undef WGM22 +#undef FOC2B +#undef FOC2A +#undef TCNT2 +#undef TCNT2_0 +#undef TCNT2_1 +#undef TCNT2_2 +#undef TCNT2_3 +#undef TCNT2_4 +#undef TCNT2_5 +#undef TCNT2_6 +#undef TCNT2_7 +#undef OCR2A +#undef OCR2_0 +#undef OCR2_1 +#undef OCR2_2 +#undef OCR2_3 +#undef OCR2_4 +#undef OCR2_5 +#undef OCR2_6 +#undef OCR2_7 +#undef OCR2B +#undef OCR2_0 +#undef OCR2_1 +#undef OCR2_2 +#undef OCR2_3 +#undef OCR2_4 +#undef OCR2_5 +#undef OCR2_6 +#undef OCR2_7 +#endif + #ifdef __cplusplus extern "C"{ #endif diff --git a/cores/arduino/Tone.cpp b/cores/arduino/Tone.cpp index 20eed3f..9bb6fe7 100755 --- a/cores/arduino/Tone.cpp +++ b/cores/arduino/Tone.cpp @@ -29,6 +29,7 @@ Version Modified By Date Comments 09/11/25 Fixed timer0 from being excluded 0006 D Mellis 09/12/29 Replaced objects with functions 0007 M Sproul 10/08/29 Changed #ifdefs from cpu to register +0008 S Kanemoto 12/06/22 Fixed for Leonardo by @maris_HY *************************************************/ #include @@ -85,10 +86,10 @@ volatile uint8_t timer5_pin_mask; #endif -// MLS: This does not make sense, the 3 options are the same #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) #define AVAILABLE_TONE_PINS 1 +#define USE_TIMER2 const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 3, 4, 5, 1, 0 */ }; static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255, 255, 255, 255 */ }; @@ -96,13 +97,23 @@ static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255, 255, 255, 25 #elif defined(__AVR_ATmega8__) #define AVAILABLE_TONE_PINS 1 +#define USE_TIMER2 const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1 */ }; static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255 */ }; +#elif defined(__AVR_ATmega32U4__) + +#define AVAILABLE_TONE_PINS 1 +#define USE_TIMER3 + +const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 3 /*, 1 */ }; +static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255 */ }; + #else #define AVAILABLE_TONE_PINS 1 +#define USE_TIMER2 // Leave timer 0 to last. const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1, 0 */ }; @@ -480,8 +491,7 @@ void noTone(uint8_t _pin) digitalWrite(_pin, 0); } -#if 0 -#if !defined(__AVR_ATmega8__) +#ifdef USE_TIMER0 ISR(TIMER0_COMPA_vect) { if (timer0_toggle_count != 0) @@ -501,6 +511,7 @@ ISR(TIMER0_COMPA_vect) #endif +#ifdef USE_TIMER1 ISR(TIMER1_COMPA_vect) { if (timer1_toggle_count != 0) @@ -520,6 +531,7 @@ ISR(TIMER1_COMPA_vect) #endif +#ifdef USE_TIMER2 ISR(TIMER2_COMPA_vect) { @@ -541,12 +553,10 @@ ISR(TIMER2_COMPA_vect) // *timer2_pin_port &= ~(timer2_pin_mask); // keep pin low after stop } } +#endif - -//#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) -#if 0 - +#ifdef USE_TIMER3 ISR(TIMER3_COMPA_vect) { if (timer3_toggle_count != 0) @@ -563,7 +573,10 @@ ISR(TIMER3_COMPA_vect) *timer3_pin_port &= ~(timer3_pin_mask); // keep pin low after stop } } +#endif + +#ifdef USE_TIMER4 ISR(TIMER4_COMPA_vect) { if (timer4_toggle_count != 0) @@ -580,7 +593,10 @@ ISR(TIMER4_COMPA_vect) *timer4_pin_port &= ~(timer4_pin_mask); // keep pin low after stop } } +#endif + +#ifdef USE_TIMER5 ISR(TIMER5_COMPA_vect) { if (timer5_toggle_count != 0) @@ -597,5 +613,4 @@ ISR(TIMER5_COMPA_vect) *timer5_pin_port &= ~(timer5_pin_mask); // keep pin low after stop } } - #endif -- cgit v1.2.3-18-g5258 From b9bbc71dca6c1e7fcf7c5eddb28987c8ad121a2c Mon Sep 17 00:00:00 2001 From: Alarus Date: Sun, 12 Aug 2012 20:18:50 +0600 Subject: Update hardware/arduino/cores/arduino/HardwareSerial.h Adding advanced begin (); with the ability to specify the length of bits, parity, stop bits. --- cores/arduino/HardwareSerial.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'cores') diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h index bf4924c..a04bb66 100644 --- a/cores/arduino/HardwareSerial.h +++ b/cores/arduino/HardwareSerial.h @@ -16,7 +16,7 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Modified 28 September 2010 by Mark Sproul + Modified 12 August 2012 by Alarus */ #ifndef HardwareSerial_h @@ -37,6 +37,7 @@ class HardwareSerial : public Stream volatile uint8_t *_ubrrl; volatile uint8_t *_ucsra; volatile uint8_t *_ucsrb; + volatile uint8_t *_ucsrc; volatile uint8_t *_udr; uint8_t _rxen; uint8_t _txen; @@ -47,9 +48,10 @@ class HardwareSerial : public Stream HardwareSerial(ring_buffer *rx_buffer, ring_buffer *tx_buffer, volatile uint8_t *ubrrh, volatile uint8_t *ubrrl, volatile uint8_t *ucsra, volatile uint8_t *ucsrb, - volatile uint8_t *udr, + volatile uint8_t *ucsrc, volatile uint8_t *udr, uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udrie, uint8_t u2x); void begin(unsigned long); + void begin(unsigned long, byte, char, byte); void end(); virtual int available(void); virtual int peek(void); -- cgit v1.2.3-18-g5258 From 03a4b50b8e95a234e9f9cf322b744890369dac90 Mon Sep 17 00:00:00 2001 From: Alarus Date: Sun, 12 Aug 2012 20:23:00 +0600 Subject: Update hardware/arduino/cores/arduino/HardwareSerial.h Adding advanced begin (); with the ability to specify the length of bits, parity, stop bits. --- cores/arduino/HardwareSerial.h | 1 + 1 file changed, 1 insertion(+) (limited to 'cores') diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h index a04bb66..699015a 100644 --- a/cores/arduino/HardwareSerial.h +++ b/cores/arduino/HardwareSerial.h @@ -16,6 +16,7 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Modified 28 September 2010 by Mark Sproul Modified 12 August 2012 by Alarus */ -- cgit v1.2.3-18-g5258 From 1f6dd923134ed2f61bc5a33cf3fd2a52e41301f8 Mon Sep 17 00:00:00 2001 From: Alarus Date: Sun, 12 Aug 2012 20:57:57 +0600 Subject: Update hardware/arduino/cores/arduino/HardwareSerial.cpp Adding advanced begin (); with the ability to specify the length of bits, parity, stop bits. --- cores/arduino/HardwareSerial.cpp | 139 ++++++++++++++++++++++++++++++++++----- 1 file changed, 124 insertions(+), 15 deletions(-) (limited to 'cores') diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index f40ddee..820835f 100644 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -18,6 +18,7 @@ Modified 23 November 2006 by David A. Mellis Modified 28 September 2010 by Mark Sproul + Modified 12 August 2012 by Alarus */ #include @@ -109,13 +110,22 @@ inline void store_char(unsigned char c, ring_buffer *buffer) #endif { #if defined(UDR0) - unsigned char c = UDR0; + if (bit_is_clear(UCSR0A, UPE0)) { + unsigned char c = UDR0; + store_char(c, &rx_buffer); + } else { + unsigned char c = UDR0; + }; #elif defined(UDR) - unsigned char c = UDR; + if (bit_is_clear(UCSRA, PE)) { + unsigned char c = UDR; + store_char(c, &rx_buffer); + } else { + unsigned char c = UDR; + }; #else #error UDR not defined #endif - store_char(c, &rx_buffer); } #endif #endif @@ -126,8 +136,12 @@ inline void store_char(unsigned char c, ring_buffer *buffer) #define serialEvent1_implemented SIGNAL(USART1_RX_vect) { - unsigned char c = UDR1; - store_char(c, &rx_buffer1); + if (bit_is_clear(UCSR1A, UPE1)) { + unsigned char c = UDR1; + store_char(c, &rx_buffer1); + } else { + unsigned char c = UDR1; + }; } #elif defined(SIG_USART1_RECV) #error SIG_USART1_RECV @@ -139,8 +153,12 @@ inline void store_char(unsigned char c, ring_buffer *buffer) #define serialEvent2_implemented SIGNAL(USART2_RX_vect) { - unsigned char c = UDR2; - store_char(c, &rx_buffer2); + if (bit_is_clear(UCSR2A, UPE2)) { + unsigned char c = UDR2; + store_char(c, &rx_buffer2); + } else { + unsigned char c = UDR2; + }; } #elif defined(SIG_USART2_RECV) #error SIG_USART2_RECV @@ -152,8 +170,12 @@ inline void store_char(unsigned char c, ring_buffer *buffer) #define serialEvent3_implemented SIGNAL(USART3_RX_vect) { - unsigned char c = UDR3; - store_char(c, &rx_buffer3); + if (bit_is_clear(UCSR3A, UPE3)) { + unsigned char c = UDR3; + store_char(c, &rx_buffer3); + } else { + unsigned char c = UDR3; + }; } #elif defined(SIG_USART3_RECV) #error SIG_USART3_RECV @@ -274,7 +296,7 @@ ISR(USART3_UDRE_vect) HardwareSerial::HardwareSerial(ring_buffer *rx_buffer, ring_buffer *tx_buffer, volatile uint8_t *ubrrh, volatile uint8_t *ubrrl, volatile uint8_t *ucsra, volatile uint8_t *ucsrb, - volatile uint8_t *udr, + volatile uint8_t *ucsrc, volatile uint8_t *udr, uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udrie, uint8_t u2x) { _rx_buffer = rx_buffer; @@ -283,6 +305,7 @@ HardwareSerial::HardwareSerial(ring_buffer *rx_buffer, ring_buffer *tx_buffer, _ubrrl = ubrrl; _ucsra = ucsra; _ucsrb = ucsrb; + _ucsrc = ucsrc; _udr = udr; _rxen = rxen; _txen = txen; @@ -333,6 +356,92 @@ try_again: cbi(*_ucsrb, _udrie); } +void HardwareSerial::begin(unsigned long baud, byte databits, char parity, byte stopbits) +{ + uint16_t baud_setting; + uint8_t config_setting; + bool use_u2x = true; + +#if F_CPU == 16000000UL + // hardcoded exception for compatibility with the bootloader shipped + // with the Duemilanove and previous boards and the firmware on the 8U2 + // on the Uno and Mega 2560. + if (baud == 57600) { + use_u2x = false; + } +#endif + +try_again: + + if (use_u2x) { + *_ucsra = 1 << _u2x; + baud_setting = (F_CPU / 4 / baud - 1) / 2; + } else { + *_ucsra = 0; + baud_setting = (F_CPU / 8 / baud - 1) / 2; + } + + if ((baud_setting > 4095) && use_u2x) + { + use_u2x = false; + goto try_again; + } + + // assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register) + *_ubrrh = baud_setting >> 8; + *_ubrrl = baud_setting; + + //set number of data bits + config_setting = *_ubrrh; + config_setting = *_ucsrc; + if (databits == 5) + { + config_setting |= B10000000; + } + else if (databits == 6) + { + config_setting |= B10000010; + } + else if (databits == 7) + { + config_setting |= B10000100; + } + else // (databits == 8) + { + config_setting |= B10000110; + } + + //set parity + if ((parity == 'O')|(parity == 'o')) + { + config_setting |= B10110000; + } + else if ((parity == 'E')|(parity == 'e')) + { + config_setting |= B10100000; + } + else // ((parity == 'N')|(parity == 'n'))) + { + config_setting |= B10000000; + } + + //set number of stop bits + if (stopbits == 2) + { + config_setting |= B10001000; + } + else // (stopbits == 1) + { + config_setting |= B10000000; + } + *_ucsrc = config_setting + + sbi(*_ucsrb, _rxen); + sbi(*_ucsrb, _txen); + sbi(*_ucsrb, _rxcie); + cbi(*_ucsrb, _udrie); +} + void HardwareSerial::end() { // wait for transmission of outgoing data @@ -405,9 +514,9 @@ HardwareSerial::operator bool() { // Preinstantiate Objects ////////////////////////////////////////////////////// #if defined(UBRRH) && defined(UBRRL) - HardwareSerial Serial(&rx_buffer, &tx_buffer, &UBRRH, &UBRRL, &UCSRA, &UCSRB, &UDR, RXEN, TXEN, RXCIE, UDRIE, U2X); + HardwareSerial Serial(&rx_buffer, &tx_buffer, &UBRRH, &UBRRL, &UCSRA, &UCSRB, &UCSRC, &UDR, RXEN, TXEN, RXCIE, UDRIE, U2X); #elif defined(UBRR0H) && defined(UBRR0L) - HardwareSerial Serial(&rx_buffer, &tx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRIE0, U2X0); + HardwareSerial Serial(&rx_buffer, &tx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UCSR0C, &UDR0, RXEN0, TXEN0, RXCIE0, UDRIE0, U2X0); #elif defined(USBCON) // do nothing - Serial object and buffers are initialized in CDC code #else @@ -415,13 +524,13 @@ HardwareSerial::operator bool() { #endif #if defined(UBRR1H) - HardwareSerial Serial1(&rx_buffer1, &tx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UDR1, RXEN1, TXEN1, RXCIE1, UDRIE1, U2X1); + HardwareSerial Serial1(&rx_buffer1, &tx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UCSR1C, &UDR1, RXEN1, TXEN1, RXCIE1, UDRIE1, U2X1); #endif #if defined(UBRR2H) - HardwareSerial Serial2(&rx_buffer2, &tx_buffer2, &UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UDR2, RXEN2, TXEN2, RXCIE2, UDRIE2, U2X2); + HardwareSerial Serial2(&rx_buffer2, &tx_buffer2, &UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UCSR2C, &UDR2, RXEN2, TXEN2, RXCIE2, UDRIE2, U2X2); #endif #if defined(UBRR3H) - HardwareSerial Serial3(&rx_buffer3, &tx_buffer3, &UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UDR3, RXEN3, TXEN3, RXCIE3, UDRIE3, U2X3); + HardwareSerial Serial3(&rx_buffer3, &tx_buffer3, &UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UCSR3C, &UDR3, RXEN3, TXEN3, RXCIE3, UDRIE3, U2X3); #endif #endif // whole file -- cgit v1.2.3-18-g5258 From ed699cf636cfe2e269ef901f3762b213cf46632f Mon Sep 17 00:00:00 2001 From: Alarus Date: Sun, 12 Aug 2012 21:35:48 +0600 Subject: Update hardware/arduino/cores/arduino/HardwareSerial.cpp Adding advanced begin (); with the ability to specify the length of bits, parity, stop bits. --- cores/arduino/HardwareSerial.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cores') diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index 820835f..7edfa84 100644 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -117,7 +117,7 @@ inline void store_char(unsigned char c, ring_buffer *buffer) unsigned char c = UDR0; }; #elif defined(UDR) - if (bit_is_clear(UCSRA, PE)) { + if (bit_is_clear(UCSRA, PE)) { unsigned char c = UDR; store_char(c, &rx_buffer); } else { -- cgit v1.2.3-18-g5258 From 0c0defa64508ba497e7196230befb2e08b602fc0 Mon Sep 17 00:00:00 2001 From: Alarus Date: Sun, 12 Aug 2012 22:07:42 +0600 Subject: Update hardware/arduino/cores/arduino/HardwareSerial.cpp Adding advanced begin (); with the ability to specify the length of bits, parity, stop bits. --- cores/arduino/HardwareSerial.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cores') diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index 7edfa84..2307735 100644 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -434,7 +434,7 @@ try_again: { config_setting |= B10000000; } - *_ucsrc = config_setting + *_ucsrc = config_setting; sbi(*_ucsrb, _rxen); sbi(*_ucsrb, _txen); -- cgit v1.2.3-18-g5258 From b6faa6e254b933a1ef29b1ddee2513075f7cb1ba Mon Sep 17 00:00:00 2001 From: Alarus Date: Tue, 14 Aug 2012 19:50:36 +0600 Subject: Update hardware/arduino/cores/arduino/HardwareSerial.cpp New Serial.begin(baud, config); --- cores/arduino/HardwareSerial.cpp | 54 ++++++---------------------------------- 1 file changed, 7 insertions(+), 47 deletions(-) (limited to 'cores') diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index 2307735..2d6d25f 100644 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -18,7 +18,7 @@ Modified 23 November 2006 by David A. Mellis Modified 28 September 2010 by Mark Sproul - Modified 12 August 2012 by Alarus + Modified 14 August 2012 by Alarus */ #include @@ -356,10 +356,10 @@ try_again: cbi(*_ucsrb, _udrie); } -void HardwareSerial::begin(unsigned long baud, byte databits, char parity, byte stopbits) +void HardwareSerial::begin(unsigned long baud, byte config) { uint16_t baud_setting; - uint8_t config_setting; + uint8_t current_config; bool use_u2x = true; #if F_CPU == 16000000UL @@ -392,49 +392,10 @@ try_again: *_ubrrl = baud_setting; //set number of data bits - config_setting = *_ubrrh; - config_setting = *_ucsrc; - if (databits == 5) - { - config_setting |= B10000000; - } - else if (databits == 6) - { - config_setting |= B10000010; - } - else if (databits == 7) - { - config_setting |= B10000100; - } - else // (databits == 8) - { - config_setting |= B10000110; - } - - //set parity - if ((parity == 'O')|(parity == 'o')) - { - config_setting |= B10110000; - } - else if ((parity == 'E')|(parity == 'e')) - { - config_setting |= B10100000; - } - else // ((parity == 'N')|(parity == 'n'))) - { - config_setting |= B10000000; - } - - //set number of stop bits - if (stopbits == 2) - { - config_setting |= B10001000; - } - else // (stopbits == 1) - { - config_setting |= B10000000; - } - *_ucsrc = config_setting; + current_config = *_ubrrh; + current_config = *_ucsrc; + current_config |= config; + *_ucsrc = current_config; sbi(*_ucsrb, _rxen); sbi(*_ucsrb, _txen); @@ -534,4 +495,3 @@ HardwareSerial::operator bool() { #endif #endif // whole file - -- cgit v1.2.3-18-g5258 From 1cda182f33ae6b1f87065b1a097f3d192ef5b6f6 Mon Sep 17 00:00:00 2001 From: Alarus Date: Tue, 14 Aug 2012 19:52:00 +0600 Subject: Update hardware/arduino/cores/arduino/HardwareSerial.h New Serial.begin(baud, config); --- cores/arduino/HardwareSerial.h | 54 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) (limited to 'cores') diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h index 699015a..07445a0 100644 --- a/cores/arduino/HardwareSerial.h +++ b/cores/arduino/HardwareSerial.h @@ -17,7 +17,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Modified 28 September 2010 by Mark Sproul - Modified 12 August 2012 by Alarus + Modified 14 August 2012 by Alarus */ #ifndef HardwareSerial_h @@ -52,7 +52,7 @@ class HardwareSerial : public Stream volatile uint8_t *ucsrc, volatile uint8_t *udr, uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udrie, uint8_t u2x); void begin(unsigned long); - void begin(unsigned long, byte, char, byte); + void begin(unsigned long, byte); void end(); virtual int available(void); virtual int peek(void); @@ -63,6 +63,56 @@ class HardwareSerial : public Stream operator bool(); }; +// Define config for Serial.begin(baud, config); +#define _5n1_ 0x80 +#define _5N1_ 0x80 +#define _6n1_ 0x82 +#define _6N1_ 0x82 +#define _7n1_ 0x84 +#define _7N1_ 0x84 +#define _8n1_ 0x86 +#define _8N1_ 0x86 +#define _5n2_ 0x88 +#define _5N2_ 0x88 +#define _6n2_ 0x8A +#define _6N2_ 0x8A +#define _7n2_ 0x8C +#define _7N2_ 0x8C +#define _8n2_ 0x8E +#define _8N2_ 0x8E +#define _5e1_ 0xA0 +#define _5E1_ 0xA0 +#define _6e1_ 0xA2 +#define _6E1_ 0xA2 +#define _7e1_ 0xA4 +#define _7E1_ 0xA4 +#define _8e1_ 0xA6 +#define _8E1_ 0xA6 +#define _5e2_ 0xA8 +#define _5E2_ 0xA8 +#define _6e2_ 0xAA +#define _6E2_ 0xAA +#define _7e2_ 0xAC +#define _7E2_ 0xAC +#define _8e2_ 0xAE +#define _8E2_ 0xAE +#define _5o1_ 0xB0 +#define _5O1_ 0xB0 +#define _6o1_ 0xB2 +#define _6O1_ 0xB2 +#define _7o1_ 0xB4 +#define _7O1_ 0xB4 +#define _8o1_ 0xB6 +#define _8O1_ 0xB6 +#define _5o2_ 0xB8 +#define _5O2_ 0xB8 +#define _6o2_ 0xBA +#define _6O2_ 0xBA +#define _7o2_ 0xBC +#define _7O2_ 0xBC +#define _8o2_ 0xBE +#define _8O2_ 0xBE + #if defined(UBRRH) || defined(UBRR0H) extern HardwareSerial Serial; #elif defined(USBCON) -- cgit v1.2.3-18-g5258 From af8ff1d1e0ffd71deee03fe7f17423f8bf22be00 Mon Sep 17 00:00:00 2001 From: Alarus Date: Tue, 14 Aug 2012 19:55:13 +0600 Subject: Update hardware/arduino/cores/arduino/HardwareSerial.cpp New Serial.begin(baud, config); --- cores/arduino/HardwareSerial.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'cores') diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index 2d6d25f..1ae90c3 100644 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -495,3 +495,4 @@ HardwareSerial::operator bool() { #endif #endif // whole file + -- cgit v1.2.3-18-g5258 From c40ab91c41bc9e2ef99600baf8c47dbe191aeb0c Mon Sep 17 00:00:00 2001 From: Adam Dunlap Date: Thu, 16 Aug 2012 20:59:33 -0700 Subject: Fix issue 866 Fix issue 866 by adding a const qualifier to what the F macro casts to. --- cores/arduino/WString.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cores') diff --git a/cores/arduino/WString.h b/cores/arduino/WString.h index d76d2a3..947325e 100644 --- a/cores/arduino/WString.h +++ b/cores/arduino/WString.h @@ -35,7 +35,7 @@ // -std=c++0x class __FlashStringHelper; -#define F(string_literal) (reinterpret_cast<__FlashStringHelper *>(PSTR(string_literal))) +#define F(string_literal) (reinterpret_cast(PSTR(string_literal))) // An inherited class for holding the result of a concatenation. These // result objects are assumed to be writable by subsequent concatenations. -- cgit v1.2.3-18-g5258 From 00ab72619ea4364ed446d929e77143ed467514c1 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Tue, 28 Aug 2012 08:02:54 -0400 Subject: Serial.flush() waits for last character to be transmitted (michele.mazzucchi) http://code.google.com/p/arduino/issues/detail?id=871 --- cores/arduino/HardwareSerial.cpp | 10 ++++++++-- cores/arduino/HardwareSerial.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'cores') diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index f40ddee..867bc9e 100644 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -327,6 +327,8 @@ try_again: *_ubrrh = baud_setting >> 8; *_ubrrl = baud_setting; + transmitting = false; + sbi(*_ucsrb, _rxen); sbi(*_ucsrb, _txen); sbi(*_ucsrb, _rxcie); @@ -376,8 +378,9 @@ int HardwareSerial::read(void) void HardwareSerial::flush() { - while (_tx_buffer->head != _tx_buffer->tail) - ; + // UDR is kept full while the buffer is not empty, so TXC triggers when EMPTY && SENT + while (transmitting && ! (*_ucsra & _BV(TXC0))); + transmitting = false; } size_t HardwareSerial::write(uint8_t c) @@ -394,6 +397,9 @@ size_t HardwareSerial::write(uint8_t c) _tx_buffer->head = i; sbi(*_ucsrb, _udrie); + // clear the TXC bit -- "can be cleared by writing a one to its bit location" + transmitting = true; + sbi(*_ucsra, TXC0); return 1; } diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h index bf4924c..5bceb75 100644 --- a/cores/arduino/HardwareSerial.h +++ b/cores/arduino/HardwareSerial.h @@ -43,6 +43,7 @@ class HardwareSerial : public Stream uint8_t _rxcie; uint8_t _udrie; uint8_t _u2x; + bool transmitting; public: HardwareSerial(ring_buffer *rx_buffer, ring_buffer *tx_buffer, volatile uint8_t *ubrrh, volatile uint8_t *ubrrl, -- cgit v1.2.3-18-g5258 From c29b408a9d420f1850b6c6692f37d11b22e7bedb Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Wed, 29 Aug 2012 16:32:05 -0400 Subject: Adding overloads so Serial.write(0) works. http://code.google.com/p/arduino/issues/detail?id=1006 --- cores/arduino/HardwareSerial.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'cores') diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h index 5bceb75..9a42773 100644 --- a/cores/arduino/HardwareSerial.h +++ b/cores/arduino/HardwareSerial.h @@ -57,6 +57,10 @@ class HardwareSerial : public Stream virtual int read(void); virtual void flush(void); virtual size_t write(uint8_t); + inline size_t write(unsigned long n) { return write((uint8_t)n); } + inline size_t write(long n) { return write((uint8_t)n); } + inline size_t write(unsigned int n) { return write((uint8_t)n); } + inline size_t write(int n) { return write((uint8_t)n); } using Print::write; // pull in write(str) and write(buf, size) from Print operator bool(); }; -- cgit v1.2.3-18-g5258 From 912092b03fddf38789ec680da4e619bedccaf559 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Wed, 29 Aug 2012 20:52:30 -0400 Subject: Fixing ATmega8 breakage from flush() change. (WestFW) http://code.google.com/p/arduino/issues/detail?id=1019 --- cores/arduino/HardwareSerial.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'cores') diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h index 9a42773..eadaaa7 100644 --- a/cores/arduino/HardwareSerial.h +++ b/cores/arduino/HardwareSerial.h @@ -81,6 +81,15 @@ class HardwareSerial : public Stream extern HardwareSerial Serial3; #endif +/* + * on ATmega8, the uart and its bits are not numbered, so there is no "TXC0" + * definition. It is slightly cleaner to define this here instead of having + * conditional code in the cpp module. + */ +#if !defined(TXC0) +#define TXC0 TXC +#endif + extern void serialEventRun(void) __attribute__((weak)); #endif -- cgit v1.2.3-18-g5258 From 70b6f11d632d9549cd2ec20b9a7fbd1136c79d72 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Thu, 30 Aug 2012 07:44:25 -0400 Subject: Fixing Serial.flush() breakage on Leonardo (WestFW). http://code.google.com/p/arduino/issues/detail?id=1020 --- cores/arduino/HardwareSerial.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'cores') diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h index eadaaa7..d4ccbec 100644 --- a/cores/arduino/HardwareSerial.h +++ b/cores/arduino/HardwareSerial.h @@ -87,7 +87,14 @@ class HardwareSerial : public Stream * conditional code in the cpp module. */ #if !defined(TXC0) +#if defined(TXC) #define TXC0 TXC +#elif defined(TXC1) +// Some devices have uart1 but no uart0 +#define TXC0 TXC1 +#else +#error TXC0 not definable in HardwareSerial.h +#endif #endif extern void serialEventRun(void) __attribute__((weak)); -- cgit v1.2.3-18-g5258 From 1650169f5d06231bc67bd5cffc484775b34f38c6 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Thu, 30 Aug 2012 08:21:12 -0400 Subject: Renaming serial config constants to, e.g., SERIAL_8N1. --- cores/arduino/HardwareSerial.h | 72 ++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 48 deletions(-) (limited to 'cores') diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h index 8f00d15..dcbaebc 100644 --- a/cores/arduino/HardwareSerial.h +++ b/cores/arduino/HardwareSerial.h @@ -69,54 +69,30 @@ class HardwareSerial : public Stream }; // Define config for Serial.begin(baud, config); -#define _5n1_ 0x80 -#define _5N1_ 0x80 -#define _6n1_ 0x82 -#define _6N1_ 0x82 -#define _7n1_ 0x84 -#define _7N1_ 0x84 -#define _8n1_ 0x86 -#define _8N1_ 0x86 -#define _5n2_ 0x88 -#define _5N2_ 0x88 -#define _6n2_ 0x8A -#define _6N2_ 0x8A -#define _7n2_ 0x8C -#define _7N2_ 0x8C -#define _8n2_ 0x8E -#define _8N2_ 0x8E -#define _5e1_ 0xA0 -#define _5E1_ 0xA0 -#define _6e1_ 0xA2 -#define _6E1_ 0xA2 -#define _7e1_ 0xA4 -#define _7E1_ 0xA4 -#define _8e1_ 0xA6 -#define _8E1_ 0xA6 -#define _5e2_ 0xA8 -#define _5E2_ 0xA8 -#define _6e2_ 0xAA -#define _6E2_ 0xAA -#define _7e2_ 0xAC -#define _7E2_ 0xAC -#define _8e2_ 0xAE -#define _8E2_ 0xAE -#define _5o1_ 0xB0 -#define _5O1_ 0xB0 -#define _6o1_ 0xB2 -#define _6O1_ 0xB2 -#define _7o1_ 0xB4 -#define _7O1_ 0xB4 -#define _8o1_ 0xB6 -#define _8O1_ 0xB6 -#define _5o2_ 0xB8 -#define _5O2_ 0xB8 -#define _6o2_ 0xBA -#define _6O2_ 0xBA -#define _7o2_ 0xBC -#define _7O2_ 0xBC -#define _8o2_ 0xBE -#define _8O2_ 0xBE +#define SERIAL_5N1 0x80 +#define SERIAL_6N1 0x82 +#define SERIAL_7N1 0x84 +#define SERIAL_8N1 0x86 +#define SERIAL_5N2 0x88 +#define SERIAL_6N2 0x8A +#define SERIAL_7N2 0x8C +#define SERIAL_8N2 0x8E +#define SERIAL_5E1 0xA0 +#define SERIAL_6E1 0xA2 +#define SERIAL_7E1 0xA4 +#define SERIAL_8E1 0xA6 +#define SERIAL_5E2 0xA8 +#define SERIAL_6E2 0xAA +#define SERIAL_7E2 0xAC +#define SERIAL_8E2 0xAE +#define SERIAL_5O1 0xB0 +#define SERIAL_6O1 0xB2 +#define SERIAL_7O1 0xB4 +#define SERIAL_8O1 0xB6 +#define SERIAL_5O2 0xB8 +#define SERIAL_6O2 0xBA +#define SERIAL_7O2 0xBC +#define SERIAL_8O2 0xBE #if defined(UBRRH) || defined(UBRR0H) extern HardwareSerial Serial; -- cgit v1.2.3-18-g5258 From 5ca747e312e70aa87b6056c15f6dae41c2f0f20c Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Thu, 30 Aug 2012 08:47:35 -0400 Subject: Changing setting of the UMSELn bits (for UART mode) and serial config values. Before, the UMSELn1 bit was being to set to 1, putting the UART into a reserved mode. Now, we only set the high (0x80) bit to 1 for the ATmega8, which is needed to access UCSRnC (whose i/o address is shared with UBRRH). Also, no longer bitwise-or the new config with the existing register value, because we're actually configuring all the settings in the register. (We're not using UCPOL, but it's supposed to be 0 in asynchronous mode.) --- cores/arduino/HardwareSerial.cpp | 10 ++++----- cores/arduino/HardwareSerial.h | 48 ++++++++++++++++++++-------------------- 2 files changed, 29 insertions(+), 29 deletions(-) (limited to 'cores') diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index e512421..2e64acb 100644 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -393,11 +393,11 @@ try_again: *_ubrrh = baud_setting >> 8; *_ubrrl = baud_setting; - //set number of data bits - current_config = *_ubrrh; - current_config = *_ucsrc; - current_config |= config; - *_ucsrc = current_config; + //set the data bits, parity, and stop bits +#if defined(__AVR_ATmega8__) + config |= 0x80; // select UCSRC register (shared with UBRRH) +#endif + *_ucsrc = config; sbi(*_ucsrb, _rxen); sbi(*_ucsrb, _txen); diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h index dcbaebc..c2d0ce9 100644 --- a/cores/arduino/HardwareSerial.h +++ b/cores/arduino/HardwareSerial.h @@ -69,30 +69,30 @@ class HardwareSerial : public Stream }; // Define config for Serial.begin(baud, config); -#define SERIAL_5N1 0x80 -#define SERIAL_6N1 0x82 -#define SERIAL_7N1 0x84 -#define SERIAL_8N1 0x86 -#define SERIAL_5N2 0x88 -#define SERIAL_6N2 0x8A -#define SERIAL_7N2 0x8C -#define SERIAL_8N2 0x8E -#define SERIAL_5E1 0xA0 -#define SERIAL_6E1 0xA2 -#define SERIAL_7E1 0xA4 -#define SERIAL_8E1 0xA6 -#define SERIAL_5E2 0xA8 -#define SERIAL_6E2 0xAA -#define SERIAL_7E2 0xAC -#define SERIAL_8E2 0xAE -#define SERIAL_5O1 0xB0 -#define SERIAL_6O1 0xB2 -#define SERIAL_7O1 0xB4 -#define SERIAL_8O1 0xB6 -#define SERIAL_5O2 0xB8 -#define SERIAL_6O2 0xBA -#define SERIAL_7O2 0xBC -#define SERIAL_8O2 0xBE +#define SERIAL_5N1 0x00 +#define SERIAL_6N1 0x02 +#define SERIAL_7N1 0x04 +#define SERIAL_8N1 0x06 +#define SERIAL_5N2 0x08 +#define SERIAL_6N2 0x0A +#define SERIAL_7N2 0x0C +#define SERIAL_8N2 0x0E +#define SERIAL_5E1 0x20 +#define SERIAL_6E1 0x22 +#define SERIAL_7E1 0x24 +#define SERIAL_8E1 0x26 +#define SERIAL_5E2 0x28 +#define SERIAL_6E2 0x2A +#define SERIAL_7E2 0x2C +#define SERIAL_8E2 0x2E +#define SERIAL_5O1 0x30 +#define SERIAL_6O1 0x32 +#define SERIAL_7O1 0x34 +#define SERIAL_8O1 0x36 +#define SERIAL_5O2 0x38 +#define SERIAL_6O2 0x3A +#define SERIAL_7O2 0x3C +#define SERIAL_8O2 0x3E #if defined(UBRRH) || defined(UBRR0H) extern HardwareSerial Serial; -- cgit v1.2.3-18-g5258 From dc86d26a11ffe3e1ac9add8fb2d397fbee20984b Mon Sep 17 00:00:00 2001 From: Peter Van Hoyweghen Date: Mon, 30 Jul 2012 21:54:19 +0200 Subject: Avoid serial buffer overrun on leonardo --- cores/arduino/CDC.cpp | 10 ++++++++-- cores/arduino/USBCore.cpp | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'cores') diff --git a/cores/arduino/CDC.cpp b/cores/arduino/CDC.cpp index 1ee3a48..701e483 100644 --- a/cores/arduino/CDC.cpp +++ b/cores/arduino/CDC.cpp @@ -141,16 +141,22 @@ void Serial_::end(void) void Serial_::accept(void) { ring_buffer *buffer = &cdc_rx_buffer; - int c = USB_Recv(CDC_RX); int i = (unsigned int)(buffer->head+1) % SERIAL_BUFFER_SIZE; // if we should be storing the received character into the location // just before the tail (meaning that the head would advance to the // current location of the tail), we're about to overflow the buffer // and so we don't write the character or advance the head. - if (i != buffer->tail) { + + // while we have room to store a byte + while (i != buffer->tail) { + int c = USB_Recv(CDC_RX); + if (c == -1) + break; // no more data buffer->buffer[buffer->head] = c; buffer->head = i; + + i = (unsigned int)(buffer->head+1) % SERIAL_BUFFER_SIZE; } } diff --git a/cores/arduino/USBCore.cpp b/cores/arduino/USBCore.cpp index 6766be6..8bcf66c 100644 --- a/cores/arduino/USBCore.cpp +++ b/cores/arduino/USBCore.cpp @@ -603,7 +603,7 @@ ISR(USB_GEN_vect) { #ifdef CDC_ENABLED USB_Flush(CDC_TX); // Send a tx frame if found - while (USB_Available(CDC_RX)) // Handle received bytes (if any) + if (USB_Available(CDC_RX)) // Handle received bytes (if any) Serial.accept(); #endif -- cgit v1.2.3-18-g5258 From 1a0f22225b9ba34c90e1104ea1281976027979c1 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Thu, 13 Sep 2012 09:19:52 -0400 Subject: Moving ATmega32U4 Timer 2 #undef's to Leonardo pins_arduino.h file. --- cores/arduino/Arduino.h | 65 ------------------------------------------------- 1 file changed, 65 deletions(-) (limited to 'cores') diff --git a/cores/arduino/Arduino.h b/cores/arduino/Arduino.h index d592aab..830c995 100755 --- a/cores/arduino/Arduino.h +++ b/cores/arduino/Arduino.h @@ -11,71 +11,6 @@ #include "binary.h" -// Workaround for wrong definitions in "iom32u4.h". -// This should be fixed in the AVR toolchain. -#ifdef __AVR_ATmega32U4__ -#undef UHCON -#undef UHINT -#undef UHIEN -#undef UHADDR -#undef UHFNUM -#undef UHFNUML -#undef UHFNUMH -#undef UHFLEN -#undef UPINRQX -#undef UPINTX -#undef UPNUM -#undef UPRST -#undef UPCONX -#undef UPCFG0X -#undef UPCFG1X -#undef UPSTAX -#undef UPCFG2X -#undef UPIENX -#undef UPDATX -#undef TCCR2A -#undef WGM20 -#undef WGM21 -#undef COM2B0 -#undef COM2B1 -#undef COM2A0 -#undef COM2A1 -#undef TCCR2B -#undef CS20 -#undef CS21 -#undef CS22 -#undef WGM22 -#undef FOC2B -#undef FOC2A -#undef TCNT2 -#undef TCNT2_0 -#undef TCNT2_1 -#undef TCNT2_2 -#undef TCNT2_3 -#undef TCNT2_4 -#undef TCNT2_5 -#undef TCNT2_6 -#undef TCNT2_7 -#undef OCR2A -#undef OCR2_0 -#undef OCR2_1 -#undef OCR2_2 -#undef OCR2_3 -#undef OCR2_4 -#undef OCR2_5 -#undef OCR2_6 -#undef OCR2_7 -#undef OCR2B -#undef OCR2_0 -#undef OCR2_1 -#undef OCR2_2 -#undef OCR2_3 -#undef OCR2_4 -#undef OCR2_5 -#undef OCR2_6 -#undef OCR2_7 -#endif - #ifdef __cplusplus extern "C"{ #endif -- cgit v1.2.3-18-g5258 From 6d296e0faba5b9910084c307a3f93cb2653bf7f8 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Tue, 9 Oct 2012 13:53:09 -0400 Subject: Adding ATmega644P check to ATmega1284P check. --- cores/arduino/Arduino.h | 2 +- cores/arduino/wiring_analog.c | 2 +- cores/arduino/wiring_private.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'cores') diff --git a/cores/arduino/Arduino.h b/cores/arduino/Arduino.h index 830c995..b265825 100755 --- a/cores/arduino/Arduino.h +++ b/cores/arduino/Arduino.h @@ -46,7 +46,7 @@ extern "C"{ #define EXTERNAL 1 #define INTERNAL 2 #else -#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284P__) +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644P__) #define INTERNAL1V1 2 #define INTERNAL2V56 3 #else diff --git a/cores/arduino/wiring_analog.c b/cores/arduino/wiring_analog.c index 0e9881f..23b01c6 100644 --- a/cores/arduino/wiring_analog.c +++ b/cores/arduino/wiring_analog.c @@ -45,7 +45,7 @@ int analogRead(uint8_t pin) if (pin >= 54) pin -= 54; // allow for channel or pin numbers #elif defined(__AVR_ATmega32U4__) if (pin >= 18) pin -= 18; // allow for channel or pin numbers -#elif defined(__AVR_ATmega1284__) +#elif defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644P__) if (pin >= 24) pin -= 24; // allow for channel or pin numbers #else if (pin >= 14) pin -= 14; // allow for channel or pin numbers diff --git a/cores/arduino/wiring_private.h b/cores/arduino/wiring_private.h index 026ce1a..f678265 100755 --- a/cores/arduino/wiring_private.h +++ b/cores/arduino/wiring_private.h @@ -54,7 +54,7 @@ extern "C"{ #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) #define EXTERNAL_NUM_INTERRUPTS 8 -#elif defined(__AVR_ATmega1284P__) +#elif defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644P__) #define EXTERNAL_NUM_INTERRUPTS 3 #elif defined(__AVR_ATmega32U4__) #define EXTERNAL_NUM_INTERRUPTS 4 -- cgit v1.2.3-18-g5258