From 38f4507ff0834b70b533d1f7c973ba544316f633 Mon Sep 17 00:00:00 2001 From: JojoS62 Date: Sat, 17 Oct 2020 00:50:40 +0200 Subject: [PATCH] fix USB in sleep mode in sleep mode, USB interrupts were disabled and USB Device was not working. Sleep mode is default in Mbed-os e.g. in a call to sleep_for() --- targets/TARGET_STM/USBPhy_STM32.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/targets/TARGET_STM/USBPhy_STM32.cpp b/targets/TARGET_STM/USBPhy_STM32.cpp index 382d9d438c..3af20e2c69 100644 --- a/targets/TARGET_STM/USBPhy_STM32.cpp +++ b/targets/TARGET_STM/USBPhy_STM32.cpp @@ -229,6 +229,14 @@ void USBPhyHw::init(USBPhyEvents *events) hpcd.Init.use_external_vbus = DISABLE; __HAL_RCC_USB_OTG_HS_CLK_ENABLE(); + + #ifdef __HAL_RCC_USB1_OTG_FS_ULPI_CLK_SLEEP_DISABLE + __HAL_RCC_USB1_OTG_FS_ULPI_CLK_SLEEP_DISABLE(); + #endif + #ifdef __HAL_RCC_USB2_OTG_FS_ULPI_CLK_SLEEP_DISABLE + __HAL_RCC_USB2_OTG_FS_ULPI_CLK_SLEEP_DISABLE(); + #endif + map = PinMap_USB_HS; #elif (MBED_CONF_TARGET_USB_SPEED == USE_USB_OTG_FS) @@ -238,6 +246,14 @@ void USBPhyHw::init(USBPhyEvents *events) hpcd.Init.speed = PCD_SPEED_FULL; __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); + + #ifdef __HAL_RCC_USB1_OTG_FS_ULPI_CLK_SLEEP_DISABLE + __HAL_RCC_USB1_OTG_FS_ULPI_CLK_SLEEP_DISABLE(); + #endif + #ifdef __HAL_RCC_USB2_OTG_FS_ULPI_CLK_SLEEP_DISABLE + __HAL_RCC_USB2_OTG_FS_ULPI_CLK_SLEEP_DISABLE(); + #endif + map = PinMap_USB_FS; #elif (MBED_CONF_TARGET_USB_SPEED == USE_USB_NO_OTG)