From d62d06308248e7d5d32df1a4c7a3151939984d92 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Tue, 21 Oct 2014 16:55:37 +0200 Subject: Fixed missing NOT_AN_INTERRUPT constant in digitalPinToInterrupt() Fixes #2379 --- cores/arduino/Arduino.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'cores/arduino') diff --git a/cores/arduino/Arduino.h b/cores/arduino/Arduino.h index 8673ab8..d4a22a6 100755 --- a/cores/arduino/Arduino.h +++ b/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 -- cgit v1.2.3-18-g5258 From 02f5b999581287001fb83f5304c06a3d144b3b42 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Tue, 21 Oct 2014 17:18:26 +0200 Subject: Revert "Match return value to type in available()" This reverts commit f40e4713542fa862d5b99b256a642e001a796988. Added an hint for the buffer sizes. See #2057 Fixes #2367 --- cores/arduino/HardwareSerial.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'cores/arduino') diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index 1a2f8ce..2a256e0 100644 --- a/cores/arduino/HardwareSerial.cpp +++ b/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) -- cgit v1.2.3-18-g5258