Jump to main content

##

# 2.2.4.6 USB_DEVICE_Close Function

## C

    void USB_DEVICE_Close(
        USB_DEVICE_HANDLE usbDeviceHandle
    );

## Summary

This function closes an opened handle to an instance of the USB device layer, invalidating the handle.

## Precondition

The USB_DEVICE_Initialize function must have been called for the specified device layer instance. USB_DEVICE_Open must have been called to obtain a valid opened device handle.

## Parameters

Parameters | Description
usbDeviceHandle | A valid open-instance handle, returned from USB_DEVICE_Open

## Returns

After calling this routine, the handle passed in "usbDevHandle" must not be used with any of the remaining driver routines. A new handle must be obtained by calling USB_DEVICE_Open() before the client may use the device layer again.

## Example

    USB_DEVICE_HANDLE usbDeviceHandle;

    // Before opening a handle, USB device must have been initialized
    // by calling USB_DEVICE_Initialize().
    usbDeviceHandle = USB_DEVICE_Open( USB_DEVICE_INDEX_0 );

    if(USB_DEVICE_HANDLE_INVALID == usbDeviceHandle)
    {
        //Failed to open handle.
    }

    //.................
    //.................
    // User's code
    //.................
    //.................
    // Close handle
    USB_DEVICE_Close( usbDevHandle );

## Remarks

None.