| usb Vitis Drivers API Documentation

- Overview
- Data Structures
- APIs
- File List
- Examples

Functions
xusb_cp9.h File Reference

## Overview

This file contains the constants, typedefs, variables and functions prototypes related to the USB chapter 9 related code.

Note
  None.

    MODIFICATION HISTORY:

    Ver   Who  Date     Changes

    1.00a hvm  2/22/07 First release
    1.01a hvm  5/30/07 Moved the USB class specific command processing to
                  application files.
    4.02a bss  4/5/12  Made changes so that the flag LITTLE_ENDIAN gets
                  defined when compiled with ARM CodeSourcery toolchain.

## Functions
void | EP0ProcessOutToken (XUsb *InstancePtr)
| This routine is called when an OUT transaction for Endpoint Zero is received. More...
void | EP0ProcessInToken (XUsb *InstancePtr)
| This routine is called when IN transaction for Endpoint Zero is received. More...
int | Chapter9 (XUsb *InstancePtr)
| This routine is called when a chapter 9 command is received. More...
int | ExecuteCommand (XUsb *InstancePtr)
| This function executes the chapter 9 command processing. More...
void | GetInterface (XUsb *InstancePtr)
| This function responds to the GET_INTERFACE command. More...
void | SetInterface (XUsb *InstancePtr)
| This function responds to the SET_INTERFACE command. More...
void | SetupControlWriteStatusStage (XUsb *InstancePtr)
| This function sets the basic Control status words. More...
void | GetStatus (XUsb *InstancePtr)
| This routine is called when a GET_STATUS command is received. More...
void | GetDescriptor (XUsb *InstancePtr)
| This routine is called when a GET_DESCRIPTOR command is received. More...
void | SetDescriptor (XUsb *InstancePtr)
| This routine is called when a SET_DESCRIPTOR command is received. More...
void | GetConfiguration (XUsb *InstancePtr)
| This routine is called when a GET_CONFIGURATION command is received. More...
void | SetConfiguration (XUsb *InstancePtr)
| This routine is called when a SET_CONFIGURATION command is received. More...
void | SetClearFeature (XUsb *InstancePtr, int flag)
| This routine is called when a SET_FEATURE or a CLEAR_FEATURE command is received. More...
void | LoadEP0 (XUsb *InstancePtr)
| This routine copies the EP0 related data to the DPRAM. More...
void | InitUsbInterface (XUsb *InstancePtr)
| This is the USB initialization function. More...

## Function Documentation

int Chapter9 | ( | XUsb * | InstancePtr | ) |

This routine is called when a chapter 9 command is received.

Parameters

  InstancePtr | is a pointer to the XUsb instance of the controller.

Returns
  The setup request value to be processed by the upper layer.

Note
  None.

References XUsb_Config::BaseAddress, XUsb::Config, ExecuteCommand(), and XUSB_SETUP_PKT_ADDR_OFFSET.

Referenced by Ep0IntrHandler().

void EP0ProcessInToken | ( | XUsb * | InstancePtr | ) |

This routine is called when IN transaction for Endpoint Zero is received.

Parameters

  InstancePtr | is a pointer to the XUsb instance of the controller.

Returns
  None.

Note
  None.

References XUsb_Config::BaseAddress, XUsb_EpConfig::Buffer0Ready, XUsb::Config, XUsb::DeviceConfig, XUsb::EndPointOffset, XUsb_DeviceConfig::Ep, LoadEP0(), TEST_J, XUSB_BUFFREADY_OFFSET, XUSB_EP_BUF0COUNT_OFFSET, XUSB_EP_CFG_DATA_TOGGLE_MASK, XUsb_ReadReg, XUsb_SetDeviceAddress(), XUsb_SetTestMode(), and XUsb_WriteReg.

Referenced by Ep0IntrHandler().

void EP0ProcessOutToken | ( | XUsb * | InstancePtr | ) |

This routine is called when an OUT transaction for Endpoint Zero is received.

Parameters

  InstancePtr | is a pointer to the XUsb instance of the controller.

Returns
  None.

Note
  None.

References XUsb_Config::BaseAddress, XUsb_EpConfig::Buffer0Ready, XUsb::Config, XUsb::DeviceConfig, XUsb_DeviceConfig::Ep, ExecuteCommand(), XUSB_BUFFREADY_OFFSET, XUSB_EP_BUF0COUNT_OFFSET, XUsb_ReadReg, and XUsb_WriteReg.

Referenced by Ep0IntrHandler().

int ExecuteCommand | ( | XUsb * | InstancePtr | ) |

This function executes the chapter 9 command processing.

Parameters

  InstancePtr | is a pointer to the XUsb instance of the controller.

Returns
  The request value to be processed by the upper layer if the request is not handled. XST_SUCCESS if the request is successfully processed.

Note
  None.

References GetConfiguration(), GetDescriptor(), GetInterface(), GetStatus(), SetClearFeature(), SetConfiguration(), SetDescriptor(), SetInterface(), SetupControlWriteStatusStage(), and XUsb_EpStall().

Referenced by Chapter9(), and EP0ProcessOutToken().

void GetConfiguration | ( | XUsb * | InstancePtr | ) |

This routine is called when a GET_CONFIGURATION command is received.

Parameters

  InstancePtr | is a pointer to the XUsb instance of the controller.

Returns
  None.

Note
  None.

References XUsb_Config::BaseAddress, XUsb_EpConfig::Buffer0Ready, XUsb::Config, XUsb_DeviceConfig::CurrentConfiguration, XUsb::DeviceConfig, XUsb::EndPointOffset, XUsb_DeviceConfig::Ep, XUsb_EpConfig::RamBase, XUSB_BUFFREADY_OFFSET, XUSB_EP_BUF0COUNT_OFFSET, and XUsb_WriteReg.

Referenced by ExecuteCommand().

void GetDescriptor | ( | XUsb * | InstancePtr | ) |

This routine is called when a GET_DESCRIPTOR command is received.

Parameters

  InstancePtr | is a pointer to the XUsb instance of the controller.

Returns
  None.

Note
  None.

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

Referenced by ExecuteCommand().

void GetInterface | ( | XUsb * | InstancePtr | ) |

This function responds to the GET_INTERFACE command.

Parameters

  InstancePtr | is a pointer to the XUsb instance of the controller.

Returns
  None.

Note
  None.

References XUsb_Config::BaseAddress, XUsb_EpConfig::Buffer0Ready, XUsb::Config, XUsb::DeviceConfig, XUsb::EndPointOffset, XUsb_DeviceConfig::Ep, XUSB_BUFFREADY_OFFSET, XUSB_EP_BUF0COUNT_OFFSET, XUsb_EpStall(), and XUsb_WriteReg.

Referenced by ExecuteCommand().

void GetStatus | ( | XUsb * | InstancePtr | ) |

This routine is called when a GET_STATUS command is received.

Parameters

  InstancePtr | is a pointer to the XUsb instance of the controller.

Returns
  None.

Note
  None.

References XUsb_Config::BaseAddress, XUsb_EpConfig::Buffer0Ready, XUsb::Config, XUsb::DeviceConfig, XUsb::EndPointOffset, XUsb_DeviceConfig::Ep, XUsb_EpConfig::RamBase, XUSB_BUFFREADY_OFFSET, XUSB_EP_BUF0COUNT_OFFSET, XUSB_EP_CFG_STALL_MASK, XUSB_EP_CFG_STALL_SHIFT, XUsb_EpStall(), XUsb_ReadReg, and XUsb_WriteReg.

Referenced by ExecuteCommand().

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

  InstancePtr | is a pointer to the XUsb instance.

Returns
  None.

Note
  None.

This is the USB initialization function.

The following is the configuration.

- EP0 : CONTROL end point, Bidirectional, Packet size 64 bytes.
- EP1 : NON_ISOCHRONOUS, INTERRUPT_IN, packet size of 16 bytes.

Parameters

  InstancePtr | is a pointer to the XUsb instance.

Returns
  None.

Note
  None.

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

- EP0 : CONTROL end point, Bidirectional, Packet size 64 bytes.
- EP1 : ISOCHRONOUS, BULK_IN, packet size 1024 bytes.

Parameters

  InstancePtr | is a pointer to the XUsb instance.

Returns
  None.

Note
  None.

This example initializes the USB device for USB mouse example. The following configuration is done.

- EP0 : CONTROL end point, Bidirectional, Packet size 64 bytes.
- EP1 : NON_ISOCHRONOUS, INTERRUPT_IN, packet size of 16 bytes.

Parameters

  InstancePtr | is a pointer to the XUsb instance.

Returns
  None.

Note
  None.

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

void LoadEP0 | ( | XUsb * | InstancePtr | ) |

This routine copies the EP0 related data to the DPRAM.

Parameters

  InstancePtr | is a pointer to the XUsb instance of the controller.

Returns
  None.

Note
  None.

References XUsb_Config::BaseAddress, XUsb_EpConfig::Buffer0Ready, XUsb::Config, XUsb::DeviceConfig, XUsb_DeviceConfig::Ep, XUsb_EpConfig::RamBase, XUSB_BUFFREADY_OFFSET, XUSB_EP_BUF0COUNT_OFFSET, and XUsb_WriteReg.

Referenced by EP0ProcessInToken(), and GetDescriptor().

void SetClearFeature | ( | XUsb * | InstancePtr,
|  | int | flag
| ) |  |

This routine is called when a SET_FEATURE or a CLEAR_FEATURE command is received.

Parameters

  InstancePtr | is a pointer to the XUsb instance of the controller.
  flag | specifies whether it is a SET_FEATURE (TRUE)or a CLEAR_FEATURE (FALSE) command.

Returns
  None.

Note
  None.

References XUsb::Config, XUsb::DeviceConfig, XUsb_DeviceConfig::Ep, XUsb_EpConfig::OutIn, SetupControlWriteStatusStage(), XUSB_EP_CFG_DATA_TOGGLE_MASK, XUsb_EpStall(), XUsb_EpUnstall(), XUsb_ReadReg, and XUsb_WriteReg.

Referenced by ExecuteCommand().

void SetConfiguration | ( | XUsb * | InstancePtr | ) |

This routine is called when a SET_CONFIGURATION command is received.

Parameters

  InstancePtr | is a pointer to the XUsb instance of the controller.

Returns
  None.

Note
  None.

References XUsb_Config::BaseAddress, XUsb_EpConfig::Buffer0Ready, XUsb_EpConfig::Buffer1Ready, XUsb::Config, XUsb_DeviceConfig::CurrentConfiguration, XUsb::DeviceConfig, XUsb_DeviceConfig::Ep, InitUsbInterface(), XUsb_DeviceConfig::NumEndpoints, XUsb_EpConfig::OutIn, SetupControlWriteStatusStage(), XUSB_BUFFREADY_OFFSET, XUSB_EP_DIRECTION_OUT, XUsb_EpStall(), XUSB_STATUS_EP_BUFF2_SHIFT, and XUsb_WriteReg.

Referenced by ExecuteCommand().

void SetDescriptor | ( | XUsb * | InstancePtr | ) |

This routine is called when a SET_DESCRIPTOR command is received.

Parameters

  InstancePtr | is a pointer to the XUsb instance of the controller.

Returns
  None.

Note
  None.

References XUsb_EpStall().

Referenced by ExecuteCommand().

void SetInterface | ( | XUsb * | InstancePtr | ) |

This function responds to the SET_INTERFACE command.

Parameters

  InstancePtr | is a pointer to the XUsb instance of the controller.

Returns
  None.

Note
  None.

References SetupControlWriteStatusStage(), and XUsb_EpStall().

Referenced by ExecuteCommand().

void SetupControlWriteStatusStage | ( | XUsb * | InstancePtr | ) |

This function sets the basic Control status words.

Parameters

  InstancePtr | is a pointer to the XUsb instance of the controller.

Returns
  None.

Note
  None.

References XUsb_Config::BaseAddress, XUsb_EpConfig::Buffer0Count, XUsb::Config, XUsb::DeviceConfig, XUsb::EndPointOffset, XUsb_DeviceConfig::Ep, XUSB_BUFFREADY_OFFSET, XUSB_EP_BUF0COUNT_OFFSET, XUSB_EP_CFG_DATA_TOGGLE_MASK, XUsb_ReadReg, and XUsb_WriteReg.

Referenced by ExecuteCommand(), MassStorageReset(), SetClearFeature(), SetConfiguration(), and SetInterface().