From 915e4889e41b61e2b4b312ca3cddb943cb31487f Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Fri, 3 Feb 2012 17:24:29 -0500 Subject: [PATCH 1/2] Making head and tail unsigned to avoid division in serial ISR. http://code.google.com/p/arduino/issues/detail?id=776 --- hardware/arduino/cores/arduino/HardwareSerial.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hardware/arduino/cores/arduino/HardwareSerial.cpp b/hardware/arduino/cores/arduino/HardwareSerial.cpp index 1b1fa71d8..9985b78c6 100644 --- a/hardware/arduino/cores/arduino/HardwareSerial.cpp +++ b/hardware/arduino/cores/arduino/HardwareSerial.cpp @@ -46,8 +46,8 @@ struct ring_buffer { unsigned char buffer[SERIAL_BUFFER_SIZE]; - volatile int head; - volatile int tail; + volatile unsigned int head; + volatile unsigned int tail; }; #if defined(USBCON) From 3dfc2c631110d912656d3bd02c7a07d16adcb6d3 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Fri, 3 Feb 2012 17:32:54 -0500 Subject: [PATCH 2/2] Serial.print() -> Serial.write() in SD SerialPrint_P function. http://code.google.com/p/arduino/issues/detail?id=759 --- libraries/SD/utility/SdFatUtil.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/SD/utility/SdFatUtil.h b/libraries/SD/utility/SdFatUtil.h index 283fcb21a..7d6b4104f 100644 --- a/libraries/SD/utility/SdFatUtil.h +++ b/libraries/SD/utility/SdFatUtil.h @@ -56,7 +56,7 @@ static UNUSEDOK int FreeRam(void) { * \param[in] str Pointer to string stored in flash memory. */ static NOINLINE void SerialPrint_P(PGM_P str) { - for (uint8_t c; (c = pgm_read_byte(str)); str++) Serial.print(c); + for (uint8_t c; (c = pgm_read_byte(str)); str++) Serial.write(c); } //------------------------------------------------------------------------------ /**