Skip to content

Commit 92ebc03

Browse files
committed
add TINYUSB_API_VERSION for easy backward compatible
1 parent 1a38d65 commit 92ebc03

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/arduino/Adafruit_TinyUSB_API.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
#include <stdbool.h>
2929
#include <stdint.h>
3030

31+
// API Version, need to be updated when there is changes for
32+
// TinyUSB_API, USBD_CDC, USBD_Device, USBD_Interface,
33+
#define TINYUSB_API_VERSION 10700
34+
3135
//--------------------------------------------------------------------+
3236
// Core API
3337
// Should be called by BSP Core to initialize, process task

src/arduino/Adafruit_USBD_CDC.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
#include "Adafruit_USBD_CDC.h"
3434
#include "Adafruit_USBD_Device.h"
3535

36+
#ifndef TINYUSB_API_VERSION
37+
#define TINYUSB_API_VERSION 0
38+
#endif
39+
3640
// Starting endpoints; adjusted elsewhere as needed
3741
#define EPOUT 0x00
3842
#define EPIN 0x80
@@ -191,6 +195,7 @@ int Adafruit_USBD_CDC::read(void) {
191195
return (int)tud_cdc_n_read_char(_instance);
192196
}
193197

198+
#if TINYUSB_API_VERSION >= 10700
194199
size_t Adafruit_USBD_CDC::read(uint8_t *buffer, size_t size)
195200
{
196201
if (!isValid()) {
@@ -199,6 +204,7 @@ size_t Adafruit_USBD_CDC::read(uint8_t *buffer, size_t size)
199204

200205
return tud_cdc_n_read(_instance, buffer, size);
201206
}
207+
#endif
202208

203209
void Adafruit_USBD_CDC::flush(void) {
204210
if (!isValid()) {

0 commit comments

Comments
 (0)