| usbps Vitis Drivers API Documentation

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

Functions
xusbps_ch9.c File Reference

## Overview

This file contains the implementation of the chapter 9 code for the example.

      MODIFICATION HISTORY:

      Ver   Who  Date     Changes

      1.00a jz  10/10/10 First release
      1.04a nm  02/05/13 Fixed CR# 696550.
                          Added template code for Vendor request.
      1.04a nm  03/04/13 Fixed CR# 704022. Implemented TEST_MODE Feature.
      1.06a kpc 11/11/13 Always use global memory for dma operations
      2.1   kpc 4/29/14  Align dma buffers to cache line boundary
      2.4    vak 4/01/19  Fixed IAR data_alignment warnings
      2.9   nd  3/18/24  Fixed failures reported by CV test suite.
    *

## Functions
void | XUsbPs_ClassReq (XUsbPs *InstancePtr, XUsbPs_SetupData *SetupData)
| This function is called by Chapter9 handler when class request is received from Host. More...
u32 | XUsbPs_Ch9SetupDevDescReply (u8 *BufPtr, u32 BufLen)
| This function returns the device descriptor for the device. More...
u32 | XUsbPs_Ch9SetupCfgDescReply (u8 *BufPtr, u32 BufLen)
| This function returns the configuration descriptor for the device. More...
u32 | XUsbPs_Ch9SetupStrDescReply (u8 *BufPtr, u32 BufLen, u8 Index)
| This function returns a string descriptor for the given index. More...
void | XUsbPs_SetConfiguration (XUsbPs *InstancePtr, int ConfigIdx)
| Changes State of Core to USB configured State. More...
void | XUsbPs_SetConfigurationApp (XUsbPs *InstancePtr, XUsbPs_SetupData *SetupData)
| This function is called by Chapter9 handler when SET_CONFIGURATION command is received from Host. More...
void | XUsbPs_SetInterfaceHandler (XUsbPs *InstancePtr, XUsbPs_SetupData *SetupData)
| This function is called by Chapter9 handler when SET_CONFIGURATION command or SET_INTERFACE command is received from Host. More...
int | XUsbPs_Ch9HandleSetupPacket (XUsbPs *InstancePtr, XUsbPs_SetupData *SetupData)
| This function handles a Setup Data packet from the host. More...
void | XUsbPs_SetConfigDone (void *InstancePtr, u8 Flag)
| Set the Config state. More...
u8 | XUsbPs_GetConfigDone (void *InstancePtr)
| Get the Config state. More...

## Function Documentation

int XUsbPs_Ch9HandleSetupPacket | ( | XUsbPs * | InstancePtr,
|  | XUsbPs_SetupData * | SetupData
| ) |  |

This function handles a Setup Data packet from the host.

Parameters

  InstancePtr | is a pointer to XUsbPs instance of the controller.
  SetupData | is the structure containing the setup request.

Returns
  - XST_SUCCESS if the function is successful.
  - XST_FAILURE if an Error occurred.

Note
  None.

References XUsbPs_SetupData::bmRequestType, XUsbPs_SetupData::bRequest, XUsbPs_ClassReq(), XUSBPS_EP_DIRECTION_IN, XUSBPS_EP_DIRECTION_OUT, XUsbPs_EpStall, and XUSBPS_REQ_TYPE_MASK.

u32 XUsbPs_Ch9SetupCfgDescReply | ( | u8 * | BufPtr,
|  | u32 | BufLen
| ) |  |

This function returns the configuration descriptor for the device.

Parameters

  InstancePtr | is a pointer to the Usb_DevData instance.
  BufPtr | is the pointer to the buffer that is to be filled with the descriptor.
  BufLen | is the size of the provided buffer.

Returns
  Length of the descriptor in the buffer on success. 0 on error.

Parameters

  BufPtr | is the pointer to the buffer that is to be filled with the descriptor.
  BufLen | is the size of the provided buffer.

Returns
  Length of the descriptor in the buffer on success. 0 on error.

u32 XUsbPs_Ch9SetupDevDescReply | ( | u8 * | BufPtr,
|  | u32 | BufLen
| ) |  |

This function returns the device descriptor for the device.

Parameters

  InstancePtr | is a pointer to the Usb_DevData instance.
  BufPtr | is pointer to the buffer that is to be filled with the descriptor.
  BufLen | is the size of the provided buffer.

Returns
  Length of the descriptor in the buffer on success. 0 on error.

Parameters

  BufPtr | is pointer to the buffer that is to be filled with the descriptor.
  BufLen | is the size of the provided buffer.

Returns
  Length of the descriptor in the buffer on success. 0 on error.

u32 XUsbPs_Ch9SetupStrDescReply | ( | u8 * | BufPtr,
|  | u32 | BufLen,
|  | u8 | Index
| ) |  |

This function returns a string descriptor for the given index.

Parameters

  InstancePtr | is a pointer to the Usb_DevData instance.
  BufPtr | is a pointer to the buffer that is to be filled with the descriptor.
  BufLen | is the size of the provided buffer.
  Index | is the index of the string for which the descriptor is requested.

Returns
  Length of the descriptor in the buffer on success. 0 on error.

Parameters

  BufPtr | is a pointer to the buffer that is to be filled with the descriptor.
  BufLen | is the size of the provided buffer.
  Index | is the index of the string for which the descriptor is requested.

Returns
  Length of the descriptor in the buffer on success. 0 on error.

void XUsbPs_ClassReq | ( | XUsbPs * | InstancePtr,
|  | XUsbPs_SetupData * | SetupData
| ) |  |

This function is called by Chapter9 handler when class request is received from Host.

Parameters

  InstancePtr | is pointer to Usb_DevData instance.
  SetupData | is the setup packet received from Host.

Note
  None.

This function is called by Chapter9 handler when class request is received from Host.

Parameters

  InstancePtr | is a pointer to XUsbPs instance of the controller.
  SetupData | is the setup data structure containing the setup request.

Returns
  None.

Note
  None.

Referenced by XUsbPs_Ch9HandleSetupPacket().

u8 XUsbPs_GetConfigDone | ( | void * | InstancePtr | ) |

Get the Config state.

Parameters

  InstancePtr | is a private member of Usb_DevData instance.

Returns
  Current configuration value

Note
  None.

void XUsbPs_SetConfigDone | ( | void * | InstancePtr,
|  | u8 | Flag
| ) |  |

Set the Config state.

Parameters

  InstancePtr | is a private member of Usb_DevData instance.
  Flag | is the config value.

Returns
  None.

Note
  None.

Referenced by XUsbPs_SetConfiguration(), and XUsbPs_SetConfigurationApp().

void XUsbPs_SetConfiguration | ( | XUsbPs * | InstancePtr,
|  | int | ConfigIdx
| ) |  |

Changes State of Core to USB configured State.

Parameters

  InstancePtr | is a pointer to the Usb_DevData instance.
  Ctrl | is a pointer to the Setup packet data.

Returns
  XST_SUCCESS else XST_FAILURE

Note
  None.

Changes State of Core to USB configured State.

Parameters

  InstancePtr | is a pointer to XUsbPs instance of the controller.
  ConfigIdx | is the Index of the desired configuration.

Returns
  None

void XUsbPs_SetConfigurationApp | ( | XUsbPs * | InstancePtr,
|  | XUsbPs_SetupData * | SetupData
| ) |  |

This function is called by Chapter9 handler when SET_CONFIGURATION command is received from Host.

Parameters

  InstancePtr | is pointer to Usb_DevData instance.
  SetupData | is the setup packet received from Host.

Returns
  - XST_SUCCESS if successful,
  - XST_FAILURE if unsuccessful.

Note
  Non control endpoints must be enabled after SET_CONFIGURATION command since hardware clears all previously enabled endpoints except control endpoints when this command is received.

Parameters

  InstancePtr | is pointer to XUsbPs instance of the controller.
  SetupData | is the setup packet received from Host.

Returns
  - XST_SUCCESS if successful,
  - XST_FAILURE if unsuccessful.

Note
  Non control endpoints must be enabled after SET_CONFIGURATION command since hardware clears all previously enabled endpoints except control endpoints when this command is received.

void XUsbPs_SetInterfaceHandler | ( | XUsbPs * | InstancePtr,
|  | XUsbPs_SetupData * | SetupData
| ) |  |

This function is called by Chapter9 handler when SET_CONFIGURATION command or SET_INTERFACE command is received from Host.

Parameters

  InstancePtr | is pointer to Usb_DevData instance.
  SetupData | is the setup packet received from Host.

Note
  Non control endpoints must be enabled after SET_INTERFACE command since hardware clears all previously enabled endpoints except control endpoints when this command is received.

Parameters

  InstancePtr | is pointer to XUsbPs instance of the controller.
  SetupData | is the setup packet received from Host.

Note