Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[common] Make Serial RX buffer size configurable, increase default to 256 bytes #313

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cores/beken-72xx/arduino/libraries/Serial/SerialPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#include <sdk_private.h>

typedef struct {
RingBuffer buf;
SerialRingBuffer buf;
} SerialData;

#define DATA ((SerialData *)data)
#define BUF (DATA->buf)
#define pBUF ((RingBuffer *)param)
#define pBUF ((SerialRingBuffer *)param)
4 changes: 3 additions & 1 deletion cores/common/arduino/libraries/api/Serial/Serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

using namespace arduino;

typedef RingBufferN<LT_SERIAL_BUFFER_SIZE> SerialRingBuffer;

class SerialClass : public HardwareSerial {
private:
uint32_t port;
Expand All @@ -18,7 +20,7 @@ class SerialClass : public HardwareSerial {
void *data;

private:
RingBuffer *buf;
SerialRingBuffer *buf;
uint32_t baudrate;
uint16_t config;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ typedef enum {

typedef struct {
SoftState state;
RingBuffer *buf;
SerialRingBuffer *buf;
uint8_t byte;
pin_size_t pin;
void *param;
Expand Down
4 changes: 4 additions & 0 deletions cores/common/base/lt_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
#define LT_UART_DEFAULT_SERIAL LT_UART_DEFAULT_PORT
#endif

#ifndef LT_SERIAL_BUFFER_SIZE
#define LT_SERIAL_BUFFER_SIZE 256
#endif

// Misc options
#ifndef LT_USE_TIME
#define LT_USE_TIME 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ void SoftwareSerial::begin(unsigned long baudrate, uint16_t config) {
pinMode(data.tx.pin, OUTPUT);
digitalWrite(data.tx.pin, HIGH);

data.rx.buf = new RingBuffer();
data.tx.buf = new RingBuffer();
data.rx.buf = new SerialRingBuffer();
data.tx.buf = new SerialRingBuffer();
data.rx.state = SS_IDLE;
data.tx.state = SS_IDLE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
typedef struct {
UART_TypeDef *uart;
IRQn irq;
RingBuffer buf;
SerialRingBuffer buf;
} SerialData;

#define DATA ((SerialData *)data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

typedef struct {
hal_uart_adapter_t *uart;
RingBuffer buf;
SerialRingBuffer buf;
} SerialData;

#define DATA ((SerialData *)data)
Expand Down
Loading