Skip to content

Commit

Permalink
USB support only when tiny USB enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason2866 authored Oct 14, 2024
1 parent af358d8 commit 25972bf
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
39 changes: 23 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ set(CORE_SRCS
cores/esp32/esp32-hal-sigmadelta.c
cores/esp32/esp32-hal-spi.c
cores/esp32/esp32-hal-time.c
cores/esp32/esp32-hal-timer.c
cores/esp32/esp32-hal-tinyusb.c
cores/esp32/esp32-hal-timer.c
cores/esp32/esp32-hal-touch.c
cores/esp32/esp32-hal-uart.c
cores/esp32/esp32-hal-rmt.c
Expand All @@ -63,16 +62,20 @@ set(CORE_SRCS
cores/esp32/StreamString.cpp
cores/esp32/Tone.cpp
cores/esp32/HWCDC.cpp
cores/esp32/USB.cpp
cores/esp32/USBCDC.cpp
cores/esp32/USBMSC.cpp
cores/esp32/FirmwareMSC.cpp
cores/esp32/firmware_msc_fat.c
cores/esp32/wiring_pulse.c
cores/esp32/wiring_shift.c
cores/esp32/WMath.cpp
cores/esp32/WString.cpp
)
if(IDF_TARGET MATCHES "esp32s2|esp32s3|esp32p4" AND CONFIG_TINYUSB_ENABLED)
list(APPEND CORE_SRCS
cores/esp32/esp32-hal-tinyusb.c
cores/esp32/USB.cpp
cores/esp32/USBCDC.cpp
cores/esp32/USBMSC.cpp)
endif()

set(ARDUINO_ALL_LIBRARIES
ArduinoOTA
Expand All @@ -95,11 +98,13 @@ set(ARDUINO_ALL_LIBRARIES
SPI
Ticker
Update
USB
WebServer
WiFi
Wire
)
if(IDF_TARGET MATCHES "esp32s2|esp32s3|esp32p4" AND CONFIG_TINYUSB_ENABLED)
list(APPEND ARDUINO_ALL_LIBRARIES USB)
endif()

set(ARDUINO_LIBRARY_ArduinoOTA_SRCS libraries/ArduinoOTA/src/ArduinoOTA.cpp)
set(ARDUINO_LIBRARY_ArduinoOTA_REQUIRES esp_https_ota)
Expand Down Expand Up @@ -149,16 +154,18 @@ set(ARDUINO_LIBRARY_Update_SRCS
libraries/Update/src/Updater.cpp
libraries/Update/src/HttpsOTAUpdate.cpp)

set(ARDUINO_LIBRARY_USB_SRCS
libraries/USB/src/USBHID.cpp
libraries/USB/src/USBMIDI.cpp
libraries/USB/src/USBHIDMouse.cpp
libraries/USB/src/USBHIDKeyboard.cpp
libraries/USB/src/USBHIDGamepad.cpp
libraries/USB/src/USBHIDConsumerControl.cpp
libraries/USB/src/USBHIDSystemControl.cpp
libraries/USB/src/USBHIDVendor.cpp
libraries/USB/src/USBVendor.cpp)
if(IDF_TARGET MATCHES "esp32s2|esp32s3|esp32p4" AND CONFIG_TINYUSB_ENABLED)
set(ARDUINO_LIBRARY_USB_SRCS
libraries/USB/src/USBHID.cpp
libraries/USB/src/USBMIDI.cpp
libraries/USB/src/USBHIDMouse.cpp
libraries/USB/src/USBHIDKeyboard.cpp
libraries/USB/src/USBHIDGamepad.cpp
libraries/USB/src/USBHIDConsumerControl.cpp
libraries/USB/src/USBHIDSystemControl.cpp
libraries/USB/src/USBHIDVendor.cpp
libraries/USB/src/USBVendor.cpp)
endif()

set(ARDUINO_LIBRARY_WebServer_SRCS
libraries/WebServer/src/WebServer.cpp
Expand Down
2 changes: 2 additions & 0 deletions cores/esp32/FirmwareMSC.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

#pragma once
#include <stdbool.h>
#if defined __has_include && __has_include("USBMSC.h")
#include "USBMSC.h"
#endif

#if CONFIG_TINYUSB_MSC_ENABLED

Expand Down
2 changes: 2 additions & 0 deletions cores/esp32/HWCDC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#if defined __has_include && __has_include("USB.h")
#include "USB.h"
#endif
#if SOC_USB_SERIAL_JTAG_SUPPORTED

#include "esp32-hal.h"
Expand Down
2 changes: 2 additions & 0 deletions cores/esp32/HardwareSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@
#include "esp32-hal.h"
#include "soc/soc_caps.h"
#include "HWCDC.h"
#if defined __has_include && __has_include("USBCDC.h")
#include "USBCDC.h"
#endif

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
Expand Down

0 comments on commit 25972bf

Please sign in to comment.