From 58b6fd4789777660b202a0f9d531b30075c56355 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Tue, 21 Oct 2014 16:55:37 +0200 Subject: [PATCH 1/3] Fixed missing NOT_AN_INTERRUPT constant in digitalPinToInterrupt() Fixes #2379 --- build/shared/revisions.txt | 3 +++ hardware/arduino/cores/arduino/Arduino.h | 2 ++ hardware/arduino/cores/robot/Arduino.h | 2 ++ 3 files changed, 7 insertions(+) diff --git a/build/shared/revisions.txt b/build/shared/revisions.txt index 664f14ef1..beac39f85 100644 --- a/build/shared/revisions.txt +++ b/build/shared/revisions.txt @@ -5,6 +5,9 @@ ARDUINO 1.0.7 * Backported GSM from IDE 1.5.x * EthernetClien: use IANA recommended ephemeral port range, 49152-65535 (Jack Christensen, cifer-lee) +[core] +* Fixed missing NOT_AN_INTERRUPT constant in digitalPinToInterrupt() macro + ARDUINO 1.0.6 - 2014.09.16 [core] diff --git a/hardware/arduino/cores/arduino/Arduino.h b/hardware/arduino/cores/arduino/Arduino.h index 8673ab8ab..d4a22a69c 100755 --- a/hardware/arduino/cores/arduino/Arduino.h +++ b/hardware/arduino/cores/arduino/Arduino.h @@ -171,6 +171,8 @@ extern const uint8_t PROGMEM digital_pin_to_timer_PGM[]; #define NOT_A_PIN 0 #define NOT_A_PORT 0 +#define NOT_AN_INTERRUPT -1 + #ifdef ARDUINO_MAIN #define PA 1 #define PB 2 diff --git a/hardware/arduino/cores/robot/Arduino.h b/hardware/arduino/cores/robot/Arduino.h index 93a3525d6..5da518f5c 100755 --- a/hardware/arduino/cores/robot/Arduino.h +++ b/hardware/arduino/cores/robot/Arduino.h @@ -168,6 +168,8 @@ extern const uint8_t PROGMEM digital_pin_to_timer_PGM[]; #define NOT_A_PIN 0 #define NOT_A_PORT 0 +#define NOT_AN_INTERRUPT -1 + #ifdef ARDUINO_MAIN #define PA 1 #define PB 2 From 62cf4b6b55ef072ae8891ff6ea9e54905329d8d7 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Tue, 21 Oct 2014 17:18:26 +0200 Subject: [PATCH 2/3] Revert "Match return value to type in available()" This reverts commit f40e4713542fa862d5b99b256a642e001a796988. Added an hint for the buffer sizes. See #2057 Fixes #2367 --- hardware/arduino/cores/arduino/HardwareSerial.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hardware/arduino/cores/arduino/HardwareSerial.cpp b/hardware/arduino/cores/arduino/HardwareSerial.cpp index 1a2f8ce20..2a256e0cd 100644 --- a/hardware/arduino/cores/arduino/HardwareSerial.cpp +++ b/hardware/arduino/cores/arduino/HardwareSerial.cpp @@ -53,6 +53,8 @@ // using a ring buffer (I think), in which head is the index of the location // to which to write the next incoming character and tail is the index of the // location from which to read. +// NOTE: a "power of 2" buffer size is reccomended to dramatically +// optimize all the modulo operations for ring buffers. #if (RAMEND < 1000) #define SERIAL_BUFFER_SIZE 16 #else @@ -426,7 +428,7 @@ void HardwareSerial::end() int HardwareSerial::available(void) { - return (int)(SERIAL_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % SERIAL_BUFFER_SIZE; + return ((unsigned int)(SERIAL_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail)) % SERIAL_BUFFER_SIZE; } int HardwareSerial::peek(void) From 54a6d644b6349c7eb19a05b3cc1c58c12b40f85f Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Tue, 21 Oct 2014 17:40:48 +0200 Subject: [PATCH 3/3] Updated revision log --- build/shared/revisions.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/build/shared/revisions.txt b/build/shared/revisions.txt index beac39f85..c3e3eab45 100644 --- a/build/shared/revisions.txt +++ b/build/shared/revisions.txt @@ -7,6 +7,7 @@ ARDUINO 1.0.7 [core] * Fixed missing NOT_AN_INTERRUPT constant in digitalPinToInterrupt() macro +* Fixed regression in HardwareSerial::available() introduced with https://github.com/arduino/Arduino/pull/2057 ARDUINO 1.0.6 - 2014.09.16