XilinxProcessorIPLib/drivers/axiethernet/examples/xaxiethernet_example_polled.c
int AxiEthernetPollForRxStatus(void)
{
	int Status = XST_NO_DATA;
	int Attempts = 1000000;	/* Number of times to get a status before
				 * giving up
				 */

	/*
	 * There are two ways to poll for a received frame:
	 *
	 * XAxiEthernet_Recv() can be used and repeatedly called until it
	 * returns a length,  but this method does not provide any error
	 * detection.
	 *
	 * XAxiEthernet_FifoQueryRecvStatus() can be used and this function
	 * provides more information to handle error conditions.
	 */

	/*
	 * Wait for something to happen
	 */
	do {
		if (--Attempts <= 0)
			break;	/* Give up? */

		if (XLlFifo_Status(&FifoInstance) & XLLF_INT_RC_MASK) {
				Status = XST_SUCCESS;
		}
		if (XLlFifo_Status(&FifoInstance) & XLLF_INT_ERROR_MASK) {
			Status = XST_FIFO_ERROR;
		}
		if (XAxiEthernet_GetIntStatus(&AxiEthernetInstance) &
							XAE_INT_RXRJECT_MASK) {
			Status = XST_DATA_LOST;
		}
		/* When the RXFIFOOVR bit is set, the RXRJECT bit also
		 * gets set
		 */
		if (XAxiEthernet_GetIntStatus(&AxiEthernetInstance) &
						XAE_INT_RXFIFOOVR_MASK) {
			Status = XST_DATA_LOST;
		}
	} while (Status == XST_NO_DATA);

	switch (Status) {
	case XST_SUCCESS:	/* Frame has arrived */
	case XST_NO_DATA:	/* Timeout */
		break;

	case XST_DATA_LOST:
		AxiEthernetUtilErrorTrap("Frame was dropped");
		break;

	case XST_FIFO_ERROR:
		AxiEthernetUtilErrorTrap("FIFO error");
		AxiEthernetResetDevice();
		break;

	default:
		AxiEthernetUtilErrorTrap("Driver returned invalid transmit status");
		break;
	}

	return (Status);
}
/******************************************************************************/
/**
* This functions polls the Rx status and waits for an indication that a frame
* has arrived or a receive related error has occurred. If an error is reported,
* handle all the possible  error conditions.
*
* @param	None.
*
* @return
*		- XST_SUCCESS, a frame has been received
*		- XST_NO_DATA, Timeout. Rx failure.
*		- XST_FIFO_ERROR, Error in the FIFO.
*		- XST_DATA_LOST, a frame has been dropped
*
* @note     None.
*
******************************************************************************/
This functions polls the Rx status and waits for an indication that a frame
has arrived or a receive related error has occurred. If an error is reported,
handle all the possible  error conditions.
This functions polls the Rx status and waits for an indication that a frame has arrived or a receive related error has occurred . If an error is reported handle all the possible error conditions .
int AxiEthernetPollForRxStatus(void)
{
	int Status = XST_NO_DATA;
	int Attempts = 1000000;	
	do {
		if (--Attempts <= 0)
			break;	
		if (XLlFifo_Status(&FifoInstance) & XLLF_INT_RC_MASK) {
				Status = XST_SUCCESS;
		}
		if (XLlFifo_Status(&FifoInstance) & XLLF_INT_ERROR_MASK) {
			Status = XST_FIFO_ERROR;
		}
		if (XAxiEthernet_GetIntStatus(&AxiEthernetInstance) &
							XAE_INT_RXRJECT_MASK) {
			Status = XST_DATA_LOST;
		}
		if (XAxiEthernet_GetIntStatus(&AxiEthernetInstance) &
						XAE_INT_RXFIFOOVR_MASK) {
			Status = XST_DATA_LOST;
		}
	} while (Status == XST_NO_DATA);
	switch (Status) {
	case XST_SUCCESS:	
	case XST_NO_DATA:	
		break;
	case XST_DATA_LOST:
		AxiEthernetUtilErrorTrap("Frame was dropped");
		break;
	case XST_FIFO_ERROR:
		AxiEthernetUtilErrorTrap("FIFO error");
		AxiEthernetResetDevice();
		break;
	default:
		AxiEthernetUtilErrorTrap("Driver returned invalid transmit status");
		break;
	}
	return (Status);
}
int AxiEthernetPollForRxStatus ( void ) { int Status = XST_NO_DATA ; int Attempts = 1000000 ; do { if ( -- Attempts <= 0 ) break ; if ( XLlFifo_Status ( & FifoInstance ) & XLLF_INT_RC_MASK ) { Status = XST_SUCCESS ; } if ( XLlFifo_Status ( & FifoInstance ) & XLLF_INT_ERROR_MASK ) { Status = XST_FIFO_ERROR ; } if ( XAxiEthernet_GetIntStatus ( & AxiEthernetInstance ) & XAE_INT_RXRJECT_MASK ) { Status = XST_DATA_LOST ; } if ( XAxiEthernet_GetIntStatus ( & AxiEthernetInstance ) & XAE_INT_RXFIFOOVR_MASK ) { Status = XST_DATA_LOST ; } } while ( Status == XST_NO_DATA ) ; switch ( Status ) { case XST_SUCCESS : case XST_NO_DATA : break ; case XST_DATA_LOST : AxiEthernetUtilErrorTrap ( " " ) ; break ; case XST_FIFO_ERROR : AxiEthernetUtilErrorTrap ( " " ) ; AxiEthernetResetDevice ( ) ; break ; default : AxiEthernetUtilErrorTrap ( " " ) ; break ; } return ( Status ) ; }
This functions polls the Rx status and waits for an indication that a frame
has arrived or a receive related error has occurred.
This functions polls the Rx status and waits for an indication that a frame has arrived or a receive related error has occurred .
/* Number of times to get a status before
				 * giving up
				 */ /*
	 * There are two ways to poll for a received frame:
	 *
	 * XAxiEthernet_Recv() can be used and repeatedly called until it
	 * returns a length,  but this method does not provide any error
	 * detection.
	 *
	 * XAxiEthernet_FifoQueryRecvStatus() can be used and this function
	 * provides more information to handle error conditions.
	 */ /*
	 * Wait for something to happen
	 */ /* Give up? */ /* When the RXFIFOOVR bit is set, the RXRJECT bit also
		 * gets set
		 */ /* Frame has arrived */ /* Timeout */