Jump to main content

##

# Endpoint Data Transfer Events

The USB Device Layer provides notification events to indicate completion of transfers. These events are generated by the Device Layer and are made available in the Device Layer event handler. The USB_DEVICE_EVENT_ENDPOINT_READ_COMPLETE event occurs when a transfer scheduled by the USB_DEVICE_EndpointRead function has completed. The USB_DEVICE_EVENT_ENDPOINT_WRITE_COMPLETE event occurs when a transfer scheduled by the USB_DEVICE_EndpointWrite function has completed. The event data accompanying these events contains the transfer handle and number of bytes that were transferred.

The following code shows an example of handling these events.

    /* The following code shows an example handling of the
     * endpoint transfer events. Here the code updates a transfer
     * pending flag indicating to the application that transfers have
     * completed. */
    case USB_DEVICE_EVENT_ENDPOINT_READ_COMPLETE:
        /* Endpoint read is complete */
        appData.epDataReadPending = false;
        break;
    case USB_DEVICE_EVENT_ENDPOINT_WRITE_COMPLETE:
        /* Endpoint write is complete */
        appData.epDataWritePending = false;
        break;