usb
Vitis Drivers API Documentation
|
This file contains an example for USB Mouse.
MODIFICATION HISTORY:
Ver Who Date Changes
1.00a hvm 6/21/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.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 | UsbMouseExample (u16 UsbId, u16 GpioId) |
This function implements the USB mouse application. 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 Mouse example. More... | |
void | InitUsbInterface (XUsb *InstancePtr) |
This is the USB initialization function. More... | |
void | UsbIfIntrHandler (void *CallBackRef, u32 IntrStatus) |
This function is the interrupt handler for the USB reset, suspend and disconnect events. 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_Config::BaseAddress, XUsb_EpConfig::Buffer0Count, XUsb_EpConfig::Buffer0Ready, XUsb_EpConfig::Buffer1Count, XUsb_EpConfig::Buffer1Ready, XUsb::Config, XUsb::DeviceConfig, XUsb::EndPointOffset, XUsb_DeviceConfig::Ep, XUSB_BUFFREADY_EP1_BUFF1_MASK, XUSB_BUFFREADY_EP1_BUFF2_MASK, XUSB_EP_BUF0COUNT_OFFSET, XUSB_EP_BUF1COUNT_OFFSET, and XUsb_ReadReg.
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 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. |
void InitUsbInterface | ( | XUsb * | InstancePtr | ) |
This is the USB initialization function.
This example initializes the USB device for USB mouse example. The following configuration is done.
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 Mouse example.
None. |
References UsbMouseExample().
void UsbIfIntrHandler | ( | void * | CallBackRef, |
u32 | IntrStatus | ||
) |
This function is the interrupt handler for the USB reset, suspend and disconnect events.
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 UsbMouseExample | ( | u16 | UsbId, |
u16 | GpioId | ||
) |
This function implements the USB mouse application.
This function sets up the ML403 evaluation board as a USB mouse. The mouse cursor movement can be seen on the PC as and when any of the push buttons SW3, SW4, SW5 and SW7 on the ML403 Evaluation board is pressed. Pressing the push button SW6 stops the test.
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().