2.2.4.25 USB_DEVICE_EndpointIsEnabled Function

C

bool USB_DEVICE_EndpointIsEnabled(
    USB_DEVICE_HANDLE usbDeviceHandle, 
    USB_ENDPOINT_ADDRESS endpoint
);

Summary

This function returns true if the endpoint is enabled. The application can use this function when handling Set Interface requests in case of Vendor or Custom USB devices.

Precondition

The device should have been configured.

Parameters

Parameters Description
usbDeviceHandle USB Device Layer Handle.
endpoint Endpoint to disable.

Returns

true - The endpoint is enabled.

false - The endpoint is not enabled or the specified endpoint is not provisioned in the system and is invalid.

Example

// The following code example checks if an Set Alternate request has
// been received and changes the endpoint characteristics based on the
// alternate setting. Endpoint is 1 and direction is device to host.
// Assume that endpoint size was 32 bytes in alternate setting 0.

if(setAlternateRequest)
{
    if(alternateSetting == 1)
    {
        // Check if the endpoint is already enabled.
        if(USB_DEVICE_EndpointIsEnabled(usbDeviceHandle, (0x1|USB_EP_DIRECTION_IN)))
        {
            // Disable the endpoint.
            USB_DEVICE_EndpointDisable(usbDeviceHandle, (0x1|USB_EP_DIRECTION_IN));
        }

        // Re-enable the endpoint with new settings
        USB_DEVICE_EndpointEnable(usbDeviceHandle, (0x1|USB_EP_DIRECTION_IN)
                    USB_TRANSFER_TYPE_BULK, 64);
    }
}

Remarks

None.