From 5af139bb74d1c10c133eb6c7fd0b8f4c75f82f8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20=C5=9Acis=C5=82owicz?= Date: Sun, 23 Dec 2018 20:15:06 +0100 Subject: [PATCH] HardwareSerial - add changeBaudRate method (#2223) * Add updateBaudRate to hardware serial * remove flush * Fix tab --- cores/esp32/HardwareSerial.cpp | 5 +++++ cores/esp32/HardwareSerial.h | 1 + 2 files changed, 6 insertions(+) diff --git a/cores/esp32/HardwareSerial.cpp b/cores/esp32/HardwareSerial.cpp index fb6300f1..495e8687 100644 --- a/cores/esp32/HardwareSerial.cpp +++ b/cores/esp32/HardwareSerial.cpp @@ -73,6 +73,11 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in } } +void HardwareSerial::updateBaudRate(unsigned long baud) +{ + uartSetBaudRate(_uart, baud); +} + void HardwareSerial::end() { if(uartGetDebug() == _uart_nr) { diff --git a/cores/esp32/HardwareSerial.h b/cores/esp32/HardwareSerial.h index 8e312c8d..89eacf85 100644 --- a/cores/esp32/HardwareSerial.h +++ b/cores/esp32/HardwareSerial.h @@ -57,6 +57,7 @@ public: void begin(unsigned long baud, uint32_t config=SERIAL_8N1, int8_t rxPin=-1, int8_t txPin=-1, bool invert=false, unsigned long timeout_ms = 20000UL); void end(); + void updateBaudRate(unsigned long baud); int available(void); int availableForWrite(void); int peek(void);