Skip to main content
Francis Cobain
Associate
January 10, 2018
Question

HAL CDC VCP stop & re-start

  • January 10, 2018
  • 1 reply
  • 677 views
Posted on January 10, 2018 at 17:28

Hi,

we have an issue with HAL when trying to stop and re-start CDC VCP. Board is discoF4. Based on the example USB_Device/CDC_Standalone/Src/main.c the code works fine after reset (DSPD=11, USBD_STATE_CONFIGURED). Once modified the example we try to stop it using: (A)     

      USBD_Stop(&hUsbDeviceFS);

      USBD_DeInit(&hUsbDeviceFS);

When re-starting with the same sequence:

      USBD_Init(&USBD_Device, &VCP_Desc, 0);

      USBD_RegisterClass(&USBD_Device, USBD_CDC_CLASS);

      USBD_CDC_RegisterInterface(&USBD_Device, &USBD_CDC_fops);

      USBD_Start(&USBD_Device);

It enters USBD_STATE_SUSPENDED with DSPD=01 and shows <<unknown device>> (43). We get the same result if we use:

      USB_DevDisconnect (USB_OTG_FS);

      USB_StopDevice(USB_OTG_FS);

instead of (A) to try to stop CDC VCP. Would be very grateful if anyone could provide guidance on how to properly stop and re-start CDC VCP. Thanks in advance.

Francis

    This topic has been closed for replies.

    1 reply

    Francis Cobain
    Associate
    January 18, 2018
    Posted on January 18, 2018 at 14:17

    __HAL_RCC_USB_OTG_FORCE_RESET() did the trick. Not a nice solution but we did not had the time to fiddle around.