From 5277cf0c4ca645fd395c1dc8c097897ed4cb58ed Mon Sep 17 00:00:00 2001 From: Liz Date: Mon, 24 Mar 2025 10:43:09 -0400 Subject: [PATCH] add usb host power for rev b --- MCUME_pico2/config/iopins.h | 1 + MCUME_pico2/display/emuapi.cpp | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/MCUME_pico2/config/iopins.h b/MCUME_pico2/config/iopins.h index 8c97b65..bbceb26 100644 --- a/MCUME_pico2/config/iopins.h +++ b/MCUME_pico2/config/iopins.h @@ -67,5 +67,6 @@ #define PIN_USB_HOST_DP (1u) #define PIN_USB_HOST_DM (2u) +#define PIN_USB_HOST_VBUS (11u) #endif diff --git a/MCUME_pico2/display/emuapi.cpp b/MCUME_pico2/display/emuapi.cpp index 465f872..f138498 100644 --- a/MCUME_pico2/display/emuapi.cpp +++ b/MCUME_pico2/display/emuapi.cpp @@ -1591,11 +1591,18 @@ void emu_init(void) #ifdef HAS_USBHOST pio_usb_configuration_t pio_cfg = PIO_USB_DEFAULT_CONFIG; - _Static_assert(PIN_USB_HOST_DP + 1 == PIN_USB_HOST_DM || PIN_USB_HOST_DP - 1 == PIN_USB_HOST_DM, "Permitted USB D+/D- configuration"); + *Static*assert(PIN_USB_HOST_DP + 1 == PIN_USB_HOST_DM || PIN_USB_HOST_DP - 1 == PIN_USB_HOST_DM, "Permitted USB D+/D- configuration"); pio_cfg.pinout = PIN_USB_HOST_DP + 1 == PIN_USB_HOST_DM ? PIO_USB_PINOUT_DPDM : PIO_USB_PINOUT_DMDP; pio_cfg.pin_dp = PIN_USB_HOST_DP; - tuh_configure(BOARD_TUH_RHPORT, TUH_CFGID_RPI_PIO_USB_CONFIGURATION, &pio_cfg); + #ifdef PIN_USB_HOST_VBUS + printf("Enabling USB host VBUS power on GP%d\r\n", PIN_USB_HOST_VBUS); + gpio_init(PIN_USB_HOST_VBUS); + gpio_set_dir(PIN_USB_HOST_VBUS, GPIO_OUT); + gpio_put(PIN_USB_HOST_VBUS, 1); + #endif + + tuh_configure(BOARD_TUH_RHPORT, TUH_CFGID_RPI_PIO_USB_CONFIGURATION, &pio_cfg); printf("Init USB...\n"); printf("USB D+/D- on GP%d and GP%d\r\n", PIN_USB_HOST_DP, PIN_USB_HOST_DM); printf("TinyUSB Host HID Controller Example\r\n");