uartps
Xilinx SDK Drivers API Documentation
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
 

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

◆ Handler()

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.

References XUARTPS_EVENT_SENT_DATA.

◆ main()

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().

◆ 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
IntcInstPtris a pointer to the instance of the Scu Gic driver.
UartInstPtris a pointer to the instance of the UART driver which is going to be connected to the interrupt controller.
DeviceIdis the device Id of the UART device and is typically XPAR_<UARTPS_instance>_DEVICE_ID value from xparameters.h.
UartIntrIdis 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.

Referenced by main().