Detecting USB connection and charger events

3 posts / 0 new
Last post
david_33021
Offline
Last seen:11个月1week ago
加入:2015-07-28 15:10
Detecting USB connection and charger events

Hi,

Wondering how to detect when the user plugs in a USB cable, or when the battery charger starts or stops charging? I haven't seen this in the documentation yet, but it appears Dialog has provided us with a rich set of callbacks in sdk/cpm/sys_charger.c that applications can implement to handle USB and charger lifecycle events. For example:

usb_attach_cb(): Called when the user connects a USB cable (looks for a transition in the voltage on VBUS, I believe)
usb_detach_cb(): Called when the user removes the USB cable
usb_charging()
usb_charged()
usb_charger_battery_full()
...

Hope this helps others looking to adjust their applications' behavior on USB connection events and as the charger transitions states.

David

Device:
david_33021
Offline
Last seen:11个月1week ago
加入:2015-07-28 15:10
Adding a comment so I can

Adding a comment so I can close the topic.

David

MT_dialog
Offline
Last seen:2 months 1 week ago
工作人员
加入:2015-06-08 11:34
Hi david_33021,

Hi david_33021,

In order to get notified that something is pluged on your USB device the VBUS_Handler() will occur and eventually the usb_attach_cb() function will occur if that is your question.

Thanks MT_dialog