[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
This commit is contained in:
Hajo Noerenberg
2025-01-13 12:14:41 +01:00
committed by GitHub
parent 3d23211c1e
commit 2ea0066536
7 changed files with 14 additions and 8 deletions

View File

@@ -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)

View File

@@ -8,6 +8,8 @@
using namespace arduino;
typedef RingBufferN<LT_SERIAL_BUFFER_SIZE> SerialRingBuffer;
class SerialClass : public HardwareSerial {
private:
uint32_t port;
@@ -18,7 +20,7 @@ class SerialClass : public HardwareSerial {
void *data;
private:
RingBuffer *buf;
SerialRingBuffer *buf;
uint32_t baudrate;
uint16_t config;

View File

@@ -27,7 +27,7 @@ typedef enum {
typedef struct {
SoftState state;
RingBuffer *buf;
SerialRingBuffer *buf;
uint8_t byte;
pin_size_t pin;
void *param;

View File

@@ -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

View File

@@ -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;

View File

@@ -8,7 +8,7 @@
typedef struct {
UART_TypeDef *uart;
IRQn irq;
RingBuffer buf;
SerialRingBuffer buf;
} SerialData;
#define DATA ((SerialData *)data)

View File

@@ -7,7 +7,7 @@
typedef struct {
hal_uart_adapter_t *uart;
RingBuffer buf;
SerialRingBuffer buf;
} SerialData;
#define DATA ((SerialData *)data)