Skip to content

Commit 4c6637a

Browse files
committed
use TUSB_OPT_DEVICE_ENABLED wihtin lib instead of USE_TINYUSB
this allow user sketch to implement port API
1 parent 8640830 commit 4c6637a

9 files changed

+30
-21
lines changed

src/Adafruit_TinyUSB.h

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

28+
#include "tusb_option.h"
29+
2830
//#ifndef USE_TINYUSB
2931
//#error TinyUSB is not selected, please select it in Tools->Menu->USB Stack
3032
//#endif
3133

32-
#ifdef USE_TINYUSB
34+
#if TUSB_OPT_DEVICE_ENABLED
3335

3436
#include "arduino/Adafruit_USBD_Device.h"
3537

src/arduino/Adafruit_TinyUSB.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
* THE SOFTWARE.
2323
*/
2424

25-
#ifdef USE_TINYUSB
25+
#include "tusb_option.h"
26+
27+
#if TUSB_OPT_DEVICE_ENABLED
2628

2729
#include "Adafruit_TinyUSB.h"
2830

src/arduino/Adafruit_USBD_CDC.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
* THE SOFTWARE.
2323
*/
2424

25-
#ifdef USE_TINYUSB
25+
#include "tusb_option.h"
26+
27+
#if TUSB_OPT_DEVICE_ENABLED && CFG_TUD_CDC
2628

2729
#include "Arduino.h"
2830
#include "Adafruit_USBD_Device.h"
@@ -206,4 +208,4 @@ void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts)
206208

207209
}
208210

209-
#endif // USE_TINYUSB
211+
#endif // TUSB_OPT_DEVICE_ENABLED

src/arduino/Adafruit_USBD_Device.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
* THE SOFTWARE.
2323
*/
2424

25-
#ifdef USE_TINYUSB
25+
#include "tusb_option.h"
26+
27+
#if TUSB_OPT_DEVICE_ENABLED
2628

2729
#include "Adafruit_USBD_Device.h"
2830
#include "Adafruit_USBD_CDC.h"
@@ -483,4 +485,4 @@ static int strcpy_utf16(const char *s, uint16_t *buf, int bufsize)
483485
return buflen;
484486
}
485487

486-
#endif // USE_TINYUSB
488+
#endif // TUSB_OPT_DEVICE_ENABLED

src/arduino/Adafruit_USBD_Device.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ class Adafruit_USBD_Device
9292
bool detach (void);
9393
bool attach (void);
9494

95-
9695
//------------- status -------------//
9796
bool mounted (void);
9897
bool suspended (void);

src/arduino/Adafruit_USBD_HID.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
* THE SOFTWARE.
2323
*/
2424

25-
#ifdef USE_TINYUSB
25+
#include "tusb_option.h"
26+
27+
#if TUSB_OPT_DEVICE_ENABLED && CFG_TUD_HID
2628

2729
#include "Adafruit_USBD_HID.h"
2830

@@ -228,4 +230,4 @@ bool Adafruit_USBD_HID::mouseButtonRelease(uint8_t report_id) {
228230
return tud_hid_mouse_report(report_id, 0, 0, 0, 0, 0);
229231
}
230232

231-
#endif
233+
#endif // TUSB_OPT_DEVICE_ENABLED

src/arduino/Adafruit_USBD_MIDI.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
* THE SOFTWARE.
2323
*/
2424

25-
#ifdef USE_TINYUSB
25+
#include "tusb_option.h"
2626

27-
#include "Adafruit_USBD_MIDI.h"
27+
#if TUSB_OPT_DEVICE_ENABLED && CFG_TUD_MIDI
2828

29-
#if CFG_TUD_MIDI
29+
#include "Adafruit_USBD_MIDI.h"
3030

3131
//--------------------------------------------------------------------+
3232
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
@@ -127,5 +127,4 @@ bool Adafruit_USBD_MIDI::readPacket(uint8_t packet[4]) {
127127
return tud_midi_packet_read(packet);
128128
}
129129

130-
#endif // MIDI
131-
#endif // USE_TINYUSB
130+
#endif // TUSB_OPT_DEVICE_ENABLED

src/arduino/Adafruit_USBD_MSC.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
* THE SOFTWARE.
2323
*/
2424

25-
#ifdef USE_TINYUSB
25+
#include "tusb_option.h"
26+
27+
#if TUSB_OPT_DEVICE_ENABLED && CFG_TUD_MSC
2628

2729
#include "Adafruit_USBD_MSC.h"
2830

@@ -219,4 +221,4 @@ void tud_msc_write10_complete_cb(uint8_t lun) {
219221

220222
} // extern "C"
221223

222-
#endif // USE_TINYUSB
224+
#endif // TUSB_OPT_DEVICE_ENABLED

src/arduino/Adafruit_USBD_WebUSB.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
* THE SOFTWARE.
2323
*/
2424

25-
#ifdef USE_TINYUSB
25+
#include "tusb_option.h"
26+
27+
#if TUSB_OPT_DEVICE_ENABLED && CFG_TUD_VENDOR
2628

2729
#include "Adafruit_USBD_WebUSB.h"
2830
#include "Arduino.h"
2931

30-
#if CFG_TUD_VENDOR
31-
3232
//--------------------------------------------------------------------+
3333
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
3434
//--------------------------------------------------------------------+
@@ -297,5 +297,4 @@ bool tud_vendor_control_complete_cb(uint8_t rhport, tusb_control_request_t const
297297
}
298298
}
299299

300-
#endif // VENDOR
301-
#endif // USE_TINYUSB
300+
#endif // TUSB_OPT_DEVICE_ENABLED

0 commit comments

Comments
 (0)