Merge pull request #1974 from hathach/pico-pio-name

rename and change default pio usb pin to adafruit feather usb host
This commit is contained in:
Ha Thach 2023-03-23 14:22:39 +07:00 committed by GitHub
commit cd0fdc3264
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 11 deletions

View File

@ -36,7 +36,7 @@
#if CFG_TUSB_MCU == OPT_MCU_RP2040
// change to 1 if using pico-pio-usb as host controller for raspberry rp2040
#define CFG_TUH_RPI_PIO_USB 1
#define CFG_TUH_RPI_PIO_USB 0
#define BOARD_TUH_RHPORT CFG_TUH_RPI_PIO_USB
#endif

View File

@ -31,6 +31,7 @@
extern "C" {
#endif
// LED
#ifdef PICO_DEFAULT_LED_PIN
#define LED_PIN PICO_DEFAULT_LED_PIN
#define LED_STATE_ON (!(PICO_DEFAULT_LED_PIN_INVERTED))
@ -40,6 +41,7 @@
#define BUTTON_BOOTSEL
#define BUTTON_STATE_ACTIVE 0
// UART
#if defined(PICO_DEFAULT_UART_TX_PIN) && defined(PICO_DEFAULT_UART_RX_PIN) && \
defined(PICO_DEFAULT_UART) && defined(LIB_PICO_STDIO_UART)
#define UART_DEV PICO_DEFAULT_UART
@ -47,16 +49,27 @@
#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
// PIO_USB
// #define USE_ADAFRUIT_RP2040_TESTER
#ifdef USE_ADAFRUIT_RP2040_TESTER
#define PICO_DEFAULT_PIO_USB_DP_PIN 20
#define PICO_DEFAULT_PIO_USB_VBUSEN_PIN 22
#endif
// following default to pin on Adafruit Feather rp2040 USB Host
#ifndef PICO_DEFAULT_PIO_USB_DP_PIN
#define PICO_DEFAULT_PIO_USB_DP_PIN 16
#endif
// VBUS enable pin and its active state
#define PIO_USB_VBUSEN_PIN 22
#ifndef PICO_DEFAULT_PIO_USB_VBUSEN_PIN
#define PICO_DEFAULT_PIO_USB_VBUSEN_PIN 18
#endif
#ifndef PIO_USB_VBUSEN_STATE
#define PIO_USB_VBUSEN_STATE 1
// VBUS enable state
#ifndef PICO_DEFAULT_PIO_USB_VBUSEN_STATE
#define PICO_DEFAULT_PIO_USB_VBUSEN_STATE 1
#endif
#ifdef __cplusplus

View File

@ -126,15 +126,15 @@ void board_init(void)
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);
gpio_init(PICO_DEFAULT_PIO_USB_VBUSEN_PIN);
gpio_set_dir(PICO_DEFAULT_PIO_USB_VBUSEN_PIN, GPIO_OUT);
gpio_put(PICO_DEFAULT_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 = PIO_USB_DP_PIN;
pio_cfg.pin_dp = PICO_DEFAULT_PIO_USB_DP_PIN;
tuh_configure(BOARD_TUH_RHPORT, TUH_CFGID_RPI_PIO_USB_CONFIGURATION, &pio_cfg);
#endif