[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:
@@ -6,9 +6,9 @@
|
|||||||
#include <sdk_private.h>
|
#include <sdk_private.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
RingBuffer buf;
|
SerialRingBuffer buf;
|
||||||
} SerialData;
|
} SerialData;
|
||||||
|
|
||||||
#define DATA ((SerialData *)data)
|
#define DATA ((SerialData *)data)
|
||||||
#define BUF (DATA->buf)
|
#define BUF (DATA->buf)
|
||||||
#define pBUF ((RingBuffer *)param)
|
#define pBUF ((SerialRingBuffer *)param)
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
using namespace arduino;
|
using namespace arduino;
|
||||||
|
|
||||||
|
typedef RingBufferN<LT_SERIAL_BUFFER_SIZE> SerialRingBuffer;
|
||||||
|
|
||||||
class SerialClass : public HardwareSerial {
|
class SerialClass : public HardwareSerial {
|
||||||
private:
|
private:
|
||||||
uint32_t port;
|
uint32_t port;
|
||||||
@@ -18,7 +20,7 @@ class SerialClass : public HardwareSerial {
|
|||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RingBuffer *buf;
|
SerialRingBuffer *buf;
|
||||||
uint32_t baudrate;
|
uint32_t baudrate;
|
||||||
uint16_t config;
|
uint16_t config;
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ typedef enum {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SoftState state;
|
SoftState state;
|
||||||
RingBuffer *buf;
|
SerialRingBuffer *buf;
|
||||||
uint8_t byte;
|
uint8_t byte;
|
||||||
pin_size_t pin;
|
pin_size_t pin;
|
||||||
void *param;
|
void *param;
|
||||||
|
|||||||
@@ -77,6 +77,10 @@
|
|||||||
#define LT_UART_DEFAULT_SERIAL LT_UART_DEFAULT_PORT
|
#define LT_UART_DEFAULT_SERIAL LT_UART_DEFAULT_PORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef LT_SERIAL_BUFFER_SIZE
|
||||||
|
#define LT_SERIAL_BUFFER_SIZE 256
|
||||||
|
#endif
|
||||||
|
|
||||||
// Misc options
|
// Misc options
|
||||||
#ifndef LT_USE_TIME
|
#ifndef LT_USE_TIME
|
||||||
#define LT_USE_TIME 0
|
#define LT_USE_TIME 0
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ void SoftwareSerial::begin(unsigned long baudrate, uint16_t config) {
|
|||||||
pinMode(data.tx.pin, OUTPUT);
|
pinMode(data.tx.pin, OUTPUT);
|
||||||
digitalWrite(data.tx.pin, HIGH);
|
digitalWrite(data.tx.pin, HIGH);
|
||||||
|
|
||||||
data.rx.buf = new RingBuffer();
|
data.rx.buf = new SerialRingBuffer();
|
||||||
data.tx.buf = new RingBuffer();
|
data.tx.buf = new SerialRingBuffer();
|
||||||
data.rx.state = SS_IDLE;
|
data.rx.state = SS_IDLE;
|
||||||
data.tx.state = SS_IDLE;
|
data.tx.state = SS_IDLE;
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
UART_TypeDef *uart;
|
UART_TypeDef *uart;
|
||||||
IRQn irq;
|
IRQn irq;
|
||||||
RingBuffer buf;
|
SerialRingBuffer buf;
|
||||||
} SerialData;
|
} SerialData;
|
||||||
|
|
||||||
#define DATA ((SerialData *)data)
|
#define DATA ((SerialData *)data)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
hal_uart_adapter_t *uart;
|
hal_uart_adapter_t *uart;
|
||||||
RingBuffer buf;
|
SerialRingBuffer buf;
|
||||||
} SerialData;
|
} SerialData;
|
||||||
|
|
||||||
#define DATA ((SerialData *)data)
|
#define DATA ((SerialData *)data)
|
||||||
|
|||||||
Reference in New Issue
Block a user