Skip to content

Commit 2e90af7

Browse files
NicoHoodcmaglie
authored andcommitted
RX and TX Serial buffer sizes can now be defined independently
Fixes #2597
1 parent b682456 commit 2e90af7

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

cores/arduino/HardwareSerial.h

+7-2
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,17 @@
3434
// location from which to read.
3535
// NOTE: a "power of 2" buffer size is reccomended to dramatically
3636
// optimize all the modulo operations for ring buffers.
37-
#if !(defined(SERIAL_TX_BUFFER_SIZE) && defined(SERIAL_RX_BUFFER_SIZE))
37+
#if !defined(SERIAL_TX_BUFFER_SIZE)
3838
#if (RAMEND < 1000)
3939
#define SERIAL_TX_BUFFER_SIZE 16
40-
#define SERIAL_RX_BUFFER_SIZE 16
4140
#else
4241
#define SERIAL_TX_BUFFER_SIZE 64
42+
#endif
43+
#endif
44+
#if !defined(SERIAL_RX_BUFFER_SIZE)
45+
#if (RAMEND < 1000)
46+
#define SERIAL_RX_BUFFER_SIZE 16
47+
#else
4348
#define SERIAL_RX_BUFFER_SIZE 64
4449
#endif
4550
#endif

cores/arduino/USBAPI.h

+5
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,16 @@ extern USBDevice_ USBDevice;
5959

6060
struct ring_buffer;
6161

62+
#ifndef SERIAL_BUFFER_SIZE
6263
#if (RAMEND < 1000)
6364
#define SERIAL_BUFFER_SIZE 16
6465
#else
6566
#define SERIAL_BUFFER_SIZE 64
6667
#endif
68+
#endif
69+
#if (SERIAL_BUFFER_SIZE>256)
70+
#error Please lower the CDC Buffer size
71+
#endif
6772

6873
class Serial_ : public Stream
6974
{

0 commit comments

Comments
 (0)