Skip to content

Commit 2ea0066

Browse files
authored
[common] Make Serial RX buffer size configurable, increase default to 256 bytes (#313)
* Make Serial RX buffer configurable and set default to 256 bytes * Replace RingBuffer by SerialRingBuffer
1 parent 3d23211 commit 2ea0066

File tree

7 files changed

+14
-8
lines changed

7 files changed

+14
-8
lines changed

cores/beken-72xx/arduino/libraries/Serial/SerialPrivate.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
#include <sdk_private.h>
77

88
typedef struct {
9-
RingBuffer buf;
9+
SerialRingBuffer buf;
1010
} SerialData;
1111

1212
#define DATA ((SerialData *)data)
1313
#define BUF (DATA->buf)
14-
#define pBUF ((RingBuffer *)param)
14+
#define pBUF ((SerialRingBuffer *)param)

cores/common/arduino/libraries/api/Serial/Serial.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
using namespace arduino;
1010

11+
typedef RingBufferN<LT_SERIAL_BUFFER_SIZE> SerialRingBuffer;
12+
1113
class SerialClass : public HardwareSerial {
1214
private:
1315
uint32_t port;
@@ -18,7 +20,7 @@ class SerialClass : public HardwareSerial {
1820
void *data;
1921

2022
private:
21-
RingBuffer *buf;
23+
SerialRingBuffer *buf;
2224
uint32_t baudrate;
2325
uint16_t config;
2426

cores/common/arduino/libraries/api/SoftwareSerial/SoftwareSerial.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ typedef enum {
2727

2828
typedef struct {
2929
SoftState state;
30-
RingBuffer *buf;
30+
SerialRingBuffer *buf;
3131
uint8_t byte;
3232
pin_size_t pin;
3333
void *param;

cores/common/base/lt_config.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@
7777
#define LT_UART_DEFAULT_SERIAL LT_UART_DEFAULT_PORT
7878
#endif
7979

80+
#ifndef LT_SERIAL_BUFFER_SIZE
81+
#define LT_SERIAL_BUFFER_SIZE 256
82+
#endif
83+
8084
// Misc options
8185
#ifndef LT_USE_TIME
8286
#define LT_USE_TIME 0

cores/realtek-amb/arduino/libraries/SoftwareSerial/SoftwareSerial.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ void SoftwareSerial::begin(unsigned long baudrate, uint16_t config) {
6363
pinMode(data.tx.pin, OUTPUT);
6464
digitalWrite(data.tx.pin, HIGH);
6565

66-
data.rx.buf = new RingBuffer();
67-
data.tx.buf = new RingBuffer();
66+
data.rx.buf = new SerialRingBuffer();
67+
data.tx.buf = new SerialRingBuffer();
6868
data.rx.state = SS_IDLE;
6969
data.tx.state = SS_IDLE;
7070

cores/realtek-ambz/arduino/libraries/Serial/SerialPrivate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
typedef struct {
99
UART_TypeDef *uart;
1010
IRQn irq;
11-
RingBuffer buf;
11+
SerialRingBuffer buf;
1212
} SerialData;
1313

1414
#define DATA ((SerialData *)data)

cores/realtek-ambz2/arduino/libraries/Serial/SerialPrivate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
typedef struct {
99
hal_uart_adapter_t *uart;
10-
RingBuffer buf;
10+
SerialRingBuffer buf;
1111
} SerialData;
1212

1313
#define DATA ((SerialData *)data)

0 commit comments

Comments
 (0)