XilinxProcessorIPLib/drivers/uartns550/src/xuartns550.c
unsigned int XUartNs550_Recv(XUartNs550 *InstancePtr, u8 *BufferPtr,
				unsigned int NumBytes)
{
	unsigned int ReceivedCount;
	u32 IerRegister;

	/*
	 * Assert validates the input arguments
	 */
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(BufferPtr != NULL);
	Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
	Xil_AssertNonvoid(((signed)NumBytes) >= 0);

	/*
	 * Enter a critical region by disabling all the UART interrupts to allow
	 * this call to stop a previous operation that may be interrupt driven
	 */
	IerRegister = XUartNs550_ReadReg(InstancePtr->BaseAddress,
						XUN_IER_OFFSET);
	XUartNs550_WriteReg(InstancePtr->BaseAddress, XUN_IER_OFFSET, 0);

	/*
	 * Setup the specified buffer to be received by setting the instance
	 * variables so it can be received with polled or interrupt mode
	 */
	InstancePtr->ReceiveBuffer.RequestedBytes = NumBytes;
	InstancePtr->ReceiveBuffer.RemainingBytes = NumBytes;
	InstancePtr->ReceiveBuffer.NextBytePtr = BufferPtr;

	/*
	 * Receive the data from the UART and return the number of bytes
	 * received
	 */
	ReceivedCount = XUartNs550_ReceiveBuffer(InstancePtr);

	/*
	 * Restore the interrupt enable register to it's previous value such
	 * that the critical region is exited
	 */
	XUartNs550_WriteReg(InstancePtr->BaseAddress, XUN_IER_OFFSET,
				IerRegister);

	return ReceivedCount;
}
/****************************************************************************/
/**
*
* 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 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 receiving data 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.
* @param	BufferPtr is pointer to buffer for data to be received into
* @param	NumBytes is the number of bytes to be received. A value of zero
*		will stop a previous receive operation that is in progress in
*		interrupt mode.
*
* @return	The number of bytes received.
*
* @note
*
* The number of bytes is not asserted so that this function may be called with
* a value of zero to stop an operation that is already in progress.
*
*****************************************************************************/
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 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 receiving data 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 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 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 receiving data 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_Recv(XUartNs550 *InstancePtr, u8 *BufferPtr,
				unsigned int NumBytes)
{
	unsigned int ReceivedCount;
	u32 IerRegister;
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(BufferPtr != NULL);
	Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
	Xil_AssertNonvoid(((signed)NumBytes) >= 0);
	IerRegister = XUartNs550_ReadReg(InstancePtr->BaseAddress,
						XUN_IER_OFFSET);
	XUartNs550_WriteReg(InstancePtr->BaseAddress, XUN_IER_OFFSET, 0);
	InstancePtr->ReceiveBuffer.RequestedBytes = NumBytes;
	InstancePtr->ReceiveBuffer.RemainingBytes = NumBytes;
	InstancePtr->ReceiveBuffer.NextBytePtr = BufferPtr;
	ReceivedCount = XUartNs550_ReceiveBuffer(InstancePtr);
	XUartNs550_WriteReg(InstancePtr->BaseAddress, XUN_IER_OFFSET,
				IerRegister);
	return ReceivedCount;
}
unsigned int XUartNs550_Recv ( XUartNs550 * InstancePtr , u8 * BufferPtr , unsigned int NumBytes ) { unsigned int ReceivedCount ; u32 IerRegister ; Xil_AssertNonvoid ( InstancePtr != NULL ) ; Xil_AssertNonvoid ( BufferPtr != NULL ) ; Xil_AssertNonvoid ( InstancePtr -> IsReady == XIL_COMPONENT_IS_READY ) ; Xil_AssertNonvoid ( ( ( signed ) NumBytes ) >= 0 ) ; IerRegister = XUartNs550_ReadReg ( InstancePtr -> BaseAddress , XUN_IER_OFFSET ) ; XUartNs550_WriteReg ( InstancePtr -> BaseAddress , XUN_IER_OFFSET , 0 ) ; InstancePtr -> ReceiveBuffer . RequestedBytes = NumBytes ; InstancePtr -> ReceiveBuffer . RemainingBytes = NumBytes ; InstancePtr -> ReceiveBuffer . NextBytePtr = BufferPtr ; ReceivedCount = XUartNs550_ReceiveBuffer ( InstancePtr ) ; XUartNs550_WriteReg ( InstancePtr -> BaseAddress , XUN_IER_OFFSET , IerRegister ) ; return ReceivedCount ; }
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 will attempt to receive a specified number of bytes of data from the UART and store it into the specified buffer .
/*
	 * Assert validates the input arguments
	 */ /*
	 * Enter a critical region by disabling all the UART interrupts to allow
	 * this call to stop a previous operation that may be interrupt driven
	 */ /*
	 * Setup the specified buffer to be received by setting the instance
	 * variables so it can be received with polled or interrupt mode
	 */ /*
	 * Receive the data from the UART and return the number of bytes
	 * received
	 */ /*
	 * Restore the interrupt enable register to it's previous value such
	 * that the critical region is exited
	 */