XilinxProcessorIPLib/drivers/axiethernet/examples/xaxiethernet_example_intr_fifo.c
int AxiEthernetSingleFrameIntrExample(XAxiEthernet *AxiEthernetInstancePtr,
					XLlFifo *FifoInstancePtr)
{
	u32 FifoFreeBytes;
	u32 TxFrameLength;
	int PayloadSize = PAYLOAD_SIZE;

	/*
	 * Clear variables shared with callbacks
	 */
	FramesRx = 0;
	FramesRxInts = 0;
	FramesTxInts = 0;
	DeviceErrors = 0;
	FrameDataErrors = 0;

	/*
	 * Setup packet to be transmitted
	 */
	AxiEthernetUtilFrameHdrFormatMAC(&TxFrame, AxiEthernetMAC);
	AxiEthernetUtilFrameHdrFormatType(&TxFrame, PayloadSize);
	AxiEthernetUtilFrameSetPayloadData(&TxFrame, PayloadSize);

	/*
	 * Clear out receive packet memory area
	 */
	AxiEthernetUtilFrameMemClear(&RxFrame);

	/*
	 * Calculate frame length (not including FCS)
	 */
	TxFrameLength = XAE_HDR_SIZE + PayloadSize;

	/****************/
	/* Setup device */
	/****************/

	/*
	 * Start the device
	 */
	XAxiEthernet_Start(AxiEthernetInstancePtr);

	/*
	 * Enable the interrupts
	 */
	XLlFifo_IntEnable(FifoInstancePtr, XLLF_INT_ALL_MASK);
	XAxiEthernet_IntEnable(AxiEthernetInstancePtr,
			   XAE_INT_RXRJECT_MASK | XAE_INT_RXFIFOOVR_MASK);


		/*******************/
		/* Send the packet */
		/*******************/

	/*
	 * Find out how much room is in the FIFO
	 * Vacancy is a value in 32 bit words. Multiply by 4 to get bytes.
	 */
	FifoFreeBytes = XLlFifo_TxVacancy(FifoInstancePtr) * 4;
	if (FifoFreeBytes < TxFrameLength) {
		AxiEthernetUtilErrorTrap("Not enough room in FIFO for frame");
		return XST_FAILURE;
	}

	/*
	 * Write frame data to FIFO
	 */
	XLlFifo_Write(FifoInstancePtr, TxFrame, TxFrameLength);

	/*
	 * Initiate the transmit
	 */
	XLlFifo_TxSetLen(FifoInstancePtr, TxFrameLength);

	/*
	 * Wait for receive indication or error
	 */
	while ((FramesRx == 0) && (DeviceErrors == 0));

	/*
	 * Stop the device
	 */
	XAxiEthernet_Stop(AxiEthernetInstancePtr);

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function demonstrates the usage of the Axi Ethernet by sending and
* receiving a single frame in interrupt mode.
*
* @param	AxiEthernetInstancePtr is a pointer to the instance of the
*		AxiEthernet component.
* @param	FifoInstancePtr is a pointer to the instance of the Fifo
*		component.
*
* @return
*		- XST_SUCCESS to indicate success.
*		- XST_FAILURE.to indicate failure.
*
* @note		None.
*
******************************************************************************/
This function demonstrates the usage of the Axi Ethernet by sending and
receiving a single frame in interrupt mode.
This function demonstrates the usage of the Axi Ethernet by sending and receiving a single frame in interrupt mode .
int AxiEthernetSingleFrameIntrExample(XAxiEthernet *AxiEthernetInstancePtr,
					XLlFifo *FifoInstancePtr)
{
	u32 FifoFreeBytes;
	u32 TxFrameLength;
	int PayloadSize = PAYLOAD_SIZE;
	FramesRx = 0;
	FramesRxInts = 0;
	FramesTxInts = 0;
	DeviceErrors = 0;
	FrameDataErrors = 0;
	AxiEthernetUtilFrameHdrFormatMAC(&TxFrame, AxiEthernetMAC);
	AxiEthernetUtilFrameHdrFormatType(&TxFrame, PayloadSize);
	AxiEthernetUtilFrameSetPayloadData(&TxFrame, PayloadSize);
	AxiEthernetUtilFrameMemClear(&RxFrame);
	TxFrameLength = XAE_HDR_SIZE + PayloadSize;
	XAxiEthernet_Start(AxiEthernetInstancePtr);
	XLlFifo_IntEnable(FifoInstancePtr, XLLF_INT_ALL_MASK);
	XAxiEthernet_IntEnable(AxiEthernetInstancePtr,
			   XAE_INT_RXRJECT_MASK | XAE_INT_RXFIFOOVR_MASK);
	FifoFreeBytes = XLlFifo_TxVacancy(FifoInstancePtr) * 4;
	if (FifoFreeBytes < TxFrameLength) {
		AxiEthernetUtilErrorTrap("Not enough room in FIFO for frame");
		return XST_FAILURE;
	}
	XLlFifo_Write(FifoInstancePtr, TxFrame, TxFrameLength);
	XLlFifo_TxSetLen(FifoInstancePtr, TxFrameLength);
	while ((FramesRx == 0) && (DeviceErrors == 0));
	XAxiEthernet_Stop(AxiEthernetInstancePtr);
	return XST_SUCCESS;
}
int AxiEthernetSingleFrameIntrExample ( XAxiEthernet * AxiEthernetInstancePtr , XLlFifo * FifoInstancePtr ) { u32 FifoFreeBytes ; u32 TxFrameLength ; int PayloadSize = PAYLOAD_SIZE ; FramesRx = 0 ; FramesRxInts = 0 ; FramesTxInts = 0 ; DeviceErrors = 0 ; FrameDataErrors = 0 ; AxiEthernetUtilFrameHdrFormatMAC ( & TxFrame , AxiEthernetMAC ) ; AxiEthernetUtilFrameHdrFormatType ( & TxFrame , PayloadSize ) ; AxiEthernetUtilFrameSetPayloadData ( & TxFrame , PayloadSize ) ; AxiEthernetUtilFrameMemClear ( & RxFrame ) ; TxFrameLength = XAE_HDR_SIZE + PayloadSize ; XAxiEthernet_Start ( AxiEthernetInstancePtr ) ; XLlFifo_IntEnable ( FifoInstancePtr , XLLF_INT_ALL_MASK ) ; XAxiEthernet_IntEnable ( AxiEthernetInstancePtr , XAE_INT_RXRJECT_MASK | XAE_INT_RXFIFOOVR_MASK ) ; FifoFreeBytes = XLlFifo_TxVacancy ( FifoInstancePtr ) * 4 ; if ( FifoFreeBytes < TxFrameLength ) { AxiEthernetUtilErrorTrap ( " " ) ; return XST_FAILURE ; } XLlFifo_Write ( FifoInstancePtr , TxFrame , TxFrameLength ) ; XLlFifo_TxSetLen ( FifoInstancePtr , TxFrameLength ) ; while ( ( FramesRx == 0 ) && ( DeviceErrors == 0 ) ) ; XAxiEthernet_Stop ( AxiEthernetInstancePtr ) ; return XST_SUCCESS ; }
This function demonstrates the usage of the Axi Ethernet by sending and
receiving a single frame in interrupt mode.
This function demonstrates the usage of the Axi Ethernet by sending and receiving a single frame in interrupt mode .
/*
	 * Clear variables shared with callbacks
	 */ /*
	 * Setup packet to be transmitted
	 */ /*
	 * Clear out receive packet memory area
	 */ /*
	 * Calculate frame length (not including FCS)
	 */ /****************/ /* Setup device */ /****************/ /*
	 * Start the device
	 */ /*
	 * Enable the interrupts
	 */ /*******************/ /* Send the packet */ /*******************/ /*
	 * Find out how much room is in the FIFO
	 * Vacancy is a value in 32 bit words. Multiply by 4 to get bytes.
	 */ /*
	 * Write frame data to FIFO
	 */ /*
	 * Initiate the transmit
	 */ /*
	 * Wait for receive indication or error
	 */ /*
	 * Stop the device
	 */