2018-01-30 01:48 AM
Hi,
Can someone please explain what is the VBUS detect (HAL_PCDEx_BCD_VBUSDetect) and battery charging (USBD_LL_BatteryCharging), what is it used for and how to use it (with STM32L4)?
Currently I have an EXTI interrupt on a port that gets the USB VBUS, I use it to turn off the USB peripheral once the VBUS is not present and turn it back on once it is detected again.
I use USB device in VCP mode.
Thanks
#usb-device #usb-vcp #stm32l42018-01-30 02:08 AM
They appear to be related to Battery Charging Detection functionality of the USB IPs, see respective RM (note that there are two distinct incarnations of that IP, the device-only, and the Synopsys-originated OTG), see
https://en.wikipedia.org/wiki/USB#USB_Battery_Charging
and seehttp://www.usb.org/developers/docs/devclass_docs/BCv1.2_070312.zip
That detection happens on DP/DM, so you can't really use that for cable disconnect while communication is ongoing.
The OTG version of USB IP has a dedicated pin for VBUS detection, OTG_FS_VBUS (on PA9).
JW
2018-01-30 03:54 AM
Thanks, I will read through that.
The PA9 for VBUS is what I use but as EXTI input and not AF, since I didn't see implementation in the peripheral or HAL for VBUS disconnection that turns of the device, if I recall correctly it puts the system in deep sleep mode and that is not desired.
2018-01-30 04:33 AM
it [VBUS disconnect] puts the system in deep sleep mode
There's no hardware for doing that, so this conclusion comes from observation of behaviour of some arbitrary code.
Disconnectiong VBUS in OTG - if VBUS detection is enabled - results in GOTGINT.SEDET being set, and that - again if not masked - results in interrupt through setting GINTSTS.OTGINT
This in Cube calls HAL_PCD_DisconnectCallback().
JW