Hi Jim,
To do this you need to enable detach feature by setting the following define in usb_device_config.h file.
#define USB_DEVICE_CONFIG_DETACH_ENABLE (1U)
This will enable notification to the device callback through USB_DeviceAttachNotification and USB_DeviceDetachNotification functions.
#if USB_DEVICE_CONFIG_DETACH_ENABLE
case kUSB_DeviceNotifyDetach:
status = USB_DeviceDetachNotification(handle, message);
break;
case kUSB_DeviceNotifyAttach:
status = USB_DeviceAttachNotification(handle, message);
break;
#endif
Now you can implement what you like to do in USB_DeviceCallback when this events occurred. I just print message a in console.
usb_status_t USB_DeviceCallback(usb_device_handle handle, uint32_t event, void *param)
{
usb_status_t error = kStatus_USB_Error;
switch (event)
{
case kUSB_DeviceEventAttach:
usb_echo("USB device attached\r\n");
break;
case kUSB_DeviceEventDetach:
usb_echo("USB device detached\r\n");
break;
Hope it helps!
Best regards,
Felipe
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored.
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
------------------------------------------------------------------------------