uartps
Vitis Drivers API Documentation
 All Data Structures Files Functions Variables Typedefs Groups Pages
xuartps_intr_example.c File Reference

Overview

This example runs on zynqmp evaluation board (zcu102), it sends data and expects to receive the same data through the device using the local loopback mode in interrupt mode by using XUartPs driver.

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. 3.12 gm 09/26/22 Corrected SetRecvTimeout description details. 3.16 ht 10/28/24 Fix compilation warnings in SDT flow peripheral tests 3.18 vlt 12/18/25 Update Doxygen comments to include SDT flow details.

 
#include "xparameters.h"
#include "xplatform_info.h"
#include "xuartps.h"
#include "xil_exception.h"
#include "xil_printf.h"
#include "xinterrupt_wrap.h"

Functions

int UartPsIntrExample (XUartPs *UartInstPtr, UINTPTR BaseAddress)
 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
CallBackRefcontains a callback reference from the driver, in this case it is the instance pointer for the XUartPs driver.
Eventcontains the specific kind of event that has occurred.
EventDatacontains 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.

Returns
XST_SUCCESS if successful, XST_FAILURE if unsuccessful
Note
None

References UartPsIntrExample().

int UartPsIntrExample ( XUartPs UartInstPtr,
UINTPTR  BaseAddress 
)

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
UartInstPtris a pointer to the instance of the UART driver which is going to be connected to the interrupt controller.
BaseAddresscontains the base address of the device
Returns
XST_SUCCESS if successful, otherwise XST_FAILURE.
Note
- In XSCT/classic flow, DeviceId is used to look up the device configuration.
  • This function contains an infinite loop such that if interrupts are not working it may never return.

References XUartPs_Config::BaseAddress, XUartPs_Config::IntrId, XUartPs_Config::IntrParent, XUartPs_CfgInitialize(), XUartPs_InterruptHandler(), 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().