diff --git a/cores/rp2040/SerialUART.cpp b/cores/rp2040/SerialUART.cpp index b755b463c..363b9c0e8 100644 --- a/cores/rp2040/SerialUART.cpp +++ b/cores/rp2040/SerialUART.cpp @@ -239,7 +239,7 @@ void SerialUART::begin(unsigned long baud, uint16_t config) { gpio_set_inover(_cts, _invertControl ? 1 : 0); } - uart_init(_uart, baud); + _actualBaud = uart_init(_uart, baud); int bits, stop; uart_parity_t parity; switch (config & SERIAL_PARITY_MASK) { diff --git a/cores/rp2040/SerialUART.h b/cores/rp2040/SerialUART.h index 5de17dfe9..0807b48ea 100644 --- a/cores/rp2040/SerialUART.h +++ b/cores/rp2040/SerialUART.h @@ -93,6 +93,11 @@ class SerialUART : public arduino::HardwareSerial { // on read) bool getBreakReceived(); + // Returns the baud rate the uart is actually operating at vs the desired baud rate specified to begin() + int getActualBaud() { + return _running ? _actualBaud : 0; + } + private: bool _running = false; uart_inst_t *_uart; @@ -100,6 +105,7 @@ class SerialUART : public arduino::HardwareSerial { pin_size_t _rts, _cts; gpio_function_t _fcnTx, _fcnRx, _fcnRts, _fcnCts; int _baud; + int _actualBaud; mutex_t _mutex; bool _polling = false; bool _overflow;