1if (DEFINED ENV{PICO_TINYUSB_PATH} AND (NOT PICO_TINYUSB_PATH)) 2 set(PICO_TINYUSB_PATH $ENV{PICO_TINYUSB_PATH}) 3 message("Using PICO_TINYUSB_PATH from environment ('${PICO_TINYUSB_PATH}')") 4endif () 5 6set(TINYUSB_TEST_PATH "src/portable/raspberrypi/rp2040") 7if (NOT PICO_TINYUSB_PATH) 8 set(PICO_TINYUSB_PATH ${PROJECT_SOURCE_DIR}/lib/tinyusb) 9 if (NOT EXISTS ${PICO_TINYUSB_PATH}/${TINYUSB_TEST_PATH}) 10 message(WARNING "TinyUSB submodule has not been initialized; USB support will be unavailable 11hint: try 'git submodule update --init' from your SDK directory (${PICO_SDK_PATH}).") 12 endif() 13elseif (NOT EXISTS ${PICO_TINYUSB_PATH}/${TINYUSB_TEST_PATH}) 14 message(WARNING "PICO_TINYUSB_PATH specified but content not present.") 15endif() 16 17if (EXISTS ${PICO_TINYUSB_PATH}/${TINYUSB_TEST_PATH}) 18 message("TinyUSB available at ${PICO_TINYUSB_PATH}/${TINYUSB_TEST_PATH}; enabling build support for USB.") 19 20 pico_register_common_scope_var(PICO_TINYUSB_PATH) 21 22 set(BOARD pico_sdk) 23 set(FAMILY rp2040) 24 include(${PICO_TINYUSB_PATH}/hw/bsp/family_support.cmake) 25 26 add_library(tinyusb_common INTERFACE) 27 target_link_libraries(tinyusb_common INTERFACE tinyusb_common_base) 28 29 add_library(tinyusb_device_unmarked INTERFACE) 30 target_link_libraries(tinyusb_device_unmarked INTERFACE tinyusb_device_base) 31 target_compile_definitions(tinyusb_device_unmarked INTERFACE 32 # off by default note TUD_OPT_RP2040_USB_DEVICE_ENUMERATION_FIX defaults from PICO_RP2040_USB_DEVICE_ENUMERATION_FIX 33 # TUD_OPT_RP2040_USB_DEVICE_ENUMERATION_FIX=1 34 PICO_RP2040_USB_DEVICE_UFRAME_FIX=1 35 ) 36 37 # unmarked version used by stdio USB 38 target_link_libraries(tinyusb_device_unmarked INTERFACE tinyusb_common pico_fix_rp2040_usb_device_enumeration tinyusb_device_base) 39 40 pico_add_library(tinyusb_device) 41 target_link_libraries(tinyusb_device INTERFACE tinyusb_device_unmarked) 42 43 pico_add_library(tinyusb_host) 44 target_link_libraries(tinyusb_host INTERFACE tinyusb_host_base tinyusb_common) 45 46 pico_add_library(tinyusb_board) 47 target_link_libraries(tinyusb_board INTERFACE tinyusb_bsp) 48 49 # Override suppress_tinyusb_warnings to add suppression of (falsely) reported GCC 11.2 warnings 50 function(suppress_tinyusb_warnings) 51 _suppress_tinyusb_warnings() 52 set_source_files_properties( 53 ${PICO_TINYUSB_PATH}/src/portable/raspberrypi/rp2040/rp2040_usb.c 54 PROPERTIES 55 COMPILE_FLAGS "-Wno-stringop-overflow -Wno-array-bounds") 56 endfunction() 57 58 pico_promote_common_scope_vars() 59endif() 60