AnsweredAssumed Answered

HAL CDC VCP stop & re-start

Question asked by Francis Cobain on Jan 10, 2018
Latest reply on Jan 18, 2018 by Francis Cobain

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

Outcomes