2015-08-27 03:18 AM
Hello there,
Trying to handle USB connection / disconnection event I realize that in stm32l1 usb api, there are no call to HAL_PCD_ConnectCallback neither HAL_PCD_DisconnectCallback as there are in STM32F4 !The session start/stop only works with HAL_PCD_ResumeCallback/HAL_PCD_SuspendCallback.These callbacks are called from HAL_PCD_IRQHandler(PCD_HandleTypeDef *hpcd) in stm32l1xx_hal_pcd.c which manage PCD IRQ.At the moment, it seems there's no USB_ISTR register flag for detecting connection / disconnection.Do someone find a clean solution for handling these events, especialy regarding power management and safety of use ?Thx. #stm32l1 #connection #usb2015-08-27 12:52 PM
Hi,
I have used HAL on F4, but StdPeriphLib on L1 so i can't comment L1 HAL. But what i know is that F4's have dedicated USB Vbus (OTG_FS_VBUS) input pin (PA9) which detects voltage on USB connector. L1's don't have that so they don't have such an interrupt either. If you want to get to know about connection of host or charger immediately then you need to take some spare IO pin and monitor Vbus on your own (e.g. by EXTI). Still, you can get to know about the device configuration/disconnection event but that won't work with charger and configuration always takes some time. Anyway, the L1 USB peripheral is little bit broken as well. The internal pull up on D+ has bad value so you need external one (see errata).2015-08-31 10:54 AM
Hey Leini,
Thx for sharing that.I got an interesting one about USB on L1 after digging a little bit on Cube FW 1.0.0When plugging/unplugging an usb to host, sometimes the Suspended callback is not anymore called and the devices stay in usbd_state_configured although the usb is unplugged.So it seems in this version there's no clean way to detect properly an USB connection/disconnection status.I'll try to move my app on Cube 1.3.0, the last one to see if this happens too.Regards.