2.6.4.4 USB_DEVICE_HID_TransferCancel Function

C

USB_DEVICE_HID_RESULT USB_DEVICE_HID_TransferCancel(
    USB_DEVICE_HID_INDEX instanceIndex, 
    USB_DEVICE_HID_TRANSFER_HANDLE transferHandle
);

Description

This function cancels a scheduled HID Device data transfer. The transfer could have been scheduled using the USB_DEVICE_HID_ReportReceive, USB_DEVICE_HID_ReportSend function. If a transfer is still in the queue and its processing has not started, then the transfer is canceled completely. A transfer that is in progress may or may not get canceled depending on the transaction that is presently in progress. If the last transaction of the transfer is in progress, then the transfer will not be canceled. If it is not the last transaction in progress, the in-progress will be allowed to complete. Pending transactions will be canceled. The first transaction of an in progress transfer cannot be canceled.

Precondition

The USB Device should be in a configured state.

Parameters

Parameters Description
instanceIndex HID Function Driver instance index.
transferHandle Transfer handle of the transfer to be canceled.

Returns

USB_DEVICE_HID_RESULT_OK - The transfer will be canceled completely or partially.

USB_DEVICE_HID_RESULT_ERROR_PARAMETER_INVALID - Invalid transfer handle.

USB_DEVICE_HID_RESULT_ERROR_INSTANCE_INVALID - Invalid HID instance index.

USB_DEVICE_HID_RESULT_ERROR - The transfer could not be canceled because it has either completed, the transfer handle is invalid or the last transaction is in progress.

Example

// The following code snippet cancels a HID transfer.

USB_DEVICE_HID_TRANSFER_HANDLE transferHandle;
USB_DEVICE_HID_RESULT result;

result = USB_DEVICE_HID_TransferCancel(instanceIndex, transferHandle);

if(USB_DEVICE_HID_RESULT_OK == result)
{
    // The transfer cancellation was either completely or 
    // partially successful.
}

Remarks

The buffer specific to the transfer handle should not be released unless the transfer abort event is notified through callback.