Move to Tinyusb 0.10.0 (still with RP patches) (#462)

Most build related items have moved into <tinyusb>/hw/bsp/rp2040/family.cmake which is now the source of truth

force merging as same code save submodule was already reviewed
This commit is contained in:
Graham Sanderson 2021-06-02 13:04:08 -05:00 committed by GitHub
parent 496ff66d19
commit 561502c2da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 46 additions and 85 deletions

View File

@ -50,5 +50,9 @@ if (NOT TARGET _pico_sdk_inclusion_marker)
# add docs at the end, as we gather documentation dirs as we go
add_subdirectory(docs)
if (NOT PICO_SDK_TOP_LEVEL_PROJECT)
pico_promote_common_scope_vars()
endif()
endif()

@ -1 +1 @@
Subproject commit 11c23f88bf42f64ce14b8a7b0b2a4e207dc4dd12
Subproject commit fea5cbaf74a033d3f0c462b6bf2d334a67f6a732

View File

@ -53,6 +53,7 @@ if (NOT TARGET _pico_sdk_pre_init_marker)
message(WARNING "pico_sdk_init() should be called after the project is created (and languages added)")
endif()
add_subdirectory(${PICO_SDK_PATH} pico-sdk)
pico_is_top_level_project(ISTOP)
endmacro()
macro(add_sub_list_dirs var)
@ -70,11 +71,24 @@ if (NOT TARGET _pico_sdk_pre_init_marker)
endforeach()
endmacro()
macro(pico_register_common_scope_var NAME)
if (NOT ${NAME} IN_LIST PICO_PROMOTE_COMMON_SCOPE_VARS)
list(APPEND PICO_PROMOTE_COMMON_SCOPE_VARS ${NAME})
endif()
endmacro()
set(PICO_PROMOTE_COMMON_SCOPE_VARS
PICO_INCLUDE_DIRS
PICO_SDK_POST_LIST_DIRS
PICO_SDK_POST_LIST_FILES
PICO_CONFIG_HEADER_FILES
PICO_RP2040_CONFIG_HEADER_FILES
)
macro(pico_promote_common_scope_vars)
set(PICO_INCLUDE_DIRS ${PICO_INCLUDE_DIRS} PARENT_SCOPE)
set(PICO_SDK_POST_LIST_DIRS ${PICO_SDK_POST_LIST_DIRS} PARENT_SCOPE)
set(PICO_SDK_POST_LIST_FILES ${PICO_SDK_POST_LIST_FILES} PARENT_SCOPE)
set(PICO_CONFIG_HEADER_FILES ${PICO_CONFIG_HEADER_FILES} PARENT_SCOPE)
set(PICO_RP2040_CONFIG_HEADER_FILES ${PICO_RP2040_CONFIG_HEADER_FILES} PARENT_SCOPE)
set(PICO_PROMOTE_COMMON_SCOPE_VARS ${PICO_PROMOTE_COMMON_SCOPE_VARS} PARENT_SCOPE)
foreach(VAR IN LISTS PICO_PROMOTE_COMMON_SCOPE_VARS)
SET(${VAR} ${${VAR}} PARENT_SCOPE)
endforeach()
endmacro()
endif()

View File

@ -101,6 +101,12 @@ static inline uint uart_get_index(uart_inst_t *uart) {
return uart == uart1 ? 1 : 0;
}
static inline uart_inst_t *uart_get_instance(uint instance) {
static_assert(NUM_UARTS == 2, "");
invalid_params_if(UART, instance >= NUM_UARTS);
return instance ? uart1 : uart0;
}
static inline uart_hw_t *uart_get_hw(uart_inst_t *uart) {
uart_get_index(uart); // check it is a hw uart
return (uart_hw_t *)uart;

View File

@ -38,7 +38,10 @@ static uint16_t resetd_open(uint8_t __unused rhport, tusb_desc_interface_t const
}
// Support for parameterized reset via vendor interface control request
static bool resetd_control_request_cb(uint8_t __unused rhport, tusb_control_request_t const *request) {
static bool resetd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request) {
// nothing to do with DATA & ACK stage
if (stage != CONTROL_STAGE_SETUP) return true;
if (request->wIndex == itf_num) {
#if PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_RESET_TO_BOOTSEL
@ -69,10 +72,6 @@ static bool resetd_control_request_cb(uint8_t __unused rhport, tusb_control_requ
return false;
}
static bool resetd_control_complete_cb(uint8_t __unused rhport, tusb_control_request_t __unused const *request) {
return true;
}
static bool resetd_xfer_cb(uint8_t __unused rhport, uint8_t __unused ep_addr, xfer_result_t __unused result, uint32_t __unused xferred_bytes) {
return true;
}
@ -85,8 +84,7 @@ static usbd_class_driver_t const _resetd_driver =
.init = resetd_init,
.reset = resetd_reset,
.open = resetd_open,
.control_request = resetd_control_request_cb,
.control_complete = resetd_control_complete_cb,
.control_xfer_cb = resetd_control_xfer_cb,
.xfer_cb = resetd_xfer_cb,
.sof = NULL
};

View File

@ -17,93 +17,32 @@ endif()
if (EXISTS ${PICO_TINYUSB_PATH}/${TINYUSB_TEST_PATH})
message("TinyUSB available at ${PICO_TINYUSB_PATH}/${TINYUSB_TEST_PATH}; adding USB support.")
pico_register_common_scope_var(PICO_TINYUSB_PATH)
set(BOARD pico_sdk)
include(${PICO_TINYUSB_PATH}/hw/bsp/rp2040/family.cmake)
add_library(tinyusb_common INTERFACE)
target_link_libraries(tinyusb_common INTERFACE
hardware_structs
hardware_irq
hardware_resets
pico_sync
)
target_sources(tinyusb_common INTERFACE
${PICO_TINYUSB_PATH}/src/tusb.c
${PICO_TINYUSB_PATH}/src/common/tusb_fifo.c
)
set(TINYUSB_DEBUG_LEVEL 0)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message("Compiling TinyUSB with CFG_TUSB_DEBUG=1")
set(TINYUSB_DEBUG_LEVEL 1)
endif ()
target_compile_definitions(tinyusb_common INTERFACE
CFG_TUSB_MCU=OPT_MCU_RP2040
CFG_TUSB_OS=OPT_OS_PICO #seems examples are hard coded to OPT_OS_NONE
CFG_TUSB_DEBUG=${TINYUSB_DEBUG_LEVEL}
)
target_include_directories(tinyusb_common INTERFACE
${PICO_TINYUSB_PATH}/src
${PICO_TINYUSB_PATH}/src/common
${PICO_TINYUSB_PATH}/hw
)
target_link_libraries(tinyusb_common INTERFACE tinyusb_common_base)
add_library(tinyusb_device_unmarked INTERFACE)
target_sources(tinyusb_device_unmarked INTERFACE
${PICO_TINYUSB_PATH}/src/portable/raspberrypi/rp2040/dcd_rp2040.c
${PICO_TINYUSB_PATH}/src/portable/raspberrypi/rp2040/rp2040_usb.c
${PICO_TINYUSB_PATH}/src/device/usbd.c
${PICO_TINYUSB_PATH}/src/device/usbd_control.c
${PICO_TINYUSB_PATH}/src/class/audio/audio_device.c
${PICO_TINYUSB_PATH}/src/class/cdc/cdc_device.c
${PICO_TINYUSB_PATH}/src/class/dfu/dfu_rt_device.c
${PICO_TINYUSB_PATH}/src/class/hid/hid_device.c
${PICO_TINYUSB_PATH}/src/class/midi/midi_device.c
${PICO_TINYUSB_PATH}/src/class/msc/msc_device.c
${PICO_TINYUSB_PATH}/src/class/net/net_device.c
${PICO_TINYUSB_PATH}/src/class/usbtmc/usbtmc_device.c
${PICO_TINYUSB_PATH}/src/class/vendor/vendor_device.c
)
target_link_libraries(tinyusb_device_unmarked INTERFACE tinyusb_device_base)
target_compile_definitions(tinyusb_device_unmarked INTERFACE
# off by default note TUD_OPT_RP2040_USB_DEVICE_ENUMERATION_FIX defaults from PICO_RP2040_USB_DEVICE_ENUMERATION_FIX
# TUD_OPT_RP2040_USB_DEVICE_ENUMERATION_FIX=1
)
# unmarked version used by stdio USB
target_link_libraries(tinyusb_device_unmarked INTERFACE tinyusb_common pico_fix_rp2040_usb_device_enumeration)
target_link_libraries(tinyusb_device_unmarked INTERFACE tinyusb_common pico_fix_rp2040_usb_device_enumeration tinyusb_device_base)
pico_add_impl_library(tinyusb_device)
target_link_libraries(tinyusb_device INTERFACE tinyusb_device_unmarked)
target_compile_definitions(tinyusb_device INTERFACE
RP2040_USB_DEVICE_MODE=1 #define is used by tinyusb still
)
pico_add_impl_library(tinyusb_host)
target_sources(tinyusb_host INTERFACE
${PICO_TINYUSB_PATH}/src/portable/raspberrypi/rp2040/hcd_rp2040.c
${PICO_TINYUSB_PATH}/src/portable/raspberrypi/rp2040/rp2040_usb.c
${PICO_TINYUSB_PATH}/src/host/usbh.c
${PICO_TINYUSB_PATH}/src/host/usbh_control.c
${PICO_TINYUSB_PATH}/src/host/hub.c
${PICO_TINYUSB_PATH}/src/class/cdc/cdc_host.c
${PICO_TINYUSB_PATH}/src/class/hid/hid_host.c
${PICO_TINYUSB_PATH}/src/class/msc/msc_host.c
${PICO_TINYUSB_PATH}/src/class/vendor/vendor_host.c
)
# Sometimes have to do host specific actions in mostly
# common functions
target_compile_definitions(tinyusb_host INTERFACE
RP2040_USB_HOST_MODE=1 #define is used by tinyusb still
)
target_link_libraries(tinyusb_host INTERFACE tinyusb_common)
target_link_libraries(tinyusb_host INTERFACE tinyusb_host_base tinyusb_common)
pico_add_impl_library(tinyusb_board)
target_sources(tinyusb_board INTERFACE
${PICO_TINYUSB_PATH}/hw/bsp/raspberry_pi_pico/board_raspberry_pi_pico.c
)
target_link_libraries(tinyusb_board INTERFACE tinyusb_bsp)
pico_promote_common_scope_vars()
endif()