XilinxProcessorIPLib/drivers/uartns550/src/xuartns550.c
unsigned int XUartNs550_ReceiveBuffer(XUartNs550 *InstancePtr)
{
	u32 LsrRegister;
	unsigned int ReceivedCount = 0;

	/*
	 * Loop until there is not more data buffered by the UART or the
	 * specified number of bytes is received
	 */
	while (ReceivedCount < InstancePtr->ReceiveBuffer.RemainingBytes) {

		/*
		 * Read the Line Status Register to determine if there is any
		 * data in the receiver/FIFO
		 */
		LsrRegister =
			XUartNs550_GetLineStatusReg(InstancePtr->BaseAddress);

		/*
		 * If there is a break condition then a zero data byte was put
		 * into the receiver, just read it and dump it and update the
		 * stats
		 */
		if (LsrRegister & XUN_LSR_BREAK_INT) {
			(void)XUartNs550_ReadReg(InstancePtr->BaseAddress,
							XUN_RBR_OFFSET);
			XUartNs550_UpdateStats(InstancePtr, (u8)LsrRegister);
		}

		/*
		 * If there is data ready to be removed, then put the next byte
		 * received into the specified buffer and update the stats to
		 * reflect any receive errors for the byte
		 */
		else if (LsrRegister & XUN_LSR_DATA_READY) {
			InstancePtr->ReceiveBuffer.NextBytePtr[ReceivedCount++] =
			XUartNs550_ReadReg(InstancePtr->BaseAddress,
						XUN_RBR_OFFSET);

			XUartNs550_UpdateStats(InstancePtr, (u8)LsrRegister);
		}

		/*
		 * There's no more data buffered, so exit such that this
		 * function does not block waiting for data
		 */
		else {
			break;
		}
	}

	/*
	 * Update the receive buffer to reflect the number of bytes that was
	 * received
	 */
	InstancePtr->ReceiveBuffer.NextBytePtr += ReceivedCount;
	InstancePtr->ReceiveBuffer.RemainingBytes -= ReceivedCount;

	/*
	 * Increment associated counters in the statistics
	 */
	InstancePtr->Stats.CharactersReceived += ReceivedCount;

	return ReceivedCount;
}
/****************************************************************************/
/**
*
* This function receives a buffer that has been previously specified by setting
* up the instance variables of the instance. This function is designed to be
* an internal function for the XUartNs550 component such that it may be called
* from a shell function that sets up the buffer or from an interrupt handler.
*
* This function will attempt to receive a specified number of bytes of data
* from the UART and store it into the specified buffer. This function is
* designed for either polled or interrupt driven modes. It is non-blocking
* such that it will return if there is no data has already received by the
* UART.
*
* In a polled mode, this function will only receive as much data as the UART
* can buffer, either in the receiver or in the FIFO if present and enabled.
* The application may need to call it repeatedly to receive a buffer. Polled
* mode is the default mode of operation for the driver.
*
* In interrupt mode, this function will start receiving and then the interrupt
* handler of the driver will continue until the buffer has been received. A
* callback function, as specified by the application, will be called to indicate
* the completion of receiving the buffer or when any receive errors or timeouts
* occur. Interrupt mode must be enabled using the SetOptions function.
*
* @param	InstancePtr is a pointer to the XUartNs550 instance.
*
* @return	The number of bytes received.
*
* @note		None.
*
*****************************************************************************/
This function receives a buffer that has been previously specified by setting
up the instance variables of the instance. This function is designed to be
an internal function for the XUartNs550 component such that it may be called
from a shell function that sets up the buffer or from an interrupt handler.

This function will attempt to receive a specified number of bytes of data
from the UART and store it into the specified buffer. This function is
designed for either polled or interrupt driven modes. It is non-blocking
such that it will return if there is no data has already received by the
UART.

In a polled mode, this function will only receive as much data as the UART
can buffer, either in the receiver or in the FIFO if present and enabled.
The application may need to call it repeatedly to receive a buffer. Polled
mode is the default mode of operation for the driver.

In interrupt mode, this function will start receiving and then the interrupt
handler of the driver will continue until the buffer has been received. A
callback function, as specified by the application, will be called to indicate
the completion of receiving the buffer or when any receive errors or timeouts
occur. Interrupt mode must be enabled using the SetOptions function.
This function receives a buffer that has been previously specified by setting up the instance variables of the instance . This function is designed to be an internal function for the XUartNs550 component such that it may be called from a shell function that sets up the buffer or from an interrupt handler . This function will attempt to receive a specified number of bytes of data from the UART and store it into the specified buffer . This function is designed for either polled or interrupt driven modes . It is non - blocking such that it will return if there is no data has already received by the UART . In a polled mode this function will only receive as much data as the UART can buffer either in the receiver or in the FIFO if present and enabled . The application may need to call it repeatedly to receive a buffer . Polled mode is the default mode of operation for the driver . In interrupt mode this function will start receiving and then the interrupt handler of the driver will continue until the buffer has been received . A callback function as specified by the application will be called to indicate the completion of receiving the buffer or when any receive errors or timeouts occur . Interrupt mode must be enabled using the SetOptions function .
unsigned int XUartNs550_ReceiveBuffer(XUartNs550 *InstancePtr)
{
	u32 LsrRegister;
	unsigned int ReceivedCount = 0;
	while (ReceivedCount < InstancePtr->ReceiveBuffer.RemainingBytes) {
		LsrRegister =
			XUartNs550_GetLineStatusReg(InstancePtr->BaseAddress);
		if (LsrRegister & XUN_LSR_BREAK_INT) {
			(void)XUartNs550_ReadReg(InstancePtr->BaseAddress,
							XUN_RBR_OFFSET);
			XUartNs550_UpdateStats(InstancePtr, (u8)LsrRegister);
		}
		else if (LsrRegister & XUN_LSR_DATA_READY) {
			InstancePtr->ReceiveBuffer.NextBytePtr[ReceivedCount++] =
			XUartNs550_ReadReg(InstancePtr->BaseAddress,
						XUN_RBR_OFFSET);
			XUartNs550_UpdateStats(InstancePtr, (u8)LsrRegister);
		}
		else {
			break;
		}
	}
	InstancePtr->ReceiveBuffer.NextBytePtr += ReceivedCount;
	InstancePtr->ReceiveBuffer.RemainingBytes -= ReceivedCount;
	InstancePtr->Stats.CharactersReceived += ReceivedCount;
	return ReceivedCount;
}
unsigned int XUartNs550_ReceiveBuffer ( XUartNs550 * InstancePtr ) { u32 LsrRegister ; unsigned int ReceivedCount = 0 ; while ( ReceivedCount < InstancePtr -> ReceiveBuffer . RemainingBytes ) { LsrRegister = XUartNs550_GetLineStatusReg ( InstancePtr -> BaseAddress ) ; if ( LsrRegister & XUN_LSR_BREAK_INT ) { ( void ) XUartNs550_ReadReg ( InstancePtr -> BaseAddress , XUN_RBR_OFFSET ) ; XUartNs550_UpdateStats ( InstancePtr , ( u8 ) LsrRegister ) ; } else if ( LsrRegister & XUN_LSR_DATA_READY ) { InstancePtr -> ReceiveBuffer . NextBytePtr [ ReceivedCount ++ ] = XUartNs550_ReadReg ( InstancePtr -> BaseAddress , XUN_RBR_OFFSET ) ; XUartNs550_UpdateStats ( InstancePtr , ( u8 ) LsrRegister ) ; } else { break ; } } InstancePtr -> ReceiveBuffer . NextBytePtr += ReceivedCount ; InstancePtr -> ReceiveBuffer . RemainingBytes -= ReceivedCount ; InstancePtr -> Stats . CharactersReceived += ReceivedCount ; return ReceivedCount ; }
This function receives a buffer that has been previously specified by setting
up the instance variables of the instance.
This function receives a buffer that has been previously specified by setting up the instance variables of the instance .
/*
	 * Loop until there is not more data buffered by the UART or the
	 * specified number of bytes is received
	 */ /*
		 * Read the Line Status Register to determine if there is any
		 * data in the receiver/FIFO
		 */ /*
		 * If there is a break condition then a zero data byte was put
		 * into the receiver, just read it and dump it and update the
		 * stats
		 */ /*
		 * If there is data ready to be removed, then put the next byte
		 * received into the specified buffer and update the stats to
		 * reflect any receive errors for the byte
		 */ /*
		 * There's no more data buffered, so exit such that this
		 * function does not block waiting for data
		 */ /*
	 * Update the receive buffer to reflect the number of bytes that was
	 * received
	 */ /*
	 * Increment associated counters in the statistics
	 */