Skip to content

Commit d80d579

Browse files
committed
add TinyUSB_Device_FlushCDC
1 parent 49ac372 commit d80d579

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

src/arduino/Adafruit_TinyUSB_API.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ void TinyUSB_Device_Task(void)
4444
USBDevice.task();
4545
}
4646

47+
void TinyUSB_Device_FlushCDC(void)
48+
{
49+
// TODO multiple CDCs
50+
tud_cdc_n_write_flush(0);
51+
}
52+
4753
}
4854

4955
#endif

src/arduino/Adafruit_TinyUSB_API.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ void TinyUSB_Device_Init(uint8_t rhport) __attribute__((weak));
4444
// Called by core/sketch to handle device event
4545
void TinyUSB_Device_Task(void) __attribute__((weak));
4646

47+
// Called by core/sketch to flush write on CDC
48+
void TinyUSB_Device_FlushCDC(void) __attribute__((weak));
49+
4750
#ifdef __cplusplus
4851
}
4952
#endif

src/arduino/Adafruit_USBD_CDC.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@
2525
#ifndef ADAFRUIT_USBD_CDC_H_
2626
#define ADAFRUIT_USBD_CDC_H_
2727

28-
#include "Stream.h"
2928
#include "Adafruit_TinyUSB_API.h"
29+
30+
#ifdef __cplusplus
31+
32+
#include "Stream.h"
3033
#include "Adafruit_USBD_Interface.h"
3134

3235
class Adafruit_USBD_CDC : public Stream, public Adafruit_USBD_Interface
@@ -72,4 +75,5 @@ class Adafruit_USBD_CDC : public Stream, public Adafruit_USBD_Interface
7275

7376
extern Adafruit_USBD_CDC Serial;
7477

78+
#endif // __cplusplus
7579
#endif

src/arduino/Adafruit_USBD_Device.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,6 @@ bool Adafruit_USBD_Device::begin(uint8_t rhport)
246246
void Adafruit_USBD_Device::task(void)
247247
{
248248
tud_task();
249-
250-
#if CFG_TUSB_OS == OPT_OS_NONE || CFG_TUSB_OS == OPT_OS_PICO
251-
// flush Serial if we don't use RTOS TODO multiple CDCs
252-
tud_cdc_n_write_flush(0);
253-
#endif
254249
}
255250

256251
bool Adafruit_USBD_Device::mounted (void)

0 commit comments

Comments
 (0)