XilinxProcessorIPLib/drivers/uartns550/examples/xuartns550_low_level_example.c
int XUartNs550_LowLevelExample(u32 UartBaseAddress)
{
	int Index;

	/*
	 * Initialize the send buffer bytes with a pattern to send and the
	 * the receive buffer bytes to zero
	 */
	for (Index = 0; Index < TEST_BUFFER_SIZE; Index++) {
		SendBuffer[Index] = Index + '0';
		RecvBuffer[Index] = 0;
	}

	/*
	 * Set the baud rate and number of stop bits
	 */
	XUartNs550_SetBaud(UartBaseAddress, UART_CLOCK_HZ, UART_BAUDRATE);
	XUartNs550_SetLineControlReg(UartBaseAddress, XUN_LCR_8_DATA_BITS);


	/*
	 * Enable the FIFOs for 16550 mode since the defaults is NO FIFOs
	 */
	XUartNs550_WriteReg(UartBaseAddress, XUN_FCR_OFFSET, XUN_FIFO_ENABLE);

	/*
	 * Send the entire transmit buffer
	 */
	for (Index = 0; Index < TEST_BUFFER_SIZE; Index++) {
		XUartNs550_SendByte(UartBaseAddress, SendBuffer[Index]);
	}

	/*
	 * Receive the entire buffer's worth. Note that the RecvByte function
	 * blocks waiting for a character
	 */
	for (Index = 0; Index < TEST_BUFFER_SIZE; Index++) {
		RecvBuffer[Index] = XUartNs550_RecvByte(UartBaseAddress);
	}

	/*
	 * Check the receive buffer data against the send buffer and verify the
	 * data was correctly received
	 */
	for (Index = 0; Index < TEST_BUFFER_SIZE; Index++) {

		if (SendBuffer[Index] != RecvBuffer[Index]) {
			return XST_FAILURE;
		}
	}

	return XST_SUCCESS;
}
/****************************************************************************/
/**
*
* This function does a minimal test on 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 by the user with the
* tranmit and receive signals of the UART.
*
* @param	UartBaseAddress is the base address of the UARTNS550 device
*		and is the XPAR_<UARTNS550_instance>_BASEADDR value from
*		xparameters.h.
*
* @return	XST_SUCCESS if successful, XST_FAILURE if unsuccessful.
*
* @note		None.
*
****************************************************************************/
This function does a minimal test on 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 by the user with the
tranmit and receive signals of the UART.
This function does a minimal test on 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 by the user with the tranmit and receive signals of the UART .
int XUartNs550_LowLevelExample(u32 UartBaseAddress)
{
	int Index;
	for (Index = 0; Index < TEST_BUFFER_SIZE; Index++) {
		SendBuffer[Index] = Index + '0';
		RecvBuffer[Index] = 0;
	}
	XUartNs550_SetBaud(UartBaseAddress, UART_CLOCK_HZ, UART_BAUDRATE);
	XUartNs550_SetLineControlReg(UartBaseAddress, XUN_LCR_8_DATA_BITS);
	XUartNs550_WriteReg(UartBaseAddress, XUN_FCR_OFFSET, XUN_FIFO_ENABLE);
	for (Index = 0; Index < TEST_BUFFER_SIZE; Index++) {
		XUartNs550_SendByte(UartBaseAddress, SendBuffer[Index]);
	}
	for (Index = 0; Index < TEST_BUFFER_SIZE; Index++) {
		RecvBuffer[Index] = XUartNs550_RecvByte(UartBaseAddress);
	}
	for (Index = 0; Index < TEST_BUFFER_SIZE; Index++) {
		if (SendBuffer[Index] != RecvBuffer[Index]) {
			return XST_FAILURE;
		}
	}
	return XST_SUCCESS;
}
int XUartNs550_LowLevelExample ( u32 UartBaseAddress ) { int Index ; for ( Index = 0 ; Index < TEST_BUFFER_SIZE ; Index ++ ) { SendBuffer [ Index ] = Index + ' ' ; RecvBuffer [ Index ] = 0 ; } XUartNs550_SetBaud ( UartBaseAddress , UART_CLOCK_HZ , UART_BAUDRATE ) ; XUartNs550_SetLineControlReg ( UartBaseAddress , XUN_LCR_8_DATA_BITS ) ; XUartNs550_WriteReg ( UartBaseAddress , XUN_FCR_OFFSET , XUN_FIFO_ENABLE ) ; for ( Index = 0 ; Index < TEST_BUFFER_SIZE ; Index ++ ) { XUartNs550_SendByte ( UartBaseAddress , SendBuffer [ Index ] ) ; } for ( Index = 0 ; Index < TEST_BUFFER_SIZE ; Index ++ ) { RecvBuffer [ Index ] = XUartNs550_RecvByte ( UartBaseAddress ) ; } for ( Index = 0 ; Index < TEST_BUFFER_SIZE ; Index ++ ) { if ( SendBuffer [ Index ] != RecvBuffer [ Index ] ) { return XST_FAILURE ; } } return XST_SUCCESS ; }
This function does a minimal test on the UART device using the low-level
driver macros and functions.
This function does a minimal test on the UART device using the low - level driver macros and functions .
/*
	 * Initialize the send buffer bytes with a pattern to send and the
	 * the receive buffer bytes to zero
	 */ /*
	 * Set the baud rate and number of stop bits
	 */ /*
	 * Enable the FIFOs for 16550 mode since the defaults is NO FIFOs
	 */ /*
	 * Send the entire transmit buffer
	 */ /*
	 * Receive the entire buffer's worth. Note that the RecvByte function
	 * blocks waiting for a character
	 */ /*
	 * Check the receive buffer data against the send buffer and verify the
	 * data was correctly received
	 */