Skip to content

Commit

Permalink
move menu check to TinyUSB_API
Browse files Browse the repository at this point in the history
  • Loading branch information
hathach committed Jun 13, 2024
1 parent f2168e4 commit d1708bc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
7 changes: 0 additions & 7 deletions src/Adafruit_TinyUSB.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@
#ifndef ADAFRUIT_TINYUSB_H_
#define ADAFRUIT_TINYUSB_H_

// Error message for Core that must select TinyUSB via menu
#if !defined(USE_TINYUSB) && \
(defined(ARDUINO_ARCH_SAMD) || \
(defined(ARDUINO_ARCH_RP2040) && !defined(ARDUINO_ARCH_MBED)))
#error TinyUSB is not selected, please select it in "Tools->Menu->USB Stack"
#endif

// ESP32 out-of-sync
#ifdef ARDUINO_ARCH_ESP32
#include "arduino/ports/esp32/tusb_config_esp32.h"
Expand Down
17 changes: 14 additions & 3 deletions src/arduino/Adafruit_TinyUSB_API.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,24 @@
// TinyUSB_API, USBD_CDC, USBD_Device, USBD_Interface,
#define TINYUSB_API_VERSION 30000

#if defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_NRF52_ADAFRUIT) || \
defined(ARDUINO_ARCH_ESP32) || \
(defined(ARDUINO_ARCH_RP2040) && !defined(ARDUINO_ARCH_MBED))
#define TINYUSB_HAS_BUITLTIN_CORE_SUPPORT
#endif

// Core that has built-in support: Adafruit SAMD, Adafruit nRF, rp2040, esp32
#if !(defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_NRF52_ADAFRUIT) || \
defined(ARDUINO_ARCH_ESP32) || \
(defined(ARDUINO_ARCH_RP2040) && !defined(ARDUINO_ARCH_MBED)))
#if !defined(TINYUSB_HAS_BUITLTIN_CORE_SUPPORT)
#define TINYUSB_NEED_POLLING_TASK
#endif

// Error message for Core that must select TinyUSB via menu (built-in except
// esp32)
#if !defined(USE_TINYUSB) && (defined(TINYUSB_HAS_BUITLTIN_CORE_SUPPORT) && \
!defined(ARDUINO_ARCH_ESP32))
#error TinyUSB is not selected, please select it in "Tools->Menu->USB Stack"
#endif

//--------------------------------------------------------------------+
// Core API
// Should be called by BSP Core to initialize, process task
Expand Down
6 changes: 4 additions & 2 deletions src/arduino/Adafruit_USBD_CDC.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,13 @@ class Adafruit_USBD_CDC : public Stream, public Adafruit_USBD_Interface {

extern Adafruit_USBD_CDC SerialTinyUSB;

// Built-in support "Serial" is used with TinyUSB CDC
// Built-in support "Serial" is assigned to TinyUSB CDC
#if defined(USE_TINYUSB)
#define Serial SerialTinyUSB
#define SerialTinyUSB Serial
#endif

extern Adafruit_USBD_CDC SerialTinyUSB;

#endif // else of ESP32
#endif // __cplusplus

Expand Down

0 comments on commit d1708bc

Please sign in to comment.