|
| 1 | +idf_build_get_property(target IDF_TARGET) |
| 2 | + |
| 3 | +if(target STREQUAL "esp32s3") |
| 4 | + set(tusb_mcu "OPT_MCU_ESP32S3") |
| 5 | + set(tusb_family "esp32sx") |
| 6 | +elseif(target STREQUAL "esp32s2") |
| 7 | + set(tusb_mcu "OPT_MCU_ESP32S2") |
| 8 | + set(tusb_family "esp32sx") |
| 9 | +elseif(target STREQUAL "esp32p4") |
| 10 | + set(tusb_mcu "OPT_MCU_ESP32P4") |
| 11 | + set(tusb_family "esp32px") |
| 12 | +endif() |
| 13 | + |
| 14 | +set(compile_options |
| 15 | + "-DCFG_TUSB_MCU=${tusb_mcu}" |
| 16 | + ) |
| 17 | + |
| 18 | +idf_component_get_property(freertos_include freertos ORIG_INCLUDE_PATH) |
| 19 | + |
| 20 | +set(includes_private |
| 21 | + "src/" |
| 22 | + "src/device" |
| 23 | + "lib/networking" # For RNDIS definitions |
| 24 | + ) |
| 25 | + |
| 26 | +set(includes_public |
| 27 | + "src/" |
| 28 | + # The FreeRTOS API include convention in tinyusb is different from esp-idf |
| 29 | + "${freertos_include}" |
| 30 | + ) |
| 31 | + |
| 32 | +set(srcs |
| 33 | + "src/class/cdc/cdc_device.c" |
| 34 | + "src/class/hid/hid_device.c" |
| 35 | + "src/class/midi/midi_device.c" |
| 36 | + "src/class/msc/msc_device.c" |
| 37 | + "src/class/vendor/vendor_device.c" |
| 38 | + "src/class/audio/audio_device.c" |
| 39 | + "src/class/video/video_device.c" |
| 40 | + "src/class/bth/bth_device.c" |
| 41 | + # NET class |
| 42 | + "src/class/net/ecm_rndis_device.c" |
| 43 | + "lib/networking/rndis_reports.c" |
| 44 | + "src/class/net/ncm_device.c" |
| 45 | + # DFU |
| 46 | + "src/class/dfu/dfu_device.c" |
| 47 | + "src/class/dfu/dfu_rt_device.c" |
| 48 | + # Common, device-mode related |
| 49 | + "src/portable/synopsys/dwc2/dcd_dwc2.c" |
| 50 | + "src/common/tusb_fifo.c" |
| 51 | + "src/device/usbd_control.c" |
| 52 | + "src/device/usbd.c" |
| 53 | + "src/tusb.c" |
| 54 | + ) |
| 55 | + |
| 56 | +idf_component_register(SRCS ${srcs} |
| 57 | + INCLUDE_DIRS ${includes_public} |
| 58 | + PRIV_INCLUDE_DIRS ${includes_private} |
| 59 | + PRIV_REQUIRES esp_netif # required by rndis_reports.c: #include "netif/ethernet.h" |
| 60 | + ) |
| 61 | + |
| 62 | +target_compile_options(${COMPONENT_LIB} PUBLIC ${compile_options}) |
| 63 | + |
| 64 | +# when no builtin class driver is enabled, an uint8_t data compared with `BUILTIN_DRIVER_COUNT` will always be false |
| 65 | +set_source_files_properties("src/device/usbd.c" PROPERTIES COMPILE_FLAGS "-Wno-type-limits") |
0 commit comments