Skip to content

Commit 7cf7787

Browse files
committed
Return acheived baud rate from begin function
1 parent 0affea4 commit 7cf7787

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

cores/rp2040/SerialUART.cpp

Lines changed: 2 additions & 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+
int achieved_baud = uart_init(_uart, baud);
243243
int bits, stop;
244244
uart_parity_t parity;
245245
switch (config & SERIAL_PARITY_MASK) {
@@ -295,6 +295,7 @@ void SerialUART::begin(unsigned long baud, uint16_t config) {
295295
}
296296
_break = false;
297297
_running = true;
298+
return achieved_baud;
298299
}
299300

300301
void SerialUART::end() {

cores/rp2040/SerialUART.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ class SerialUART : public arduino::HardwareSerial {
6464
bool setFIFOSize(size_t size);
6565
bool setPollingMode(bool mode = true);
6666

67-
void begin(unsigned long baud = 115200) override {
68-
begin(baud, SERIAL_8N1);
67+
int begin(unsigned long baud = 115200) override {
68+
return begin(baud, SERIAL_8N1);
6969
};
70-
void begin(unsigned long baud, uint16_t config) override;
70+
int begin(unsigned long baud, uint16_t config) override;
7171
void end() override;
7272

7373
virtual int peek() override;

0 commit comments

Comments
 (0)