Skip to content

Commit 2fc1e48

Browse files
committed
USBH CDC setBaudrate() do nothing if baud is already matched
begin() will also change baudrate if mounted()
1 parent 9aaa6c9 commit 2fc1e48

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/arduino/cdc/Adafruit_USBH_CDC.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ void Adafruit_USBH_CDC::begin(unsigned long baudrate) {
4242
if (_baud == 0) {
4343
_baud = 115200; // default, backward compatible with previous API begin(0)
4444
}
45+
46+
// if already mounted, this will set baudrate
47+
if (mounted()) {
48+
setBaudrate(_baud);
49+
}
4550
}
4651

4752
void Adafruit_USBH_CDC::begin(unsigned long baudrate, uint16_t config) {
@@ -103,6 +108,11 @@ bool Adafruit_USBH_CDC::setBaudrate(uint32_t baudrate,
103108
return false;
104109
}
105110

111+
if (baud() == baudrate) {
112+
// skip if already matched
113+
return true;
114+
}
115+
106116
return tuh_cdc_set_baudrate(_idx, baudrate, complete_cb, user_data);
107117
}
108118

0 commit comments

Comments
 (0)