Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kuldeepdhaka/1a2f810dd47d611fd731b46a2774bb52 to your computer and use it in GitHub Desktop.
Save kuldeepdhaka/1a2f810dd47d611fd731b46a2774bb52 to your computer and use it in GitHub Desktop.
diff --git a/lib/usb/usb_f107.c b/lib/usb/usb_f107.c
index fb8ddf5..af98ddc 100644
--- a/lib/usb/usb_f107.c
+++ b/lib/usb/usb_f107.c
@@ -55,8 +55,14 @@ static usbd_device *stm32f107_usbd_init(void)
OTG_FS_GINTSTS = OTG_GINTSTS_MMIS;
OTG_FS_GUSBCFG |= OTG_GUSBCFG_PHYSEL;
- /* Enable VBUS sensing in device mode and power down the PHY. */
- OTG_FS_GCCFG |= OTG_GCCFG_VBUSBSEN | OTG_GCCFG_PWRDWN;
+
+ /* Enable VBUS sensing in device mode and power down the PHY.
+ * note: bit VBDEN and NOVBUSSENS are same */
+ OTG_FS_GCCFG |= OTG_GCCFG_PWRDWN | OTG_GCCFG_NOVBUSSENS |
+ OTG_GCCFG_VBUSASEN | OTG_GCCFG_VBUSBSEN;
+
+ /* make sure that SDIS is low */
+ OTG_FS_DCTL &= ~OTG_DCTL_SDIS;
/* Wait for AHB idle. */
while (!(OTG_FS_GRSTCTL & OTG_GRSTCTL_AHBIDL));
@davids5
Copy link

davids5 commented Aug 9, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment