2016-09-17 06:15 AM
hey guys,
so I am using an STM32F411 as an USB device. It's connected via VCOM to a PC. I am using HAL V2.4.1 from19-June-2 In general it works good, but when I quickly connect and disconnect the usb plug on the device for a few times in a row and then re-connect with my terminal PC tool the device is no longer sending data becauseUSBD_CDC_TransmitPacket
returnsUSBD_BUSY only!
I have no idea how handle this case. Should I somehow reset the USB driver? Is this an indication that s/t is messed up with my implementation? Why is it busy? What can cause such a state?
Any help is appreciated. Let me know if you need more information on this.
2016-10-26 03:23 AM
Hi moll.benjamin,
If you want to know if you have a device is either connected or disconnected, use can a global variable inside both HAL_PCD_ConnectCallback() and HAL_PCD_DisconnectCallback().If USBD_LL_DevConnected status is USBD_OK you should change the value of the global variable to 1 (or whatever you prefer). You should write the code to update this global variable into every related callbacks.HAL_PCD_CconnectCallback() is called inside HAL_PCD_IRQHandler() (stm32fxx_hal_pcd.c), by GOTGINT.SEDET (session end detected) interrupt
.To ensure this interrupt is fired you need the following requirement:
-Hannibal-