XilinxProcessorIPLib/drivers/uartpsv/src/xuartpsv.c
u32 XUartPsv_ReceiveBuffer(XUartPsv *InstancePtr)
{
	u32 FlagRegister;
	u32 ReceivedCount = 0U;

	/*
	 * Read the Flag Register to determine if there is any data in
	 * the RX FIFO
	 */
	FlagRegister = XUartPsv_ReadReg(InstancePtr->Config.BaseAddress,
					XUARTPSV_UARTFR_OFFSET);

	/*
	 * Loop until there is no more data in RX FIFO or the specified
	 * number of bytes has been received
	 */
	while ((ReceivedCount <= InstancePtr->ReceiveBuffer.RemainingBytes) &&
		(((FlagRegister & XUARTPSV_UARTFR_RXFE) == (u32)0))) {

		InstancePtr->ReceiveBuffer.NextBytePtr[ReceivedCount] =
				(u8)XUartPsv_ReadReg(InstancePtr->Config.
					BaseAddress, XUARTPSV_UARTDR_OFFSET);

		ReceivedCount++;

		FlagRegister = XUartPsv_ReadReg(InstancePtr->Config.
						BaseAddress,
						XUARTPSV_UARTFR_OFFSET);
	}

	/*
	 * Update the receive buffer to reflect the number of bytes just
	 * received
	 */
	if (InstancePtr->ReceiveBuffer.NextBytePtr != NULL) {
		InstancePtr->ReceiveBuffer.NextBytePtr += ReceivedCount;
	}
	InstancePtr->ReceiveBuffer.RemainingBytes -= 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 an
* internal function, and it may be called from a shell function that sets up
* the buffer or from an interrupt handler.
*
* This function attempts to receive a specified number of bytes from the
* device and store it into the specified buffer. This function works for
* either polled or interrupt driven modes. It is non-blocking.
*
* In polled mode, this function only receives as much data as in the RX FIFO.
* The application may need to call it repeatedly to receive the entire
* buffer. Polled mode is the default mode for the driver.
*
* In interrupt mode, this function starts the receiving, if not the entire
* buffer has been received, the interrupt handler will continue until the
* entire buffer has been received. A callback function, as specified by the
* application, will be called to indicate the completion of the receiving or
* error conditions.
*
* @param	InstancePtr is a pointer to the XUartPsv 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 an
internal function, and it may be called from a shell function that sets up
the buffer or from an interrupt handler.

This function attempts to receive a specified number of bytes from the
device and store it into the specified buffer. This function works for
either polled or interrupt driven modes. It is non-blocking.

In polled mode, this function only receives as much data as in the RX FIFO.
The application may need to call it repeatedly to receive the entire
buffer. Polled mode is the default mode for the driver.

In interrupt mode, this function starts the receiving, if not the entire
buffer has been received, the interrupt handler will continue until the
entire buffer has been received. A callback function, as specified by the
application, will be called to indicate the completion of the receiving or
error conditions.
This function receives a buffer that has been previously specified by setting up the instance variables of the instance . This function is an internal function and it may be called from a shell function that sets up the buffer or from an interrupt handler . This function attempts to receive a specified number of bytes from the device and store it into the specified buffer . This function works for either polled or interrupt driven modes . It is non - blocking . In polled mode this function only receives as much data as in the RX FIFO . The application may need to call it repeatedly to receive the entire buffer . Polled mode is the default mode for the driver . In interrupt mode this function starts the receiving if not the entire buffer has been received the interrupt handler will continue until the entire buffer has been received . A callback function as specified by the application will be called to indicate the completion of the receiving or error conditions .
u32 XUartPsv_ReceiveBuffer(XUartPsv *InstancePtr)
{
	u32 FlagRegister;
	u32 ReceivedCount = 0U;
	FlagRegister = XUartPsv_ReadReg(InstancePtr->Config.BaseAddress,
					XUARTPSV_UARTFR_OFFSET);
	while ((ReceivedCount <= InstancePtr->ReceiveBuffer.RemainingBytes) &&
		(((FlagRegister & XUARTPSV_UARTFR_RXFE) == (u32)0))) {
		InstancePtr->ReceiveBuffer.NextBytePtr[ReceivedCount] =
				(u8)XUartPsv_ReadReg(InstancePtr->Config.
					BaseAddress, XUARTPSV_UARTDR_OFFSET);
		ReceivedCount++;
		FlagRegister = XUartPsv_ReadReg(InstancePtr->Config.
						BaseAddress,
						XUARTPSV_UARTFR_OFFSET);
	}
	if (InstancePtr->ReceiveBuffer.NextBytePtr != NULL) {
		InstancePtr->ReceiveBuffer.NextBytePtr += ReceivedCount;
	}
	InstancePtr->ReceiveBuffer.RemainingBytes -= ReceivedCount;
	return ReceivedCount;
}
u32 XUartPsv_ReceiveBuffer ( XUartPsv * InstancePtr ) { u32 FlagRegister ; u32 ReceivedCount = 0U ; FlagRegister = XUartPsv_ReadReg ( InstancePtr -> Config . BaseAddress , XUARTPSV_UARTFR_OFFSET ) ; while ( ( ReceivedCount <= InstancePtr -> ReceiveBuffer . RemainingBytes ) && ( ( ( FlagRegister & XUARTPSV_UARTFR_RXFE ) == ( u32 ) 0 ) ) ) { InstancePtr -> ReceiveBuffer . NextBytePtr [ ReceivedCount ] = ( u8 ) XUartPsv_ReadReg ( InstancePtr -> Config . BaseAddress , XUARTPSV_UARTDR_OFFSET ) ; ReceivedCount ++ ; FlagRegister = XUartPsv_ReadReg ( InstancePtr -> Config . BaseAddress , XUARTPSV_UARTFR_OFFSET ) ; } if ( InstancePtr -> ReceiveBuffer . NextBytePtr != NULL ) { InstancePtr -> ReceiveBuffer . NextBytePtr += ReceivedCount ; } InstancePtr -> ReceiveBuffer . RemainingBytes -= 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 .
/*
	 * Read the Flag Register to determine if there is any data in
	 * the RX FIFO
	 */ /*
	 * Loop until there is no more data in RX FIFO or the specified
	 * number of bytes has been received
	 */ /*
	 * Update the receive buffer to reflect the number of bytes just
	 * received
	 */