From e6642ca0dc3e6fbc2502871abca5e9a8da48bbae Mon Sep 17 00:00:00 2001 From: Nico Date: Mon, 2 Feb 2015 20:36:12 +0100 Subject: [PATCH] Correct undefined Serial Buffer Size https://github.com/arduino/Arduino/pull/2597 --- .gitignore | 3 +-- avr/cores/hid/HardwareSerial.h | 9 +++++++-- avr/cores/hid/USB-Core/CDC.h | 5 +++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 117ca86..432031f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -dev/* -*.pdn \ No newline at end of file +dev/* \ No newline at end of file diff --git a/avr/cores/hid/HardwareSerial.h b/avr/cores/hid/HardwareSerial.h index 7dc2aa9..203008d 100644 --- a/avr/cores/hid/HardwareSerial.h +++ b/avr/cores/hid/HardwareSerial.h @@ -34,12 +34,17 @@ // 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 !(defined(SERIAL_TX_BUFFER_SIZE) #if (RAMEND < 1000) #define SERIAL_TX_BUFFER_SIZE 16 -#define SERIAL_RX_BUFFER_SIZE 16 #else #define SERIAL_TX_BUFFER_SIZE 64 +#endif +#endif +#if !defined(SERIAL_RX_BUFFER_SIZE)) +#if (RAMEND < 1000) +#define SERIAL_RX_BUFFER_SIZE 16 +#else #define SERIAL_RX_BUFFER_SIZE 64 #endif #endif diff --git a/avr/cores/hid/USB-Core/CDC.h b/avr/cores/hid/USB-Core/CDC.h index f58bc0d..99b62fa 100644 --- a/avr/cores/hid/USB-Core/CDC.h +++ b/avr/cores/hid/USB-Core/CDC.h @@ -56,11 +56,16 @@ THE SOFTWARE. struct ring_buffer; +#ifndef SERIAL_BUFFER_SIZE #if (RAMEND < 1000) #define SERIAL_BUFFER_SIZE 16 #else #define SERIAL_BUFFER_SIZE 64 #endif +#endif +#if (SERIAL_BUFFER_SIZE>256) +#error Please lower the CDC Buffer size +#endif class Serial_ : public Stream {