From d2595129c5c473bcc5c68250007ae58311ad5b8c Mon Sep 17 00:00:00 2001 From: Nico Date: Mon, 2 Feb 2015 20:27:17 +0100 Subject: [PATCH] RX and TX Serial buffer sizes can now be defined independently Fixes #2597 --- hardware/arduino/avr/cores/arduino/HardwareSerial.h | 9 +++++++-- hardware/arduino/avr/cores/arduino/USBAPI.h | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/hardware/arduino/avr/cores/arduino/HardwareSerial.h b/hardware/arduino/avr/cores/arduino/HardwareSerial.h index 7dc2aa98c..7f4f162d6 100644 --- a/hardware/arduino/avr/cores/arduino/HardwareSerial.h +++ b/hardware/arduino/avr/cores/arduino/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/hardware/arduino/avr/cores/arduino/USBAPI.h b/hardware/arduino/avr/cores/arduino/USBAPI.h index 2fab957f9..5837b3e11 100644 --- a/hardware/arduino/avr/cores/arduino/USBAPI.h +++ b/hardware/arduino/avr/cores/arduino/USBAPI.h @@ -59,11 +59,16 @@ extern USBDevice_ USBDevice; 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 {