usb
Vitis Drivers API Documentation
xusb_dma_intr_storage.c File Reference

Overview

This file has the USB example Mass storage device application function with SCSI command processing and related response preparation being implemented as a part of the interrupt handler.

Note
The example is tested on MicroBlaze system on SP605 board, with caches included in the H/W design.
MODIFICATION HISTORY:
Ver   Who  Date     Changes


1.00a hvm 2/22/07 First release. 4.00a hvm 06/01/11 Signature parameter of Command Status word is initialized with 'U''S''B''S' in ProcessRxCmd function. CR611761 fix. 4.01a bss 11/01/11 Modified UsbIfIntrHandler function to unconditionally reset when USB reset is asserted (CR 627574). 4.03a bss 02/05/13 Updated the example to support Zynq 5.6 pm 07/05/23 Removed powerpc support. 5.6 pm 07/05/23 Added support for system device-tree flow.

Functions

void ReadTransfer (XUsb *InstancePtr)
 This function implements the reception of data in the USB device for the READ request from the USB Host. More...
 
void WriteTransfer (XUsb *InstancePtr)
 This function implements the reception of data in the USB device for the WRITE request from the USB Host. More...
 
void DmaIntrHandler (void *CallBackRef, u32 IntrStatus)
 This function is the interrupt handler for the USB DMA events. More...
 
int main ()
 This main function starts the USB application. 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 mass storage device application. 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 Ep2IntrHandler (void *CallBackRef, u8 EpNum, u32 IntrStatus)
 This function is the interrupt handler for the USB End point two events. More...
 
void ProcessRxCmd (XUsb *InstancePtr)
 This function processes mass storage specific commands and sends the required response. More...
 
void Read10 (XUsb *InstancePtr, PUSBCBW pCmdBlock, PUSBCSW pStatusBlock)
 This function implements the transmission of data from the device to the READ request from the USB Host. More...
 
void Write10 (XUsb *InstancePtr, PUSBCBW pCmdBlock, PUSBCSW pStatusBlock)
 This function implements the reception of data in the USB device for the write request from the USB Host. More...
 
void MassStorageReset (XUsb *InstancePtr)
 This routine is called when a RESET class command is received. More...
 
void GetMaxLUN (XUsb *InstancePtr)
 This routine is called when a GETMAXLUN class command is received. More...
 

Function Documentation

void DmaIntrHandler ( void *  CallBackRef,
u32  IntrStatus 
)

This function is the interrupt handler for the USB DMA events.

Parameters
CallBackRefis the callback reference passed from the interrupt handler, which in our case is a pointer to the driver instance.
IntrStatusis a bit mask indicating pending interrupts.
Returns
None.
Note
None.

References XUsb::DeviceConfig, ProcessRxCmd(), ReadTransfer(), XUsb_DeviceConfig::Status, WriteTransfer(), XUSB_DISCONNECTED, XUsb_EpDataSend(), XUSB_STATUS_DMA_DONE_MASK, and XUSB_STATUS_DMA_ERROR_MASK.

Referenced by main().

void Ep0IntrHandler ( void *  CallBackRef,
u8  EpNum,
u32  IntrStatus 
)

This function is the interrupt handler for the USB End point Zero events.

Parameters
CallBackRefis the callback reference passed from the interrupt. handler, which in our case is a pointer to the driver instance.
EpNumis the end point number.
IntrStatusis a bit mask indicating pending interrupts.
Returns
None.
Note
EpNum is not used in this function as the handler is attached specific to end point zero. This parameter is useful when a single handler is used for processing all end point interrupts.

Referenced by main(), UsbKbdExample(), and UsbMouseExample().

void Ep1IntrHandler ( void *  CallBackRef,
u8  EpNum,
u32  IntrStatus 
)

This function is the interrupt handler for the USB End point one events.

Parameters
CallBackRefis the callback reference passed from the interrupt handler, which in our case is a pointer to the driver instance.
EpNumis the end point number.
IntrStatusis a bit mask indicating pending interrupts.
Returns
None.
Note
EpNum is not used in this function as the handler is attached specific to end point one. This parameter is useful when a single handler is used for processing all end point interrupts.

Referenced by main(), UsbKbdExample(), and UsbMouseExample().

void Ep2IntrHandler ( void *  CallBackRef,
u8  EpNum,
u32  IntrStatus 
)

This function is the interrupt handler for the USB End point two events.

Parameters
CallBackRefis the callback reference passed from the interrupt handler, which in our case is a pointer to the driver instance.
EpNumis the end point number.
IntrStatusis a bit mask indicating pending interrupts.
Returns
None.
Note
EpNum is not used in this function as the handler is attached specific to end point two. This parameter is useful when a single handler is used for processing all end point interrupts.

Referenced by main().

void GetMaxLUN ( XUsb InstancePtr)

This routine is called when a GETMAXLUN class command is received.

Parameters
InstancePtris a pointer to the XUsb instance of the controller.
Returns
None.
Note
None.

Referenced by Ep0IntrHandler().

void InitUsbInterface ( XUsb InstancePtr)

This is the USB initialization function.

This example initializes the device for Mass Storage Application. The following configuration is done.

  • EP0 : CONTROL end point, Bidirectional, Packet size 64 bytes.
  • EP1 : NON_ISOCHRONOUS, BULK_IN, packet size 512 bytes.
  • EP2 : NON_ISOCHRONOUS, BULK_OUT, packet size 512 bytes
Parameters
InstancePtris a pointer to the XUsb instance.
Returns
None.
Note
None.
void MassStorageReset ( XUsb InstancePtr)

This routine is called when a RESET class command is received.

Parameters
InstancePtris a pointer to the XUsb instance of the controller.
Returns
None.
Note
None.

Referenced by Ep0IntrHandler().

void ProcessRxCmd ( XUsb InstancePtr)

This function processes mass storage specific commands and sends the required response.

Parameters
InstancePtris a pointer to the XUsb instance.
Returns
None.
Note
None.

Referenced by DmaIntrHandler(), and main().

void Read10 ( XUsb InstancePtr,
PUSBCBW  pCmdBlock,
PUSBCSW  pStatusBlock 
)

This function implements the transmission of data from the device to the READ request from the USB Host.

Parameters
InstancePtris a pointer to the XUsb instance.
pCmdBlockis a pointer to the Mass Storage Command Block wrapper.
pStatusBlockis a pointer to the Mass Storage Status wrapper.
Returns
None.
Note
None.

Referenced by ProcessRxCmd().

void ReadTransfer ( XUsb InstancePtr)

This function implements the reception of data in the USB device for the READ request from the USB Host.

Parameters
InstancePtris a pointer to the XUsb instance.
Returns
None.
Note
None.

References XUsb_DeviceConfig::CurrentSpeed, XUsb::DeviceConfig, XUSB_EP_HIGH_SPEED, and XUsb_EpDataSend().

Referenced by DmaIntrHandler(), and Ep1IntrHandler().

void UsbIfIntrHandler ( void *  CallBackRef,
u32  IntrStatus 
)

This function is the interrupt handler for the USB mass storage device application.

Parameters
CallBackRefis the callback reference passed from the interrupt handler, which in our case is a pointer to the driver instance.
IntrStatusis a bit mask indicating pending interrupts.
Returns
None.
Note
None.

Referenced by main(), UsbKbdExample(), and UsbMouseExample().

void Write10 ( XUsb InstancePtr,
PUSBCBW  pCmdBlock,
PUSBCSW  pStatusBlock 
)

This function implements the reception of data in the USB device for the write request from the USB Host.

Parameters
InstancePtris a pointer to the XUsb instance.
pCmdBlockis a pointer to the Mass Storage Command Block wrapper.
pStatusBlockis a pointer to the Mass Storage Status wrapper.
Returns
None.
Note
None.

Referenced by ProcessRxCmd().

void WriteTransfer ( XUsb InstancePtr)

This function implements the reception of data in the USB device for the WRITE request from the USB Host.

Parameters
InstancePtris a pointer to the XUsb instance.
Returns
None.
Note
None.

References XUsb_DeviceConfig::CurrentSpeed, XUsb::DeviceConfig, XUSB_EP_HIGH_SPEED, XUsb_EpDataRecv(), and XUsb_EpDataSend().

Referenced by DmaIntrHandler(), and Ep2IntrHandler().