This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

USB CONNECT event and DISCONNECT event subscription

Hi,

I am looking for usb connect and disconnect events to be able to trigger some behaviors in our product.

I don't find any API for that, like subscribing via a callback to USB-events. It's kind of basic need for detecting USB-events.

Perhaps this isn't a Nordic question, but a zephyr one, but I thought why not ask if you guys have ideas or know anything.

I found events coming in into a callback in this driver: subsys/usb/class/cdc_acm.c

cdc_acm_do_cb () seems to get events and adding printing there, corresponds with me plugging and unplugging the usb cable.

PLUGGED:

<dbg> usb_cdc_acm.cdc_acm_do_cb: USB device connected

UNPLUG:

<inf> usb_cdc_acm: USB device suspended 

<inf> usb_cdc_acm: USB device disconnected 

Best,

Related