summaryrefslogtreecommitdiff
path: root/ports/esp8266/uart.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-12-05 23:31:24 +1100
committerDamien George <damien.p.george@gmail.com>2018-12-05 23:31:24 +1100
commit52bec93755e70dc2f5bea00377190b2278954c78 (patch)
treeff65a16cca1a46adcf5c52ad04068263e2fbf0f2 /ports/esp8266/uart.c
parent9ddc182ec7195722de426d5461ed1d70d9aedf7f (diff)
esp8266/machine_uart: Add rxbuf keyword arg to UART constructor/init.
As per the machine.UART documentation, this is used to set the length of the UART RX buffer.
Diffstat (limited to 'ports/esp8266/uart.c')
-rw-r--r--ports/esp8266/uart.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/ports/esp8266/uart.c b/ports/esp8266/uart.c
index 52707f981..cf9e8f61b 100644
--- a/ports/esp8266/uart.c
+++ b/ports/esp8266/uart.c
@@ -36,7 +36,7 @@ static os_event_t uart_evt_queue[16];
// A small, static ring buffer for incoming chars
// This will only be populated if the UART is not attached to dupterm
-static byte uart_ringbuf_array[16];
+uint8 uart_ringbuf_array[UART0_STATIC_RXBUF_LEN];
static ringbuf_t uart_ringbuf = {uart_ringbuf_array, sizeof(uart_ringbuf_array), 0, 0};
static void uart0_rx_intr_handler(void *para);
@@ -269,6 +269,19 @@ void ICACHE_FLASH_ATTR uart_setup(uint8 uart) {
ETS_UART_INTR_ENABLE();
}
+int ICACHE_FLASH_ATTR uart0_get_rxbuf_len(void) {
+ return uart_ringbuf.size;
+}
+
+void ICACHE_FLASH_ATTR uart0_set_rxbuf(uint8 *buf, int len) {
+ ETS_UART_INTR_DISABLE();
+ uart_ringbuf.buf = buf;
+ uart_ringbuf.size = len;
+ uart_ringbuf.iget = 0;
+ uart_ringbuf.iput = 0;
+ ETS_UART_INTR_ENABLE();
+}
+
// Task-based UART interface
#include "py/obj.h"