| usb Vitis Drivers API Documentation

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

Functions
xusb_microphone.c File Reference

## Overview

This file contains usb Microphone application related functions.

This example only provides a reference as to how an isochronous transfer related application can be written. This example emulates a microphone and when connected to a Windows PC will be detected as a Microphone and if we open sound recorder and start recording data, this example sends data on isochronous endpoint and the PC can store this data. Noise will be heard when this data is played on the PC.

Note
  None.

    MODIFICATION HISTORY:

    Ver   Who  Date     Changes

    1.00a hvm  12/20/10 First release
    4.01a bss  11/01/11 Modified UsbIfIntrHandler function to unconditionally
                    reset when USB reset is asserted (CR 627574).
    4.02a bss  02/20/12 Modified main function to call Xil_DCacheFlushRange
                            when DMA is enabled.(CR 640005)
    5.6   pm   07/05/23 Removed powerpc support.
    5.6   pm   07/05/23 Added support for system device-tree flow.

## Functions
int | main ()
| This main function starts the USB Intrerrupt 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 microphone 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...

## Function Documentation

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

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

Parameters

  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.

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.

References XUsb_Config::BaseAddress, Chapter9(), XUsb::Config, XUsb::EndPointOffset, EP0ProcessInToken(), EP0ProcessOutToken(), XUSB_BUFFREADY_EP0_BUFF_MASK, XUSB_BUFFREADY_OFFSET, XUSB_EP_CFG_DATA_TOGGLE_MASK, XUsb_IntrEnable(), XUsb_ReadReg, 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, XUSB_STATUS_SUSPEND_MASK, and XUsb_WriteReg.

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

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

Parameters

  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.

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.

References XUsb_EpConfig::Buffer0Ready, XUsb_EpConfig::Buffer1Ready, XUsb::DeviceConfig, XUsb_DeviceConfig::Ep, XUSB_BUFFREADY_EP1_BUFF1_MASK, and XUSB_BUFFREADY_EP1_BUFF2_MASK.

void InitUsbInterface | ( | XUsb * | InstancePtr | ) |

This is the USB initialization function.

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.

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 main function starts the USB Intrerrupt example.

Parameters

  None. |

Returns
  - XST_SUCCESS if successful.
  - XST_FAILURE if test fails.

Note
  None.

References XUsb_Config::BaseAddress, XUsb::Config, XUsb_DeviceConfig::CurrentConfiguration, XUsb::DeviceConfig, XUsb_Config::DmaEnabled, Ep0IntrHandler(), Ep1IntrHandler(), InitUsbInterface(), UsbIfIntrHandler(), XUsb_CfgInitialize(), XUsb_EpDataSend(), 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_EP2_BUFF1_COMP_MASK, XUSB_STATUS_EP2_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.

void UsbIfIntrHandler | ( | void * | CallBackRef,
|  | u32 | IntrStatus
| ) |  |

This function is the interrupt handler for the USB microphone device application.

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

Parameters

  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.

Returns
  None.

Note
  None.

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.