2.2.4.23 USB_DEVICE_EndpointDisable Function

C

USB_DEVICE_RESULT USB_DEVICE_EndpointDisable(
    USB_DEVICE_HANDLE usbDeviceHandle, 
    USB_ENDPOINT_ADDRESS endpoint
);

Summary

This function disables a device endpoint. The application may need to disable the endpoint when it want to change the endpoint characteristics. This could happen when the device features interfaces with multiple alternate settings. If such cases, the host may request the device to switch to specific alternate setting by sending the Set Interface request. The device application must then disable the endpoint (if it was enabled) before re-enabling it with the new settings.The application can use the USB_DEVICE_EndpointIsEnabled function to check the status of the endpoint and USB_DEVICE_EndpointEnable function to enable the endpoint.

Precondition

The device should have been configured.

Parameters

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

Returns

USB_DEVICE_RESULT_OK - The endpoint was enabled successfully.

USB_DEVICE_RESULT_ERROR_ENDPOINT_INVALID - The specified instance was not provisioned in the application 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.