usb
Vitis Drivers API Documentation
|
This file contains an example for USB keyboard.
MODIFICATION HISTORY:
Ver Who Date Changes
1.00a hvm 5/31/07 First release 3.00a hvm 11/18/09 Updated to use HAL processor APIs. XUsb_mReadReg is renamed to XUsb_ReadReg and XUsb_mWriteReg is renamed to XUsb_WriteReg. 4.00a hvm 08/11/11 Updated the code in gpio isr to increment the index by 4 as a dummy byte is added in the Message variable in keyboard.h file to handle the address alignment issue. 4.02a bss 11/01/11 Modified UsbIfIntrHandler function to unconditionally reset when USB reset is asserted (CR 627574). 5.6 pm 07/05/23 Added support for system device-tree flow.
Functions | |
int | UsbKbdExample (u16 UsbId, u16 GpioId) |
This function implements the USB Keyboard example. More... | |
void | GpioIsr (void *InstancePtr) |
This function is the Interrupt Service Routine for the GPIO device. More... | |
int | main (void) |
This function is the main function of the USB Keyboard example. More... | |
void | InitUsbInterface (XUsb *InstancePtr) |
This function initializes the USB device for Keyboard example. More... | |
void | UsbIfIntrHandler (void *CallBackRef, u32 IntrStatus) |
This function is the interrupt handler for the USB keyboard example. More... | |
void | Ep0IntrHandler (void *CallBackRef, u8 EpNum, u32 IntrStatus) |
This function is the interrupt handler for the USB End point Zero events. More... | |
void | Ep1IntrHandler (void *CallBackRef, u8 EpNum, u32 IntrStatus) |
This function is the interrupt handler for the USB End point one events. More... | |
void Ep0IntrHandler | ( | void * | CallBackRef, |
u8 | EpNum, | ||
u32 | IntrStatus | ||
) |
This function is the interrupt handler for the USB End point Zero events.
CallBackRef | is the callback reference passed from the interrupt. handler, which in our case is a pointer to the driver instance. |
EpNum | is the end point number. |
IntrStatus | is a bit mask indicating pending interrupts. |
References Chapter9(), EP0ProcessInToken(), EP0ProcessOutToken(), XUSB_BUFFREADY_EP0_BUFF_MASK, XUsb_EpStall(), XUsb_IntrEnable(), XUSB_STATUS_DISCONNECT_MASK, XUSB_STATUS_FIFO_BUFF_FREE_MASK, XUSB_STATUS_FIFO_BUFF_RDY_MASK, XUSB_STATUS_RESET_MASK, XUSB_STATUS_SETUP_PACKET_MASK, and XUSB_STATUS_SUSPEND_MASK.
void Ep1IntrHandler | ( | void * | CallBackRef, |
u8 | EpNum, | ||
u32 | IntrStatus | ||
) |
This function is the interrupt handler for the USB End point one events.
CallBackRef | is the callback reference passed from the interrupt handler, which in our case is a pointer to the driver instance. |
EpNum | is the end point number. |
IntrStatus | is a bit mask indicating pending interrupts. |
References XUsb_EpConfig::Buffer0Ready, XUsb_EpConfig::Buffer1Ready, XUsb::DeviceConfig, XUsb_DeviceConfig::Ep, XUSB_BUFFREADY_EP1_BUFF1_MASK, and XUSB_BUFFREADY_EP1_BUFF2_MASK.
void GpioIsr | ( | void * | InstancePtr | ) |
This function is the Interrupt Service Routine for the GPIO device.
This function will detect the push button on the board has changed state and then prepare data to be sent to the host.
InstancePtr | is the GPIO component to operate on. It is a void pointer and in this case will be a pointer to the GPIO instance. |
This function will detect the push button on the board has changed state and then prepare data to be sent to the host upon receiving the Get
InstancePtr | is the GPIO component to operate on. It is a void pointer to meet the interface of an interrupt processing function. |
References XUsb_EpDataSend().
Referenced by UsbKbdExample(), and UsbMouseExample().
void InitUsbInterface | ( | XUsb * | InstancePtr | ) |
This function initializes the USB device for Keyboard example.
This is the USB initialization function.
The following is the configuration.
InstancePtr | is a pointer to the XUsb instance. |
References XUsb::DeviceConfig, XUsb_DeviceConfig::Ep, XUsb_EpConfig::EpType, XUsb_DeviceConfig::NumEndpoints, XUsb_EpConfig::OutIn, XUsb_EpConfig::RamBase, XUsb_EpConfig::Size, XUsb_ConfigureDevice(), XUSB_EP_DIRECTION_IN, XUSB_EP_DIRECTION_OUT, and XUsb_EpEnable().
int main | ( | void | ) |
This function is the main function of the USB Keyboard example.
None. |
References UsbKbdExample().
void UsbIfIntrHandler | ( | void * | CallBackRef, |
u32 | IntrStatus | ||
) |
This function is the interrupt handler for the USB keyboard example.
This function is the interrupt handler for the USB mass storage device application.
CallBackRef | is the callback reference passed from the interrupt handler, which in our case is a pointer to the driver instance. |
IntrStatus | is a bit mask indicating pending interrupts. |
References XUsb_Config::BaseAddress, XUsb::Config, XUsb_DeviceConfig::CurrentConfiguration, XUsb::DeviceConfig, InitUsbInterface(), XUsb_DeviceConfig::Status, XUsb_IntrDisable(), XUsb_IntrEnable(), XUSB_RESET, XUsb_SetDeviceAddress(), XUsb_Start(), XUSB_STATUS_DISCONNECT_MASK, XUSB_STATUS_RESET_MASK, XUSB_STATUS_SUSPEND_MASK, XUsb_Stop(), and XUsb_WriteReg.
int UsbKbdExample | ( | u16 | UsbId, |
u16 | GpioId | ||
) |
This function implements the USB Keyboard example.
The Key board action can be seen on the PC as and when any of the push buttons SW3 or SW4 or SW5 or SW7 on the ML403 evaluation board is pressed.
UsbId | is the USB device id. |
GpioId | is the GPIO device id. |
References XUsb_Config::BaseAddress, XUsb_DeviceConfig::CurrentConfiguration, XUsb::DeviceConfig, Ep0IntrHandler(), Ep1IntrHandler(), GpioIsr(), InitUsbInterface(), UsbIfIntrHandler(), XUsb_CfgInitialize(), XUsb_EpSetHandler(), XUsb_IntrEnable(), XUsb_IntrHandler(), XUsb_IntrSetHandler(), XUsb_LookupConfig(), XUsb_SetDeviceAddress(), XUsb_Start(), XUSB_STATUS_DISCONNECT_MASK, XUSB_STATUS_EP0_BUFF1_COMP_MASK, XUSB_STATUS_EP1_BUFF1_COMP_MASK, XUSB_STATUS_EP1_BUFF2_COMP_MASK, XUSB_STATUS_FIFO_BUFF_FREE_MASK, XUSB_STATUS_FIFO_BUFF_RDY_MASK, XUSB_STATUS_GLOBAL_INTR_MASK, XUSB_STATUS_RESET_MASK, and XUSB_STATUS_SUSPEND_MASK.
Referenced by main().