uartps: xuartps_intr_example.c File Reference

| uartps Xilinx SDK Drivers API Documentation

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

Functions
xuartps_intr_example.c File Reference

## Overview

This file contains a design example using the XUartPs driver in interrupt mode.

It sends data and expects to receive the same data through the device using the local loopback mode.

Note
  The example contains an infinite loop such that if interrupts are not working it may hang.

MODIFICATION HISTORY:

    Ver   Who    Date     Changes

    1.00a  drg/jz 01/13/10 First Release
    1.00a  sdm    05/25/11 Modified the example for supporting Peripheral tests
                    in SDK
    1.03a  sg     07/16/12 Updated the example for CR 666306. Modified
                    the device ID to use the first Device Id
                    and increased the receive timeout to 8
                    Removed the printf at the start of the main
                    Put the device normal mode at the end of the example
    3.1     kvn             04/10/15 Added code to support Zynq Ultrascale+ MP.
    3.1   mus     01/14/16 Added support for intc interrupt controller
    3.8   adk     10/05/19 Don't update the DeviceId variable in peripheral test
                     app case.

## Functions
int | UartPsIntrExample (INTC *IntcInstPtr, XUartPs *UartInstPtr, u16 DeviceId, u16 UartIntrId)
| This function does a minimal test on the UartPS device and driver as a design example. More...
void | Handler (void *CallBackRef, u32 Event, unsigned int EventData)
| This function is the handler which performs processing to handle data events from the device. More...
int | main (void)
| Main function to call the Uart interrupt example. More...

## Function Documentation

void Handler | ( | void * | CallBackRef,
|  | u32 | Event,
|  | unsigned int | EventData
| ) |  |

This function is the handler which performs processing to handle data events from the device.

It is called from an interrupt context. so the amount of processing should be minimal.

This handler provides an example of how to handle data for the device and is application specific.

Parameters

  CallBackRef | contains a callback reference from the driver, in this case it is the instance pointer for the XUartPs driver.
  Event | contains the specific kind of event that has occurred.
  EventData | contains the number of bytes sent or received for sent and receive events.

Returns
  None.

Note
  None.

int main | ( | void |  | ) |

Main function to call the Uart interrupt example.

Parameters

  None |

Returns
  XST_SUCCESS if successful, XST_FAILURE if unsuccessful

Note
  None

References UartPsIntrExample().

int UartPsIntrExample | ( | INTC * | IntcInstPtr,
|  | XUartPs * | UartInstPtr,
|  | u16 | DeviceId,
|  | u16 | UartIntrId
| ) |  |

This function does a minimal test on the UartPS device and driver as a design example.

The purpose of this function is to illustrate how to use the XUartPs driver.

This function sends data and expects to receive the same data through the device using the local loopback mode.

This function uses interrupt mode of the device.

Parameters

  IntcInstPtr | is a pointer to the instance of the Scu Gic driver.
  UartInstPtr | is a pointer to the instance of the UART driver which is going to be connected to the interrupt controller.
  DeviceId | is the device Id of the UART device and is typically XPAR_<UARTPS_instance>_DEVICE_ID value from xparameters.h.
  UartIntrId | is the interrupt Id and is typically XPAR_<UARTPS_instance>_INTR value from xparameters.h.

Returns
  XST_SUCCESS if successful, otherwise XST_FAILURE.

Note

This function contains an infinite loop such that if interrupts are not working it may never return.

References XUartPs_Config::BaseAddress, XUartPs_CfgInitialize(), XUARTPS_IXR_FRAMING, XUARTPS_IXR_OVER, XUARTPS_IXR_PARITY, XUARTPS_IXR_RBRK, XUARTPS_IXR_RXFULL, XUARTPS_IXR_RXOVR, XUARTPS_IXR_TOUT, XUARTPS_IXR_TXEMPTY, XUartPs_LookupConfig(), XUARTPS_OPER_MODE_LOCAL_LOOP, XUARTPS_OPER_MODE_NORMAL, XUartPs_Recv(), XUartPs_SelfTest(), XUartPs_Send(), XUartPs_SetHandler(), XUartPs_SetInterruptMask(), XUartPs_SetOperMode(), and XUartPs_SetRecvTimeout().

Referenced by main().