1idf_build_get_property(target IDF_TARGET) 2 3set(srcs) 4set(includes_public) 5set(includes_private) 6set(compile_options) 7 8if(CONFIG_TINYUSB) 9 if(target STREQUAL "esp32s3") 10 set(tusb_mcu "OPT_MCU_ESP32S3") 11 set(tusb_family "esp32sx") 12 elseif(target STREQUAL "esp32s2") 13 set(tusb_mcu "OPT_MCU_ESP32S2") 14 set(tusb_family "esp32sx") 15 else() 16 # CONFIG_TINYUSB dependency has been garanteed by Kconfig logic, 17 # So it's not possible that cmake goes here 18 message(FATAL_ERROR "TinyUSB is not support on ${target}.") 19 return() 20 endif() 21 22 list(APPEND compile_options 23 "-DCFG_TUSB_MCU=${tusb_mcu}" 24 "-DCFG_TUSB_DEBUG=${CONFIG_TINYUSB_DEBUG_LEVEL}" 25 ) 26 27 idf_component_get_property(freertos_component_dir freertos COMPONENT_DIR) 28 29 list(APPEND includes_private 30 "tinyusb/hw/bsp/" 31 "tinyusb/src/" 32 "tinyusb/src/device" 33 "additions/include_private" 34 ) 35 36 list(APPEND includes_public 37 "tinyusb/src/" 38 "additions/include" 39 # The FreeRTOS API include convention in tinyusb is different from esp-idf 40 "${freertos_component_dir}/include/freertos" 41 ) 42 43 list(APPEND srcs 44 "tinyusb/src/portable/espressif/${tusb_family}/dcd_${tusb_family}.c" 45 "tinyusb/src/class/cdc/cdc_device.c" 46 "tinyusb/src/class/hid/hid_device.c" 47 "tinyusb/src/class/midi/midi_device.c" 48 "tinyusb/src/class/msc/msc_device.c" 49 "tinyusb/src/class/vendor/vendor_device.c" 50 "tinyusb/src/common/tusb_fifo.c" 51 "tinyusb/src/device/usbd_control.c" 52 "tinyusb/src/device/usbd.c" 53 "tinyusb/src/tusb.c" 54 "additions/src/descriptors_control.c" 55 "additions/src/tinyusb.c" 56 "additions/src/tusb_tasks.c" 57 "additions/src/usb_descriptors.c" 58 ) 59 60 # when no builtin class driver is enabled, an uint8_t data compared with `BUILTIN_DRIVER_COUNT` will always be false 61 set_source_files_properties("tinyusb/src/device/usbd.c" PROPERTIES COMPILE_FLAGS "-Wno-type-limits") 62 63 if(CONFIG_TINYUSB_CDC_ENABLED) 64 list(APPEND srcs 65 "additions/src/cdc.c" 66 "additions/src/tusb_cdc_acm.c" 67 "additions/src/tusb_console.c" 68 "additions/src/vfs_tinyusb.c" 69 ) 70 endif() # CONFIG_TINYUSB_CDC_ENABLED 71endif() # CONFIG_TINYUSB 72 73idf_component_register(SRCS ${srcs} 74 INCLUDE_DIRS ${includes_public} 75 PRIV_INCLUDE_DIRS ${includes_private} 76 PRIV_REQUIRES "vfs" "usb" 77 ) 78 79if(CONFIG_TINYUSB) 80 target_compile_options(${COMPONENT_LIB} PRIVATE ${compile_options}) 81endif() 82