Skip to content

Commit c9c8560

Browse files
johnboilestore-espressif
authored andcommitted
fix(usb/phy): Fix ability to switch back to USB/JTAG after uninstalling TinyUSB
Fixes #15912. This is a revert of a change made in 005ae05 that breaks the ability to re-initalize the USB/JTAG device after uninstalling TinyUSB. Closes #15912
1 parent 38e84d5 commit c9c8560

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

components/usb/usb_phy.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "esp_private/usb_phy.h"
1414
#include "esp_private/critical_section.h"
1515
#include "soc/usb_dwc_periph.h"
16+
#include "hal/usb_serial_jtag_hal.h"
1617
#include "hal/usb_wrap_hal.h"
1718
#include "hal/usb_utmi_hal.h"
1819
#include "esp_rom_gpio.h"
@@ -347,6 +348,12 @@ esp_err_t usb_new_phy(const usb_phy_config_t *config, usb_phy_handle_t *handle_r
347348
usb_wrap_hal_phy_set_external(&phy_context->wrap_hal, (phy_target == USB_PHY_TARGET_EXT));
348349
#endif
349350
}
351+
#if SOC_USB_SERIAL_JTAG_SUPPORTED && USB_SERIAL_JTAG_LL_EXT_PHY_SUPPORTED
352+
else if (config->controller == USB_PHY_CTRL_SERIAL_JTAG) {
353+
usb_serial_jtag_hal_phy_set_external(NULL, (config->target == USB_PHY_TARGET_EXT));
354+
phy_context->otg_mode = USB_OTG_MODE_DEVICE;
355+
}
356+
#endif
350357

351358
// For FSLS PHY that shares pads with GPIO peripheral, we must set drive capability to 3 (40mA)
352359
if (phy_target == USB_PHY_TARGET_INT) {

0 commit comments

Comments
 (0)