Skip to content

Commit 6f7e619

Browse files
committed
avoid altering virtual function spec
1 parent 7cf7787 commit 6f7e619

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

cores/rp2040/SerialUART.cpp

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

301300
void SerialUART::end() {

cores/rp2040/SerialUART.h

Lines changed: 8 additions & 2 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-
int begin(unsigned long baud = 115200) override {
67+
void begin(unsigned long baud = 115200) override {
6868
return begin(baud, SERIAL_8N1);
6969
};
70-
int begin(unsigned long baud, uint16_t config) override;
70+
void begin(unsigned long baud, uint16_t config) override;
7171
void end() override;
7272

7373
virtual int peek() override;
@@ -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 getAcheivedBaud() {
98+
return _achievedBaud;
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 _achievedBaud;
103109
mutex_t _mutex;
104110
bool _polling = false;
105111
bool _overflow;

0 commit comments

Comments
 (0)