XilinxProcessorIPLib/drivers/uartlite/src/xuartlite.c
unsigned int XUartLite_SendBuffer(XUartLite *InstancePtr)
{
	unsigned int SentCount = 0;
	u8 StatusRegister;
	u8 IntrEnableStatus;

	/*
	 * Read the status register to determine if the transmitter is full
	 */
	StatusRegister = XUartLite_GetSR(InstancePtr);

	/*
	 * Enter a critical region by disabling all the UART interrupts to allow
	 * this call to stop a previous operation that may be interrupt driven
	 */
	StatusRegister = XUartLite_GetSR(InstancePtr);
	XUartLite_WriteReg(InstancePtr->RegBaseAddress,
				XUL_CONTROL_REG_OFFSET, 0);

	/*
	 * Save the status register contents to restore the interrupt enable
	 * register to it's previous value when that the critical region is
	 * exited
	 */
	IntrEnableStatus = StatusRegister;

	/*
	 * Fill the FIFO from the the buffer that was specified
	 */

	while (((StatusRegister & XUL_SR_TX_FIFO_FULL) == 0) &&
		(SentCount < InstancePtr->SendBuffer.RemainingBytes)) {
		XUartLite_WriteReg(InstancePtr->RegBaseAddress,
					XUL_TX_FIFO_OFFSET,
					InstancePtr->SendBuffer.NextBytePtr[
					SentCount]);

		SentCount++;

		StatusRegister = XUartLite_GetSR(InstancePtr);
	}

	/*
	 * Update the buffer to reflect the bytes that were sent from it
	 */
	InstancePtr->SendBuffer.NextBytePtr += SentCount;
	InstancePtr->SendBuffer.RemainingBytes -= SentCount;

	/*
	 * Increment associated counters
	 */
	 InstancePtr->Stats.CharactersTransmitted += SentCount;

	/*
	 * Restore the interrupt enable register to it's previous value such
	 * that the critical region is exited
	 */
	IntrEnableStatus &= XUL_CR_ENABLE_INTR;
	XUartLite_WriteReg(InstancePtr->RegBaseAddress, XUL_CONTROL_REG_OFFSET,
				IntrEnableStatus);

	/*
	 * Return the number of bytes that were sent, although they really were
	 * only put into the FIFO, not completely sent yet
	 */
	return SentCount;
}
/****************************************************************************/
/**
*
* This function sends 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 XUartLite component such that it may be called
* from a shell function that sets up the buffer or from an interrupt handler.
*
* This function sends the specified buffer of data to the UART in either
* polled or interrupt driven modes. This function is non-blocking such that
* it will return before the data has been sent by the UART.
*
* In a polled mode, this function will only send as much data as the UART can
* buffer, either in the transmitter or in the FIFO if present and enabled.
* The application may need to call it repeatedly to send a buffer.
*
* In interrupt mode, this function will start sending the specified buffer and
* then the interrupt handler of the driver will continue until the buffer
* has been sent. A callback function, as specified by the application, will
* be called to indicate the completion of sending the buffer.
*
* @param	InstancePtr is a pointer to the XUartLite instance.
*
* @return	NumBytes is the number of bytes actually sent (put into the
*		UART transmitter and/or FIFO).
*
* @note		None.
*
*****************************************************************************/
This function sends 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 XUartLite component such that it may be called
from a shell function that sets up the buffer or from an interrupt handler.

This function sends the specified buffer of data to the UART in either
polled or interrupt driven modes. This function is non-blocking such that
it will return before the data has been sent by the UART.

In a polled mode, this function will only send as much data as the UART can
buffer, either in the transmitter or in the FIFO if present and enabled.
The application may need to call it repeatedly to send a buffer.

In interrupt mode, this function will start sending the specified buffer and
then the interrupt handler of the driver will continue until the buffer
has been sent. A callback function, as specified by the application, will
be called to indicate the completion of sending the buffer.
This function sends 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 XUartLite component such that it may be called from a shell function that sets up the buffer or from an interrupt handler . This function sends the specified buffer of data to the UART in either polled or interrupt driven modes . This function is non - blocking such that it will return before the data has been sent by the UART . In a polled mode this function will only send as much data as the UART can buffer either in the transmitter or in the FIFO if present and enabled . The application may need to call it repeatedly to send a buffer . In interrupt mode this function will start sending the specified buffer and then the interrupt handler of the driver will continue until the buffer has been sent . A callback function as specified by the application will be called to indicate the completion of sending the buffer .
unsigned int XUartLite_SendBuffer(XUartLite *InstancePtr)
{
	unsigned int SentCount = 0;
	u8 StatusRegister;
	u8 IntrEnableStatus;
	StatusRegister = XUartLite_GetSR(InstancePtr);
	StatusRegister = XUartLite_GetSR(InstancePtr);
	XUartLite_WriteReg(InstancePtr->RegBaseAddress,
				XUL_CONTROL_REG_OFFSET, 0);
	IntrEnableStatus = StatusRegister;
	while (((StatusRegister & XUL_SR_TX_FIFO_FULL) == 0) &&
		(SentCount < InstancePtr->SendBuffer.RemainingBytes)) {
		XUartLite_WriteReg(InstancePtr->RegBaseAddress,
					XUL_TX_FIFO_OFFSET,
					InstancePtr->SendBuffer.NextBytePtr[
					SentCount]);
		SentCount++;
		StatusRegister = XUartLite_GetSR(InstancePtr);
	}
	InstancePtr->SendBuffer.NextBytePtr += SentCount;
	InstancePtr->SendBuffer.RemainingBytes -= SentCount;
	 InstancePtr->Stats.CharactersTransmitted += SentCount;
	IntrEnableStatus &= XUL_CR_ENABLE_INTR;
	XUartLite_WriteReg(InstancePtr->RegBaseAddress, XUL_CONTROL_REG_OFFSET,
				IntrEnableStatus);
	return SentCount;
}
unsigned int XUartLite_SendBuffer ( XUartLite * InstancePtr ) { unsigned int SentCount = 0 ; u8 StatusRegister ; u8 IntrEnableStatus ; StatusRegister = XUartLite_GetSR ( InstancePtr ) ; StatusRegister = XUartLite_GetSR ( InstancePtr ) ; XUartLite_WriteReg ( InstancePtr -> RegBaseAddress , XUL_CONTROL_REG_OFFSET , 0 ) ; IntrEnableStatus = StatusRegister ; while ( ( ( StatusRegister & XUL_SR_TX_FIFO_FULL ) == 0 ) && ( SentCount < InstancePtr -> SendBuffer . RemainingBytes ) ) { XUartLite_WriteReg ( InstancePtr -> RegBaseAddress , XUL_TX_FIFO_OFFSET , InstancePtr -> SendBuffer . NextBytePtr [ SentCount ] ) ; SentCount ++ ; StatusRegister = XUartLite_GetSR ( InstancePtr ) ; } InstancePtr -> SendBuffer . NextBytePtr += SentCount ; InstancePtr -> SendBuffer . RemainingBytes -= SentCount ; InstancePtr -> Stats . CharactersTransmitted += SentCount ; IntrEnableStatus &= XUL_CR_ENABLE_INTR ; XUartLite_WriteReg ( InstancePtr -> RegBaseAddress , XUL_CONTROL_REG_OFFSET , IntrEnableStatus ) ; return SentCount ; }
This function sends a buffer that has been previously specified by setting
up the instance variables of the instance.
This function sends a buffer that has been previously specified by setting up the instance variables of the instance .
/*
	 * Read the status register to determine if the transmitter is full
	 */ /*
	 * Enter a critical region by disabling all the UART interrupts to allow
	 * this call to stop a previous operation that may be interrupt driven
	 */ /*
	 * Save the status register contents to restore the interrupt enable
	 * register to it's previous value when that the critical region is
	 * exited
	 */ /*
	 * Fill the FIFO from the the buffer that was specified
	 */ /*
	 * Update the buffer to reflect the bytes that were sent from it
	 */ /*
	 * Increment associated counters
	 */ /*
	 * Restore the interrupt enable register to it's previous value such
	 * that the critical region is exited
	 */ /*
	 * Return the number of bytes that were sent, although they really were
	 * only put into the FIFO, not completely sent yet
	 */