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

Overview

Demonstrates low-level UART NS550 driver usage.

This file contains a design example using the low-level driver functions and macros of the UART NS550 driver.

MODIFICATION HISTORY:

Ver   Who  Date     Changes


1.00b rpm 04/25/02 First release 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, minor modifications as per coding guidelines and macros have been renamed to remove _m from the name. 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 03/15/26 Updated BaseAddress type from u32 to UINTPTR to support 64-bit addressing. 3.15 vn 09/09/26 Align Doxygen comments with AMD standards

#include "xparameters.h"
#include "xstatus.h"
#include "xuartns550_l.h"
#include "xil_printf.h"

Macros

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 UART_BASEADDR   XPAR_XUARTNS550_0_BASEADDR
 UART base address. More...
 
#define UART_CLOCK_HZ   XPAR_XUARTNS550_0_CLOCK_FREQ
 UART clock frequency in Hz. More...
 
Buffer size and baud rate

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 so the entire buffer fits into the transmit and receive FIFOs of the UART.

#define TEST_BUFFER_SIZE   16
 Length of the send and receive buffers. More...
 
#define UART_BAUDRATE   19200
 Baud Rate. More...
 

Functions

int XUartNs550_LowLevelExample (UINTPTR UartBaseAddress)
 Performs a minimal low-level test on the UART device. More...
 
int main (void)
 Calls the UartNs550 low level example. More...
 

Variables

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.

Referenced by XUartNs550_LowLevelExample().

#define UART_BASEADDR   XPAR_XUARTNS550_0_BASEADDR

UART base address.

Referenced by main().

#define UART_BAUDRATE   19200

Baud Rate.

Referenced by XUartNs550_LowLevelExample().

#define UART_CLOCK_HZ   XPAR_XUARTNS550_0_CLOCK_FREQ

UART clock frequency in Hz.

Referenced by XUartNs550_LowLevelExample().

Function Documentation

int main ( void  )

Calls the UartNs550 low level example.

Returns
XST_SUCCESS if successful, XST_FAILURE if unsuccessful.

References UART_BASEADDR, and XUartNs550_LowLevelExample().

int XUartNs550_LowLevelExample ( UINTPTR  UartBaseAddress)

Performs a minimal low-level test on the UART device.

Tests the UART device using the low-level driver macros and functions.

This function sends data and expects to receive the data through the UART. A physical loopback must be done with the transmit and receive signals of the UART.

Parameters
[in]UartBaseAddressBase address of the UARTNS550 device and is the XPAR_<UARTNS550_instance>_BASEADDR value from xparameters.h.
Returns
XST_SUCCESS if successful, XST_FAILURE if unsuccessful.

References RecvBuffer, SendBuffer, TEST_BUFFER_SIZE, UART_BAUDRATE, UART_CLOCK_HZ, XUartNs550_RecvByte(), XUartNs550_SendByte(), XUartNs550_SetBaud(), XUartNs550_SetLineControlReg, XUartNs550_WriteReg, XUN_FCR_OFFSET, XUN_FIFO_ENABLE, and XUN_LCR_8_DATA_BITS.

Referenced by main().

Variable Documentation

u8 RecvBuffer[TEST_BUFFER_SIZE]

Buffer for Receiving Data.

u8 SendBuffer[TEST_BUFFER_SIZE]

Buffer for Transmitting Data.