2021-05-30 18:41:07 -05:00
|
|
|
cmake_minimum_required(VERSION 3.13)
|
|
|
|
if (NOT TARGET _rp2040_family_inclusion_marker)
|
|
|
|
add_library(_rp2040_family_inclusion_marker INTERFACE)
|
2021-03-18 19:53:39 +07:00
|
|
|
|
2021-05-30 18:41:07 -05:00
|
|
|
# include basic family CMake functionality
|
|
|
|
set(FAMILY_MCUS RP2040 rp2040)
|
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/../family.cmake)
|
2021-03-18 19:53:39 +07:00
|
|
|
|
2021-05-30 18:41:07 -05:00
|
|
|
if (BOARD AND NOT PICO_BOARD)
|
|
|
|
message("Defaulting PICO_BOARD from BOARD ('${BOARD}')")
|
|
|
|
set(PICO_BOARD ${BOARD})
|
|
|
|
endif()
|
2021-03-02 22:57:33 +07:00
|
|
|
|
2021-05-30 18:41:07 -05:00
|
|
|
# add the SDK in case we are standalone tinyusb example (noop if already present)
|
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/pico_sdk_import.cmake)
|
|
|
|
set(BOARD ${PICO_BOARD})
|
2021-03-02 22:57:33 +07:00
|
|
|
|
2021-05-30 18:41:07 -05:00
|
|
|
# TOP is absolute path to root directory of TinyUSB git repo
|
|
|
|
set(TOP "../../..")
|
|
|
|
get_filename_component(TOP "${TOP}" REALPATH)
|
2021-01-24 00:12:20 +07:00
|
|
|
|
2021-05-30 18:41:07 -05:00
|
|
|
# tinyusb_additions will hold our extra settings libraries
|
|
|
|
add_library(tinyusb_additions INTERFACE)
|
2021-01-24 00:12:20 +07:00
|
|
|
|
2021-05-30 18:41:07 -05:00
|
|
|
target_compile_definitions(tinyusb_additions INTERFACE
|
|
|
|
PICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1
|
|
|
|
)
|
2021-01-24 00:12:20 +07:00
|
|
|
|
2021-05-30 18:41:07 -05:00
|
|
|
if(DEFINED LOG)
|
|
|
|
target_compile_definitions(tinyusb_additions INTERFACE CFG_TUSB_DEBUG=${LOG} )
|
|
|
|
endif()
|
2021-01-29 11:24:05 +07:00
|
|
|
|
2021-05-30 18:41:07 -05:00
|
|
|
if(LOGGER STREQUAL "rtt")
|
|
|
|
target_compile_definitions(tinyusb_additions INTERFACE
|
|
|
|
LOGGER_RTT
|
|
|
|
SEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
|
|
|
|
)
|
2021-01-29 11:24:05 +07:00
|
|
|
|
2021-05-30 18:41:07 -05:00
|
|
|
target_sources(tinyusb_additions INTERFACE
|
|
|
|
${TOP}/lib/SEGGER_RTT/RTT/SEGGER_RTT.c
|
|
|
|
)
|
2021-01-29 11:24:05 +07:00
|
|
|
|
2021-05-30 18:41:07 -05:00
|
|
|
target_include_directories(tinyusb_additions INTERFACE
|
|
|
|
${TOP}/lib/SEGGER_RTT/RTT
|
|
|
|
)
|
|
|
|
endif()
|
2021-01-29 11:24:05 +07:00
|
|
|
|
2021-05-30 18:41:07 -05:00
|
|
|
function(family_configure_target TARGET)
|
|
|
|
pico_add_extra_outputs(${TARGET})
|
|
|
|
pico_enable_stdio_uart(${TARGET} 1)
|
|
|
|
target_link_libraries(${TARGET} PUBLIC pico_stdlib pico_bootsel_via_double_reset tinyusb_board tinyusb_additions)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(family_configure_device_example TARGET)
|
|
|
|
family_configure_target(${TARGET})
|
|
|
|
target_link_libraries(${TARGET} PUBLIC pico_stdlib tinyusb_device)
|
|
|
|
endfunction()
|
2021-01-29 11:24:05 +07:00
|
|
|
|
2021-05-30 18:41:07 -05:00
|
|
|
function(family_configure_host_example TARGET)
|
|
|
|
family_configure_target(${TARGET})
|
|
|
|
target_link_libraries(${TARGET} PUBLIC pico_stdlib tinyusb_host)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(family_initialize_project PROJECT DIR)
|
|
|
|
_family_initialize_project(${PROJECT} ${DIR})
|
|
|
|
enable_language(C CXX ASM)
|
|
|
|
pico_sdk_init()
|
|
|
|
endfunction()
|
|
|
|
endif()
|