From cb0ca6151bda002d8c9c6650ed8d5b225614e0e2 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 4 Nov 2022 17:08:02 +0700 Subject: [PATCH 1/3] remove CFG_TUSB_DEBUG from tinyusb_common_base --- hw/bsp/rp2040/family.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/bsp/rp2040/family.cmake b/hw/bsp/rp2040/family.cmake index 31e97d9af..5dba9dc39 100644 --- a/hw/bsp/rp2040/family.cmake +++ b/hw/bsp/rp2040/family.cmake @@ -55,7 +55,7 @@ if (NOT TARGET _rp2040_family_inclusion_marker) target_compile_definitions(tinyusb_common_base INTERFACE CFG_TUSB_MCU=OPT_MCU_RP2040 CFG_TUSB_OS=OPT_OS_PICO - CFG_TUSB_DEBUG=${TINYUSB_DEBUG_LEVEL} + #CFG_TUSB_DEBUG=${TINYUSB_DEBUG_LEVEL} ) #------------------------------------ From 44e19aa3c7ce7436a9722a609ca45530d3e1cb70 Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 6 Nov 2022 14:44:18 +0700 Subject: [PATCH 2/3] rename PIO_USB_PIN_DP to PIO_USB_DP_PIN and change from 2 to 20 & moved to board.h add support for PIO_USB_VBUSEN_PIN and its state. --- hw/bsp/rp2040/board.h | 12 ++++++++++++ hw/bsp/rp2040/family.c | 11 +++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/hw/bsp/rp2040/board.h b/hw/bsp/rp2040/board.h index 237f29dc2..56b8fec84 100644 --- a/hw/bsp/rp2040/board.h +++ b/hw/bsp/rp2040/board.h @@ -46,6 +46,18 @@ #define UART_RX_PIN PICO_DEFAULT_UART_RX_PIN #endif +// PIO_USB_DP_PIN_DEFAULT is 0, which conflict with UART, change to other pin +#ifndef PIO_USB_DP_PIN +#define PIO_USB_DP_PIN 20 +#endif + +// VBUS enable pin and its active state +// #define PIO_USB_VBUSEN_PIN 22 + +#ifndef PIO_USB_VBUSEN_STATE +#define PIO_USB_VBUSEN_STATE 1 +#endif + #ifdef __cplusplus } #endif diff --git a/hw/bsp/rp2040/family.c b/hw/bsp/rp2040/family.c index 90e2192c0..ee5a73ff6 100644 --- a/hw/bsp/rp2040/family.c +++ b/hw/bsp/rp2040/family.c @@ -39,9 +39,6 @@ #include "pio_usb.h" #endif -// PIO_USB_DP_PIN_DEFAULT is 0, which conflict with UART, change to 2 -#define PICO_PIO_USB_PIN_DP 2 - #ifdef BUTTON_BOOTSEL // This example blinks the Picoboard LED when the BOOTSEL button is pressed. // @@ -138,10 +135,16 @@ void board_init(void) // Set the system clock to a multiple of 120mhz for bitbanging USB with pico-usb set_sys_clock_khz(120000, true); +#ifdef PIO_USB_VBUSEN_PIN + gpio_init(PIO_USB_VBUSEN_PIN); + gpio_set_dir(PIO_USB_VBUSEN_PIN, GPIO_OUT); + gpio_put(PIO_USB_VBUSEN_PIN, PIO_USB_VBUSEN_STATE); +#endif + // rp2040 use pico-pio-usb for host tuh_configure() can be used to passed pio configuration to the host stack // Note: tuh_configure() must be called before tuh_init() pio_usb_configuration_t pio_cfg = PIO_USB_DEFAULT_CONFIG; - pio_cfg.pin_dp = PICO_PIO_USB_PIN_DP; + pio_cfg.pin_dp = PIO_USB_DP_PIN; tuh_configure(BOARD_TUH_RHPORT, TUH_CFGID_RPI_PIO_USB_CONFIGURATION, &pio_cfg); #endif From a061bc41733047468b624fb33dc0811d1eb984e4 Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 6 Nov 2022 14:46:44 +0700 Subject: [PATCH 3/3] bump up pico-pio-usb --- hw/mcu/raspberry_pi/Pico-PIO-USB | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/mcu/raspberry_pi/Pico-PIO-USB b/hw/mcu/raspberry_pi/Pico-PIO-USB index 92bd3b4c3..f78dc9b2c 160000 --- a/hw/mcu/raspberry_pi/Pico-PIO-USB +++ b/hw/mcu/raspberry_pi/Pico-PIO-USB @@ -1 +1 @@ -Subproject commit 92bd3b4c3ad2fce36166e4a357749b6d4fe9013b +Subproject commit f78dc9b2c7fa9b82587e43babdc1d21294a32985