Skip to content

Commit

Permalink
Fixup for tinyusb-0.9.0+ changes and bump tinyusb ref to pico-0.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kilograham committed May 31, 2021
1 parent 59e50a8 commit f1c4988
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/tinyusb
Submodule tinyusb updated 814 files
6 changes: 6 additions & 0 deletions src/rp2_common/hardware_uart/include/hardware/uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 5 additions & 7 deletions src/rp2_common/pico_stdio_usb/reset_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand All @@ -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
};
Expand Down
11 changes: 9 additions & 2 deletions src/rp2_common/tinyusb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ endif()
if (EXISTS ${PICO_TINYUSB_PATH}/${TINYUSB_TEST_PATH})
message("TinyUSB available at ${PICO_TINYUSB_PATH}/${TINYUSB_TEST_PATH}; adding USB support.")

# todo some of this functionality now overlaps tinyusb/hw/bsp/rp2040/family.cmake and some of this
# should be moved there in the future

pico_register_common_scope_var(PICO_TINYUSB_PATH)
add_library(tinyusb_common INTERFACE)
target_link_libraries(tinyusb_common INTERFACE
hardware_structs
Expand Down Expand Up @@ -56,6 +60,7 @@ if (EXISTS ${PICO_TINYUSB_PATH}/${TINYUSB_TEST_PATH})
${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_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
Expand Down Expand Up @@ -102,8 +107,10 @@ if (EXISTS ${PICO_TINYUSB_PATH}/${TINYUSB_TEST_PATH})

pico_add_impl_library(tinyusb_board)
target_sources(tinyusb_board INTERFACE
${PICO_TINYUSB_PATH}/hw/bsp/raspberry_pi_pico/board_raspberry_pi_pico.c
${PICO_TINYUSB_PATH}/hw/bsp/rp2040/family.c
)

endif()
target_include_directories(tinyusb_board INTERFACE ${PICO_TINYUSB_PATH}/hw/bsp/rp2040/boards/sdk_selected)

pico_promote_common_scope_vars()
endif()

0 comments on commit f1c4988

Please sign in to comment.