Преглед изворни кода

Merge pull request #1723 from hathach/fix-rp2040-minor

Fix rp2040 minor
Ha Thach пре 3 година
родитељ
комит
a97f6a4945
4 измењених фајлова са 21 додато и 6 уклоњено
  1. 12 0
      hw/bsp/rp2040/board.h
  2. 7 4
      hw/bsp/rp2040/family.c
  3. 1 1
      hw/bsp/rp2040/family.cmake
  4. 1 1
      hw/mcu/raspberry_pi/Pico-PIO-USB

+ 12 - 0
hw/bsp/rp2040/board.h

@@ -46,6 +46,18 @@
 #define UART_RX_PIN           PICO_DEFAULT_UART_RX_PIN
 #define UART_RX_PIN           PICO_DEFAULT_UART_RX_PIN
 #endif
 #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
 #ifdef __cplusplus
  }
  }
 #endif
 #endif

+ 7 - 4
hw/bsp/rp2040/family.c

@@ -39,9 +39,6 @@
 #include "pio_usb.h"
 #include "pio_usb.h"
 #endif
 #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
 #ifdef BUTTON_BOOTSEL
 // This example blinks the Picoboard LED when the BOOTSEL button is pressed.
 // 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 the system clock to a multiple of 120mhz for bitbanging USB with pico-usb
   set_sys_clock_khz(120000, true);
   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
   // 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()
   // Note: tuh_configure() must be called before tuh_init()
   pio_usb_configuration_t pio_cfg = PIO_USB_DEFAULT_CONFIG;
   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);
   tuh_configure(BOARD_TUH_RHPORT, TUH_CFGID_RPI_PIO_USB_CONFIGURATION, &pio_cfg);
 #endif
 #endif
 
 

+ 1 - 1
hw/bsp/rp2040/family.cmake

@@ -55,7 +55,7 @@ if (NOT TARGET _rp2040_family_inclusion_marker)
 	target_compile_definitions(tinyusb_common_base INTERFACE
 	target_compile_definitions(tinyusb_common_base INTERFACE
 			CFG_TUSB_MCU=OPT_MCU_RP2040
 			CFG_TUSB_MCU=OPT_MCU_RP2040
 			CFG_TUSB_OS=OPT_OS_PICO
 			CFG_TUSB_OS=OPT_OS_PICO
-			CFG_TUSB_DEBUG=${TINYUSB_DEBUG_LEVEL}
+			#CFG_TUSB_DEBUG=${TINYUSB_DEBUG_LEVEL}
 	)
 	)
 
 
 	#------------------------------------
 	#------------------------------------

+ 1 - 1
hw/mcu/raspberry_pi/Pico-PIO-USB

@@ -1 +1 @@
-Subproject commit 92bd3b4c3ad2fce36166e4a357749b6d4fe9013b
+Subproject commit f78dc9b2c7fa9b82587e43babdc1d21294a32985