From fc711303ff1566eda2c1aba6b24e1e98166a7f9c Mon Sep 17 00:00:00 2001 From: Claude Heintz Date: Thu, 22 Jun 2017 09:04:18 -0500 Subject: [PATCH 1/2] Update esp32-hal-uart.c --- cores/esp32/esp32-hal-uart.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cores/esp32/esp32-hal-uart.c b/cores/esp32/esp32-hal-uart.c index 3b81a5365a3..8850728a579 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -195,6 +195,13 @@ uart_t* uartBegin(uint8_t uart_nr, uint32_t baudrate, uint32_t config, int8_t rx uartSetBaudRate(uart, baudrate); UART_MUTEX_LOCK(); uart->dev->conf0.val = config; + #define TWO_STOP_BITS_CONF 0x3 + #define ONE_STOP_BITS_CONF 0x1 + + if ( uart->dev->conf0.stop_bit_num == TWO_STOP_BITS_CONF) { + uart->dev->conf0.stop_bit_num = ONE_STOP_BITS_CONF; + uart->dev->rs485_conf.dl1_en = 1; + } UART_MUTEX_UNLOCK(); if(rxPin != -1) { From 5e14c420fa4dc65b1f1e166ed1e0dbfbb13119e8 Mon Sep 17 00:00:00 2001 From: Claude Heintz Date: Thu, 22 Jun 2017 09:07:56 -0500 Subject: [PATCH 2/2] Two Stop Bit Workaround see https://github.com/espressif/esp-idf/blob/master/components/driver/uart.c lines 118-127 --- cores/esp32/esp32-hal-uart.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cores/esp32/esp32-hal-uart.c b/cores/esp32/esp32-hal-uart.c index 8850728a579..4730720bd5c 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -196,12 +196,12 @@ uart_t* uartBegin(uint8_t uart_nr, uint32_t baudrate, uint32_t config, int8_t rx UART_MUTEX_LOCK(); uart->dev->conf0.val = config; #define TWO_STOP_BITS_CONF 0x3 - #define ONE_STOP_BITS_CONF 0x1 + #define ONE_STOP_BITS_CONF 0x1 - if ( uart->dev->conf0.stop_bit_num == TWO_STOP_BITS_CONF) { - uart->dev->conf0.stop_bit_num = ONE_STOP_BITS_CONF; - uart->dev->rs485_conf.dl1_en = 1; - } + if ( uart->dev->conf0.stop_bit_num == TWO_STOP_BITS_CONF) { + uart->dev->conf0.stop_bit_num = ONE_STOP_BITS_CONF; + uart->dev->rs485_conf.dl1_en = 1; + } UART_MUTEX_UNLOCK(); if(rxPin != -1) {