Protocols — USB Support
Version 1.10 12/01/02 14-47
Examples
Below is an example of how an asynchronous interrupt transfer is used. The example shows how a
USB Keyboard Device Driver can periodically receive data from interrupt endpoint.
EFI_USB_IO_PROTOCOL *UsbIo;
EFI_STATUS Status;
USB_KEYBOARD_DEV *UsbKeyboardDevice;
EFI_USB_INTERRUPT_CALLBACK KeyboardHandle;
. . .
Status = UsbIo->UsbAsyncInterruptTransfer(
UsbIo,
UsbKeyboardDevice->IntEndpointAddress,
TRUE,
UsbKeyboardDevice->IntPollingInterval,
8,
KeyboardHandler,
UsbKeyboardDevice
);
. . .
//
// The following is the InterruptCallback function. If there is any results got
// from Asynchoronous Interrupt Transfer, this function will be called.
//
EFI_STATUS
KeyboardHandler(
IN VOID *Data,
IN UINTN DataLength,
IN VOID *Context,
IN UINT32 Result
)
{
USB_KEYBOARD_DEV *UsbKeyboardDevice;
UINTN I;
if(EFI_ERROR(Result))
{
//
// Something error during this transfer, just to some recovery work
//
. . .
. . .
return EFI_DEVICE_ERROR;
}
UsbKeyboardDevice = (USB_KEYBOARD_DEV *)Context;
for(I = 0; I < DataLength; I++)
{
ParsedData(Data[I]);
. . .
}
return EFI_SUCCESS;
}