XilinxProcessorIPLib/drivers/uartlite/examples/xuartlite_intr_example.c
int UartLiteIntrExample(u16 DeviceId)
{
	int Status;
	int Index;

	/*
	 * Initialize the UartLite driver so that it's ready to use.
	 */
	Status = XUartLite_Initialize(&UartLite, DeviceId);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/*
	 * Perform a self-test to ensure that the hardware was built correctly.
	 */
	Status = XUartLite_SelfTest(&UartLite);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/*
	 * Connect the UartLite to the interrupt subsystem such that interrupts can
	 * occur. This function is application specific.
	 */
	Status = SetupInterruptSystem(&UartLite);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/*
	 * Setup the handlers for the UartLite that will be called from the
	 * interrupt context when data has been sent and received, specify a
	 * pointer to the UartLite driver instance as the callback reference so
	 * that the handlers are able to access the instance data.
	 */
	XUartLite_SetSendHandler(&UartLite, SendHandler, &UartLite);
	XUartLite_SetRecvHandler(&UartLite, RecvHandler, &UartLite);

	/*
	 * Enable the interrupt of the UartLite so that interrupts will occur.
	 */
	XUartLite_EnableInterrupt(&UartLite);

	/*
	 * Initialize the send buffer bytes with a pattern to send and the
	 * the receive buffer bytes to zero to allow the receive data to be
	 * verified.
	 */
	for (Index = 0; Index < TEST_BUFFER_SIZE; Index++) {
		SendBuffer[Index] = Index;
		ReceiveBuffer[Index] = 0;
	}

	/*
	 * Start receiving data before sending it since there is a loopback.
	 */
	XUartLite_Recv(&UartLite, ReceiveBuffer, TEST_BUFFER_SIZE);

	/*
	 * Send the buffer using the UartLite.
	 */
	XUartLite_Send(&UartLite, SendBuffer, TEST_BUFFER_SIZE);

	/*
	 * Wait for the entire buffer to be received, letting the interrupt
	 * processing work in the background, this function may get locked
	 * up in this loop if the interrupts are not working correctly.
	 */
	while ((TotalReceivedCount != TEST_BUFFER_SIZE) ||
		(TotalSentCount != TEST_BUFFER_SIZE)) {
	}

	/*
	 * Verify the entire receive buffer was successfully received.
	 */
	for (Index = 0; Index < TEST_BUFFER_SIZE; Index++) {
		if (ReceiveBuffer[Index] != SendBuffer[Index]) {
			return XST_FAILURE;
		}
	}

	return XST_SUCCESS;
}
/****************************************************************************/
/**
*
* This function does a minimal test on the UartLite device and driver as a
* design example. The purpose of this function is to illustrate
* how to use the XUartLite component.
*
* This function sends data and expects to receive the same data through the
* UartLite. The user must provide a physical loopback such that data which is
* transmitted will be received.
*
* This function uses interrupt driver mode of the UartLite device. The calls
* to the UartLite driver in the handlers should only use the non-blocking
* calls.
*
* @param	DeviceId is the Device ID of the UartLite Device and is the
*		XPAR_<uartlite_instance>_DEVICE_ID value from xparameters.h.
*
* @return	XST_SUCCESS if successful, otherwise XST_FAILURE.
*
* @note
*
* This function contains an infinite loop such that if interrupts are not
* working it may never return.
*
****************************************************************************/
This function does a minimal test on the UartLite device and driver as a
design example. The purpose of this function is to illustrate
how to use the XUartLite component.

This function sends data and expects to receive the same data through the
UartLite. The user must provide a physical loopback such that data which is
transmitted will be received.

This function uses interrupt driver mode of the UartLite device. The calls
to the UartLite driver in the handlers should only use the non-blocking
calls.
This function does a minimal test on the UartLite device and driver as a design example . The purpose of this function is to illustrate how to use the XUartLite component . This function sends data and expects to receive the same data through the UartLite . The user must provide a physical loopback such that data which is transmitted will be received . This function uses interrupt driver mode of the UartLite device . The calls to the UartLite driver in the handlers should only use the non - blocking calls .
int UartLiteIntrExample(u16 DeviceId)
{
	int Status;
	int Index;
	Status = XUartLite_Initialize(&UartLite, DeviceId);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	Status = XUartLite_SelfTest(&UartLite);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	Status = SetupInterruptSystem(&UartLite);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	XUartLite_SetSendHandler(&UartLite, SendHandler, &UartLite);
	XUartLite_SetRecvHandler(&UartLite, RecvHandler, &UartLite);
	XUartLite_EnableInterrupt(&UartLite);
	for (Index = 0; Index < TEST_BUFFER_SIZE; Index++) {
		SendBuffer[Index] = Index;
		ReceiveBuffer[Index] = 0;
	}
	XUartLite_Recv(&UartLite, ReceiveBuffer, TEST_BUFFER_SIZE);
	XUartLite_Send(&UartLite, SendBuffer, TEST_BUFFER_SIZE);
	while ((TotalReceivedCount != TEST_BUFFER_SIZE) ||
		(TotalSentCount != TEST_BUFFER_SIZE)) {
	}
	for (Index = 0; Index < TEST_BUFFER_SIZE; Index++) {
		if (ReceiveBuffer[Index] != SendBuffer[Index]) {
			return XST_FAILURE;
		}
	}
	return XST_SUCCESS;
}
int UartLiteIntrExample ( u16 DeviceId ) { int Status ; int Index ; Status = XUartLite_Initialize ( & UartLite , DeviceId ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Status = XUartLite_SelfTest ( & UartLite ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Status = SetupInterruptSystem ( & UartLite ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } XUartLite_SetSendHandler ( & UartLite , SendHandler , & UartLite ) ; XUartLite_SetRecvHandler ( & UartLite , RecvHandler , & UartLite ) ; XUartLite_EnableInterrupt ( & UartLite ) ; for ( Index = 0 ; Index < TEST_BUFFER_SIZE ; Index ++ ) { SendBuffer [ Index ] = Index ; ReceiveBuffer [ Index ] = 0 ; } XUartLite_Recv ( & UartLite , ReceiveBuffer , TEST_BUFFER_SIZE ) ; XUartLite_Send ( & UartLite , SendBuffer , TEST_BUFFER_SIZE ) ; while ( ( TotalReceivedCount != TEST_BUFFER_SIZE ) || ( TotalSentCount != TEST_BUFFER_SIZE ) ) { } for ( Index = 0 ; Index < TEST_BUFFER_SIZE ; Index ++ ) { if ( ReceiveBuffer [ Index ] != SendBuffer [ Index ] ) { return XST_FAILURE ; } } return XST_SUCCESS ; }
This function does a minimal test on the UartLite device and driver as a
design example.
This function does a minimal test on the UartLite device and driver as a design example .
/*
	 * Initialize the UartLite driver so that it's ready to use.
	 */ /*
	 * Perform a self-test to ensure that the hardware was built correctly.
	 */ /*
	 * Connect the UartLite to the interrupt subsystem such that interrupts can
	 * occur. This function is application specific.
	 */ /*
	 * Setup the handlers for the UartLite that will be called from the
	 * interrupt context when data has been sent and received, specify a
	 * pointer to the UartLite driver instance as the callback reference so
	 * that the handlers are able to access the instance data.
	 */ /*
	 * Enable the interrupt of the UartLite so that interrupts will occur.
	 */ /*
	 * Initialize the send buffer bytes with a pattern to send and the
	 * the receive buffer bytes to zero to allow the receive data to be
	 * verified.
	 */ /*
	 * Start receiving data before sending it since there is a loopback.
	 */ /*
	 * Send the buffer using the UartLite.
	 */ /*
	 * Wait for the entire buffer to be received, letting the interrupt
	 * processing work in the background, this function may get locked
	 * up in this loop if the interrupts are not working correctly.
	 */ /*
	 * Verify the entire receive buffer was successfully received.
	 */