From d5d93a4ef1089fb5b89201a8a87954a7d7dda2d0 Mon Sep 17 00:00:00 2001 From: David Douard Date: Tue, 5 Oct 2021 19:48:59 +0200 Subject: [PATCH] STM32: fix USB_reenumerate() for STM32F3 for which the DP pin remained forced low after the reenumerate sequence (low for 10ms) instead of being reconfigured as an input (PullNone). Signed-off-by: David Douard --- targets/TARGET_STM/USBPhy_STM32.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/targets/TARGET_STM/USBPhy_STM32.cpp b/targets/TARGET_STM/USBPhy_STM32.cpp index 28068ee972..c45150de4b 100644 --- a/targets/TARGET_STM/USBPhy_STM32.cpp +++ b/targets/TARGET_STM/USBPhy_STM32.cpp @@ -194,7 +194,7 @@ USBPhyHw::~USBPhyHw() #if defined(TARGET_STM32F1) || defined(TARGET_STM32F3) || defined(SYSCFG_PMC_USB_PU) -#include "drivers/DigitalOut.h" +#include "drivers/DigitalInOut.h" void USB_reenumerate() { @@ -204,14 +204,15 @@ void USB_reenumerate() wait_us(10000); // 10ms LL_SYSCFG_EnableUSBPullUp(); #elif defined(USB_PULLUP_CONTROL) - mbed::DigitalOut usb_dp_pin(USB_PULLUP_CONTROL, 0); + mbed::DigitalInOut usb_dp_pin(USB_PULLUP_CONTROL, PIN_OUTPUT, PullNone, 0); wait_us(1000); usb_dp_pin = 1; wait_us(1000); #else // Force USB_DP pin (with external pull up) to 0 - mbed::DigitalOut usb_dp_pin(USB_DP, 0); + mbed::DigitalInOut usb_dp_pin(USB_DP, PIN_OUTPUT, PullNone, 0); wait_us(10000); // 10ms + usb_dp_pin.input(); // revert as input #endif } #endif