diff options
author | Cristian Maglie <c.maglie@bug.st> | 2014-10-21 17:47:59 +0200 |
---|---|---|
committer | Cristian Maglie <c.maglie@bug.st> | 2014-10-21 17:47:59 +0200 |
commit | 0f7a0ec4ed6fc294c2e7fe4c90faca4a56ecafc8 (patch) | |
tree | edeba4706c2bb415cfa608313a2d831e35750a1b /cores | |
parent | 5e2b7aa87674433c173e6de44a5ad47ea0410097 (diff) | |
parent | 02f5b999581287001fb83f5304c06a3d144b3b42 (diff) |
Merge branch 'master' into ide-1.5.x
Conflicts:
hardware/arduino/cores/arduino/HardwareSerial.cpp
hardware/arduino/cores/robot/Arduino.h
Diffstat (limited to 'cores')
-rw-r--r-- | cores/arduino/HardwareSerial.cpp | 2 | ||||
-rw-r--r-- | cores/arduino/HardwareSerial.h | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index 29a3366..41935e3 100644 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -152,7 +152,7 @@ void HardwareSerial::end() int HardwareSerial::available(void) { - return (int)(SERIAL_RX_BUFFER_SIZE + _rx_buffer_head - _rx_buffer_tail) % SERIAL_RX_BUFFER_SIZE; + return ((unsigned int)(SERIAL_RX_BUFFER_SIZE + _rx_buffer_head - _rx_buffer_tail)) % SERIAL_RX_BUFFER_SIZE; } int HardwareSerial::peek(void) diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h index 935934b..7dc2aa9 100644 --- a/cores/arduino/HardwareSerial.h +++ b/cores/arduino/HardwareSerial.h @@ -32,6 +32,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 !(defined(SERIAL_TX_BUFFER_SIZE) && defined(SERIAL_RX_BUFFER_SIZE)) #if (RAMEND < 1000) #define SERIAL_TX_BUFFER_SIZE 16 |