Skip to content

Commit 03cc990

Browse files
authored
[UART] Adds SerialUART::getActualBaud() (#3225)
1 parent 63180ab commit 03cc990

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

cores/rp2040/SerialUART.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ void SerialUART::begin(unsigned long baud, uint16_t config) {
239239
gpio_set_inover(_cts, _invertControl ? 1 : 0);
240240
}
241241

242-
uart_init(_uart, baud);
242+
_actualBaud = uart_init(_uart, baud);
243243
int bits, stop;
244244
uart_parity_t parity;
245245
switch (config & SERIAL_PARITY_MASK) {

cores/rp2040/SerialUART.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,19 @@ class SerialUART : public arduino::HardwareSerial {
9393
// on read)
9494
bool getBreakReceived();
9595

96+
// Returns the baud rate the uart is actually operating at vs the desired baud rate specified to begin()
97+
int getActualBaud() {
98+
return _running ? _actualBaud : 0;
99+
}
100+
96101
private:
97102
bool _running = false;
98103
uart_inst_t *_uart;
99104
pin_size_t _tx, _rx;
100105
pin_size_t _rts, _cts;
101106
gpio_function_t _fcnTx, _fcnRx, _fcnRts, _fcnCts;
102107
int _baud;
108+
int _actualBaud;
103109
mutex_t _mutex;
104110
bool _polling = false;
105111
bool _overflow;

0 commit comments

Comments
 (0)