You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2021/08/15 15:49:44 UTC

[mynewt-core] 02/03: tinyusb: Update VBUS detection for stm32f7

This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit f04aeab07417a1a4a24b76670bc6d226c1296226
Author: Jerzy Kasenberg <je...@apache.org>
AuthorDate: Sat Aug 14 19:11:56 2021 +0200

    tinyusb: Update VBUS detection for stm32f7
    
    Some register content differs between F4 and F7.
    One of the differences is VBUS detection bits in
    GOTGCTL and GCCFG.
    This adds code for F7 flavour of synopsys module
    for VBUS detection.
---
 hw/usb/tinyusb/synopsys/src/synopsys.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/hw/usb/tinyusb/synopsys/src/synopsys.c b/hw/usb/tinyusb/synopsys/src/synopsys.c
index b6b4106..84298f8 100755
--- a/hw/usb/tinyusb/synopsys/src/synopsys.c
+++ b/hw/usb/tinyusb/synopsys/src/synopsys.c
@@ -72,5 +72,16 @@ tinyusb_hardware_init(void)
     USB_OTG_FS->GCCFG |= ~USB_OTG_GCCFG_VBUSASEN;
     hal_gpio_init_af(MCU_GPIO_PORTA(9), GPIO_AF10_OTG_FS, GPIO_NOPULL, GPIO_MODE_AF_PP);
 #endif
+#elif USB_OTG_GCCFG_VBDEN
+#if MYNEWT_VAL(USB_VBUS_DETECTION_ENABLE)
+    hal_gpio_init_in(MCU_GPIO_PORTA(9), HAL_GPIO_PULL_NONE);
+    USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBDEN;
+#else
+    /* PA9- VUSB not used for USB */
+    USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN;
+    /* B-peripheral session valid override enable */
+    USB_OTG_FS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOEN;
+    USB_OTG_FS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOVAL;
+#endif
 #endif
 }