2021-05-06 04:20:54 -04:00
|
|
|
idf_build_get_property(target IDF_TARGET)
|
2020-03-06 09:04:06 -05:00
|
|
|
|
2021-07-08 23:15:26 -04:00
|
|
|
set(srcs)
|
|
|
|
set(includes_public)
|
|
|
|
set(includes_private)
|
|
|
|
set(compile_options)
|
2020-03-06 09:04:06 -05:00
|
|
|
|
2021-07-08 23:15:26 -04:00
|
|
|
if(CONFIG_TINYUSB)
|
|
|
|
if(target STREQUAL "esp32s3")
|
|
|
|
set(tusb_mcu "OPT_MCU_ESP32S3")
|
|
|
|
set(tusb_family "esp32sx")
|
|
|
|
elseif(target STREQUAL "esp32s2")
|
|
|
|
set(tusb_mcu "OPT_MCU_ESP32S2")
|
|
|
|
set(tusb_family "esp32sx")
|
|
|
|
else()
|
|
|
|
# CONFIG_TINYUSB dependency has been garanteed by Kconfig logic,
|
|
|
|
# So it's not possible that cmake goes here
|
|
|
|
message(FATAL_ERROR "TinyUSB is not support on ${target}.")
|
|
|
|
return()
|
|
|
|
endif()
|
2021-05-06 04:20:54 -04:00
|
|
|
|
2021-07-08 23:15:26 -04:00
|
|
|
list(APPEND compile_options
|
|
|
|
"-DCFG_TUSB_MCU=${tusb_mcu}"
|
|
|
|
"-DCFG_TUSB_DEBUG=${CONFIG_TINYUSB_DEBUG_LEVEL}"
|
|
|
|
)
|
2021-05-06 04:20:54 -04:00
|
|
|
|
2021-07-08 23:15:26 -04:00
|
|
|
idf_component_get_property(freertos_component_dir freertos COMPONENT_DIR)
|
|
|
|
|
|
|
|
list(APPEND includes_private
|
|
|
|
"tinyusb/hw/bsp/"
|
|
|
|
"tinyusb/src/"
|
|
|
|
"tinyusb/src/device"
|
|
|
|
"additions/include_private"
|
|
|
|
)
|
|
|
|
|
|
|
|
list(APPEND includes_public
|
|
|
|
"tinyusb/src/"
|
|
|
|
"additions/include"
|
|
|
|
# The FreeRTOS API include convention in tinyusb is different from esp-idf
|
2021-09-20 02:07:03 -04:00
|
|
|
"${freertos_component_dir}/FreeRTOS-Kernel/include/freertos"
|
2021-07-08 23:15:26 -04:00
|
|
|
)
|
2020-03-06 09:04:06 -05:00
|
|
|
|
2020-08-06 08:41:32 -04:00
|
|
|
list(APPEND srcs
|
2021-07-08 23:15:26 -04:00
|
|
|
"tinyusb/src/portable/espressif/${tusb_family}/dcd_${tusb_family}.c"
|
|
|
|
"tinyusb/src/class/cdc/cdc_device.c"
|
|
|
|
"tinyusb/src/class/hid/hid_device.c"
|
|
|
|
"tinyusb/src/class/midi/midi_device.c"
|
|
|
|
"tinyusb/src/class/msc/msc_device.c"
|
|
|
|
"tinyusb/src/class/vendor/vendor_device.c"
|
|
|
|
"tinyusb/src/common/tusb_fifo.c"
|
|
|
|
"tinyusb/src/device/usbd_control.c"
|
|
|
|
"tinyusb/src/device/usbd.c"
|
|
|
|
"tinyusb/src/tusb.c"
|
|
|
|
"additions/src/descriptors_control.c"
|
|
|
|
"additions/src/tinyusb.c"
|
|
|
|
"additions/src/usb_descriptors.c"
|
|
|
|
)
|
|
|
|
|
2022-01-03 21:33:23 -05:00
|
|
|
if(NOT CONFIG_TINYUSB_NO_DEFAULT_TASK)
|
|
|
|
list(APPEND srcs "additions/src/tusb_tasks.c")
|
|
|
|
endif()
|
|
|
|
|
2021-07-08 23:15:26 -04:00
|
|
|
# when no builtin class driver is enabled, an uint8_t data compared with `BUILTIN_DRIVER_COUNT` will always be false
|
|
|
|
set_source_files_properties("tinyusb/src/device/usbd.c" PROPERTIES COMPILE_FLAGS "-Wno-type-limits")
|
|
|
|
|
|
|
|
if(CONFIG_TINYUSB_CDC_ENABLED)
|
|
|
|
list(APPEND srcs
|
|
|
|
"additions/src/cdc.c"
|
|
|
|
"additions/src/tusb_cdc_acm.c"
|
|
|
|
"additions/src/tusb_console.c"
|
|
|
|
"additions/src/vfs_tinyusb.c"
|
|
|
|
)
|
|
|
|
endif() # CONFIG_TINYUSB_CDC_ENABLED
|
|
|
|
endif() # CONFIG_TINYUSB
|
2020-08-06 08:41:32 -04:00
|
|
|
|
2021-07-08 23:15:26 -04:00
|
|
|
idf_component_register(SRCS ${srcs}
|
|
|
|
INCLUDE_DIRS ${includes_public}
|
|
|
|
PRIV_INCLUDE_DIRS ${includes_private}
|
2021-08-19 08:28:28 -04:00
|
|
|
PRIV_REQUIRES "vfs" "usb"
|
2021-07-08 23:15:26 -04:00
|
|
|
)
|
2020-03-06 09:04:06 -05:00
|
|
|
|
2021-07-08 23:15:26 -04:00
|
|
|
if(CONFIG_TINYUSB)
|
|
|
|
target_compile_options(${COMPONENT_LIB} PRIVATE ${compile_options})
|
2020-03-06 09:04:06 -05:00
|
|
|
endif()
|