2021-05-06 08:20:54 +00:00
|
|
|
idf_build_get_property(target IDF_TARGET)
|
2020-03-06 14:04:06 +00:00
|
|
|
|
2021-07-09 03:15:26 +00:00
|
|
|
set(srcs)
|
|
|
|
set(includes_public)
|
|
|
|
set(includes_private)
|
|
|
|
set(compile_options)
|
2020-03-06 14:04:06 +00:00
|
|
|
|
2021-07-09 03:15:26 +00: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 08:20:54 +00:00
|
|
|
|
2021-07-09 03:15:26 +00:00
|
|
|
list(APPEND compile_options
|
|
|
|
"-DCFG_TUSB_MCU=${tusb_mcu}"
|
|
|
|
"-DCFG_TUSB_DEBUG=${CONFIG_TINYUSB_DEBUG_LEVEL}"
|
|
|
|
)
|
2021-05-06 08:20:54 +00:00
|
|
|
|
2021-07-09 03:15:26 +00: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
|
|
|
|
"${freertos_component_dir}/include/freertos"
|
|
|
|
)
|
2020-03-06 14:04:06 +00:00
|
|
|
|
2020-08-06 12:41:32 +00:00
|
|
|
list(APPEND srcs
|
2021-07-09 03:15:26 +00: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/tusb_tasks.c"
|
|
|
|
"additions/src/usb_descriptors.c"
|
|
|
|
)
|
|
|
|
|
|
|
|
# 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 12:41:32 +00:00
|
|
|
|
2021-07-09 03:15:26 +00:00
|
|
|
idf_component_register(SRCS ${srcs}
|
|
|
|
INCLUDE_DIRS ${includes_public}
|
|
|
|
PRIV_INCLUDE_DIRS ${includes_private}
|
2021-08-19 12:28:28 +00:00
|
|
|
PRIV_REQUIRES "vfs" "usb"
|
2021-07-09 03:15:26 +00:00
|
|
|
)
|
2020-03-06 14:04:06 +00:00
|
|
|
|
2021-07-09 03:15:26 +00:00
|
|
|
if(CONFIG_TINYUSB)
|
|
|
|
target_compile_options(${COMPONENT_LIB} PRIVATE ${compile_options})
|
2020-03-06 14:04:06 +00:00
|
|
|
endif()
|