USB Libraries Help > USB Device Libraries > USB Device Layer Library > Library Interface > d) Device Management Functions > USB_DEVICE_Detach Function
MPLAB Harmony USB Stack
USB_DEVICE_Detach Function

This function will detach the device from the USB. It does this by disabling the pull up resistors on the D+ or D- lines. This function should be called when the application wants to disconnect the device from the bus (typically to implement a soft detach or switch to host mode operation). It should be called when the Device Layer has generated the USB_DEVICE_EVENT_POWER_REMOVED event.

C
void USB_DEVICE_Detach(
    USB_DEVICE_HANDLE usbDeviceHandle
);
Preconditions

The device layer should have been initialized and opened.

Parameters
Parameters 
Description 
usbDeviceHandle 
Client's driver handle (returned from USB_DEVICE_Open
Returns

None.

Remarks

None.

Example
USB_DEVICE_HANDLE usbDeviceHandle;

// Detach the device from the USB
USB_DEVICE_Detach( usbDeviceHandle );