uartns550
Vitis Drivers API Documentation
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
xuartns550_polled_example.c File Reference

Overview

Demonstrates XUartNs550 driver usage in polled mode.

This file contains a design example using the Uart 16450/550 driver (XUartNs550) and hardware device using polled mode.

MODIFICATION HISTORY:

Ver   Who  Date     Changes


1.00a jhl 02/13/02 First release 1.00b ecm 01/25/05 Modified for TestApp integration, updated boilerplate. 1.00b sv 06/08/05 Minor changes to comply to Doxygen and coding guidelines 2.00a ktn 10/20/09 Updated to use HAL processor APIs and minor modifications as per coding guidelines. Updated this example to wait for valid data in receive fifo instead of Tx fifo empty to update receive buffer 3.4 ms 01/23/17 Added xil_printf statement in main function to ensure that "Successfully ran" and "Failed" strings are available in all examples. This is a fix for CR-965028. 3.9 gm 07/09/23 Added SDT support 3.14 vlt 12/18/25 Update Doxygen comments to include SDT flow details. 3.15 vn 09/09/26 Align Doxygen comments with AMD standards

#include "xparameters.h"
#include "xuartns550.h"
#include "xil_printf.h"

Macros

#define TEST_BUFFER_SIZE   16
 Length of the send and receive buffers. More...
 
Device parameters

The following constants map to the XPAR parameters created in the xparameters.h file.

They are defined here such that a user can easily change all the needed parameters in one place.

#define XUARTNS550_BASEADDRESS   XPAR_XUARTNS550_0_BASEADDR
 UART base address. More...
 

Functions

int UartNs550PolledExample (UINTPTR BaseAddress)
 Tests the UART 16450/550 device and driver in polled mode. More...
 
int main (void)
 Calls the UART polled mode example. More...
 

Variables

XUartNs550 UartNs550
 Instance of the UART Device. More...
 
Data buffers

The following buffers are used in this example to send and receive data with the UART.

u8 SendBuffer [TEST_BUFFER_SIZE]
 Buffer for Transmitting Data. More...
 
u8 RecvBuffer [TEST_BUFFER_SIZE]
 Buffer for Receiving Data. More...
 

Macro Definition Documentation

#define TEST_BUFFER_SIZE   16

Length of the send and receive buffers.

The following constant controls the length of the buffers to be sent and received with the UART, this constant must be 16 bytes or less since this is a single threaded non-interrupt driven example such that the entire buffer fits into the transmit and receive FIFOs of the UART.

Referenced by UartNs550PolledExample().

#define XUARTNS550_BASEADDRESS   XPAR_XUARTNS550_0_BASEADDR

UART base address.

Referenced by main().

Function Documentation

int main ( void  )

Calls the UART polled mode example.

This function is not included if the example is generated from the TestAppGen test tool.

Returns
XST_SUCCESS if successful, otherwise XST_FAILURE.

References UartNs550PolledExample(), and XUARTNS550_BASEADDRESS.

int UartNs550PolledExample ( UINTPTR  BaseAddress)

Tests the UART 16450/550 device and driver in polled mode.

This function does a minimal test on the UART 16450/550 device and driver as a design example. It illustrates how to use the XUartNs550 component.

This function sends data and expects to receive the data through the UART using the local loopback mode of the UART hardware.

This function polls the UART and does not require the use of interrupts.

Parameters
[in]BaseAddressBase address of the device.
Returns
XST_SUCCESS if successful, XST_FAILURE if unsuccessful.
Note
- This function polls the UART such that it may be not return if the hardware is not working correctly.
  • In XSCT/classic flow, DeviceId is used to look up the device configuration.

References RecvBuffer, SendBuffer, TEST_BUFFER_SIZE, XUartNs550_GetOptions(), XUartNs550_Initialize(), XUartNs550_Recv(), XUartNs550_SelfTest(), XUartNs550_Send(), XUartNs550_SetOptions(), XUN_OPTION_FIFOS_ENABLE, and XUN_OPTION_LOOPBACK.

Referenced by main().

Variable Documentation

u8 RecvBuffer[TEST_BUFFER_SIZE]

Buffer for Receiving Data.

u8 SendBuffer[TEST_BUFFER_SIZE]

Buffer for Transmitting Data.

XUartNs550 UartNs550

Instance of the UART Device.