Skip to content

Commit cd0fdc3

Browse files
authored
Merge pull request hathach#1974 from hathach/pico-pio-name
rename and change default pio usb pin to adafruit feather usb host
2 parents 07976ad + 4cee79a commit cd0fdc3

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

examples/host/cdc_msc_hid/src/tusb_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
#if CFG_TUSB_MCU == OPT_MCU_RP2040
3838
// change to 1 if using pico-pio-usb as host controller for raspberry rp2040
39-
#define CFG_TUH_RPI_PIO_USB 1
39+
#define CFG_TUH_RPI_PIO_USB 0
4040
#define BOARD_TUH_RHPORT CFG_TUH_RPI_PIO_USB
4141
#endif
4242

hw/bsp/rp2040/board.h

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
extern "C" {
3232
#endif
3333

34+
// LED
3435
#ifdef PICO_DEFAULT_LED_PIN
3536
#define LED_PIN PICO_DEFAULT_LED_PIN
3637
#define LED_STATE_ON (!(PICO_DEFAULT_LED_PIN_INVERTED))
@@ -40,23 +41,35 @@
4041
#define BUTTON_BOOTSEL
4142
#define BUTTON_STATE_ACTIVE 0
4243

44+
// UART
4345
#if defined(PICO_DEFAULT_UART_TX_PIN) && defined(PICO_DEFAULT_UART_RX_PIN) && \
4446
defined(PICO_DEFAULT_UART) && defined(LIB_PICO_STDIO_UART)
4547
#define UART_DEV PICO_DEFAULT_UART
4648
#define UART_TX_PIN PICO_DEFAULT_UART_TX_PIN
4749
#define UART_RX_PIN PICO_DEFAULT_UART_RX_PIN
4850
#endif
4951

50-
// PIO_USB_DP_PIN_DEFAULT is 0, which conflict with UART, change to other pin
51-
#ifndef PIO_USB_DP_PIN
52-
#define PIO_USB_DP_PIN 20
52+
// PIO_USB
53+
54+
// #define USE_ADAFRUIT_RP2040_TESTER
55+
#ifdef USE_ADAFRUIT_RP2040_TESTER
56+
#define PICO_DEFAULT_PIO_USB_DP_PIN 20
57+
#define PICO_DEFAULT_PIO_USB_VBUSEN_PIN 22
58+
#endif
59+
60+
// following default to pin on Adafruit Feather rp2040 USB Host
61+
#ifndef PICO_DEFAULT_PIO_USB_DP_PIN
62+
#define PICO_DEFAULT_PIO_USB_DP_PIN 16
5363
#endif
5464

5565
// VBUS enable pin and its active state
56-
#define PIO_USB_VBUSEN_PIN 22
66+
#ifndef PICO_DEFAULT_PIO_USB_VBUSEN_PIN
67+
#define PICO_DEFAULT_PIO_USB_VBUSEN_PIN 18
68+
#endif
5769

58-
#ifndef PIO_USB_VBUSEN_STATE
59-
#define PIO_USB_VBUSEN_STATE 1
70+
// VBUS enable state
71+
#ifndef PICO_DEFAULT_PIO_USB_VBUSEN_STATE
72+
#define PICO_DEFAULT_PIO_USB_VBUSEN_STATE 1
6073
#endif
6174

6275
#ifdef __cplusplus

hw/bsp/rp2040/family.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,15 @@ void board_init(void)
126126
set_sys_clock_khz(120000, true);
127127

128128
#ifdef PIO_USB_VBUSEN_PIN
129-
gpio_init(PIO_USB_VBUSEN_PIN);
130-
gpio_set_dir(PIO_USB_VBUSEN_PIN, GPIO_OUT);
131-
gpio_put(PIO_USB_VBUSEN_PIN, PIO_USB_VBUSEN_STATE);
129+
gpio_init(PICO_DEFAULT_PIO_USB_VBUSEN_PIN);
130+
gpio_set_dir(PICO_DEFAULT_PIO_USB_VBUSEN_PIN, GPIO_OUT);
131+
gpio_put(PICO_DEFAULT_PIO_USB_VBUSEN_PIN, PIO_USB_VBUSEN_STATE);
132132
#endif
133133

134134
// rp2040 use pico-pio-usb for host tuh_configure() can be used to passed pio configuration to the host stack
135135
// Note: tuh_configure() must be called before tuh_init()
136136
pio_usb_configuration_t pio_cfg = PIO_USB_DEFAULT_CONFIG;
137-
pio_cfg.pin_dp = PIO_USB_DP_PIN;
137+
pio_cfg.pin_dp = PICO_DEFAULT_PIO_USB_DP_PIN;
138138
tuh_configure(BOARD_TUH_RHPORT, TUH_CFGID_RPI_PIO_USB_CONFIGURATION, &pio_cfg);
139139
#endif
140140

0 commit comments

Comments
 (0)