Skip to content

Commit 49ac372

Browse files
committed
add TinyUSB_Device_Task() to API
1 parent 568f4a8 commit 49ac372

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

src/arduino/Adafruit_TinyUSB_API.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
//--------------------------------------------------------------------+
3232
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
3333
//--------------------------------------------------------------------+
34+
extern "C"
35+
{
3436

3537
void TinyUSB_Device_Init(uint8_t rhport)
3638
{
@@ -39,6 +41,8 @@ void TinyUSB_Device_Init(uint8_t rhport)
3941

4042
void TinyUSB_Device_Task(void)
4143
{
44+
USBDevice.task();
45+
}
4246

4347
}
4448

src/arduino/Adafruit_TinyUSB_API.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
// Should be called by BSP Core to initialize, process task
3434
// Weak function allow compile arduino core before linking with this library
3535
//--------------------------------------------------------------------+
36+
#ifdef __cplusplus
37+
extern "C" {
38+
#endif
3639

3740
// Called by core/sketch to initialize usb device hardware and stack
3841
// This also initialize Serial as CDC device
@@ -41,6 +44,10 @@ void TinyUSB_Device_Init(uint8_t rhport) __attribute__((weak));
4144
// Called by core/sketch to handle device event
4245
void TinyUSB_Device_Task(void) __attribute__((weak));
4346

47+
#ifdef __cplusplus
48+
}
49+
#endif
50+
4451
//--------------------------------------------------------------------+
4552
// Port API
4653
// Must be implemented by each BSP core/platform

src/arduino/Adafruit_USBD_Device.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ void Adafruit_USBD_Device::task(void)
248248
tud_task();
249249

250250
#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);
251253
#endif
252254
}
253255

src/arduino/ports/Adafruit_TinyUSB_samd.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,6 @@ void USB_Handler(void) { tud_int_handler(0); }
5252

5353
#endif
5454

55-
// run TinyUSB background task when yield()
56-
void yield(void)
57-
{
58-
tud_task();
59-
tud_cdc_write_flush();
60-
}
61-
6255
} // extern C
6356

6457

0 commit comments

Comments
 (0)