AnsweredAssumed Answered

Unable to shut down the USB core

Question asked by Deamonata on Apr 11, 2016
Latest reply on Apr 11, 2016 by Deamonata
I'm currently having some issues with the USB core on the STM32f4. Before enabling the USB core the VBUS line (GPIO A9) is low as would be expected. when a usb cable is plugged it I detect this and enable my USB core using the following function:

void MX_USB_Init(void)
     if(USBState == Disabled){
          /* Init Device Library */
          USBD_Init(&USBD_Device, &VCP_Desc, 0);

          /* Add Supported Class */
          USBD_RegisterClass(&USBD_Device, USBD_CDC_CLASS);

          /* Add CDC Interface Class */
          USBD_CDC_RegisterInterface(&USBD_Device, &USBD_CDC_fops);

          /* Start Device Process */

          USBState = Enabled;

This works fine and the USB appears to communicate correctly with the PC, the problem comes however when I disconnect the USB cable. Originally I wasn't deinitializing the USB core, but it was noticed that if the core was active, VBUS would output 1.9V. I then wrote the following function to disable the USB core

void MX_USB_Deinit(void)
     if(USBState == Enabled){

          /* Stop Device Process */

          /* Deinit Device Library */

          USBState = Disabled;

However I'm not sure it has fully shut down the USB core as I still have a voltage on USB VBUS (GPIO A9).