Skip to content

Commit 50e5527

Browse files
committed
Limit Adafruit_USBD_CDC::ignoreFlowcontrol to rp2040 core
`Adafruit_USBD_CDC::ignoreFlowcontrol` added in 0672cb8 may only work for rp2040 for now. So add `#ifdef` to limit this method to rp2040 core only.
1 parent 0672cb8 commit 50e5527

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/arduino/Adafruit_USBD_CDC.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,11 @@ void Adafruit_USBD_CDC::end(void) {
118118
_instance = INVALID_INSTANCE;
119119
}
120120

121+
#ifdef ARDUINO_ARCH_RP2040
121122
void Adafruit_USBD_CDC::ignoreFlowControl(bool ignore) {
122123
_ignoreFlowControl = ignore;
123124
}
125+
#endif
124126

125127
uint32_t Adafruit_USBD_CDC::baud(void) {
126128
if (!isValid()) {
@@ -247,7 +249,12 @@ size_t Adafruit_USBD_CDC::write(const uint8_t *buffer, size_t size) {
247249
}
248250

249251
size_t remain = size;
250-
while (remain && (tud_cdc_n_connected(_instance) || _ignoreFlowControl)) {
252+
#ifdef ARDUINO_ARCH_RP2040
253+
while (remain && (tud_cdc_n_connected(_instance) || _ignoreFlowControl))
254+
#else
255+
while (remain && tud_cdc_n_connected(_instance))
256+
#endif
257+
{
251258
size_t wrcount = tud_cdc_n_write(_instance, buffer, remain);
252259
remain -= wrcount;
253260
buffer += wrcount;

src/arduino/Adafruit_USBD_CDC.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,15 @@ class Adafruit_USBD_CDC : public Stream, public Adafruit_USBD_Interface {
5454
void begin(uint32_t baud, uint8_t config);
5555
void end(void);
5656

57+
#ifdef ARDUINO_ARCH_RP2040
5758
// In some cases, the target application will not assert
5859
// the DTR virtual line, thus preventing writing operations
5960
// to succeed. For this reason, the
6061
// Adafruit_USBD_CDC::ignoreFlowControl() method disables the
6162
// connection’s state verification, enabling the program to
6263
// write on the port, even though the data might be lost.
6364
void ignoreFlowControl(bool ignore = true);
65+
#endif
6466

6567
// return line coding set by host
6668
uint32_t baud(void);
@@ -98,7 +100,9 @@ class Adafruit_USBD_CDC : public Stream, public Adafruit_USBD_Interface {
98100

99101
uint8_t _instance;
100102

103+
#ifdef ARDUINO_ARCH_RP2040
101104
bool _ignoreFlowControl = false;
105+
#endif
102106

103107
bool isValid(void) { return _instance != INVALID_INSTANCE; }
104108
};

0 commit comments

Comments
 (0)