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

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

	/*
	 * Setup the transmit packet header
	 */
	AxiEthernetUtilFrameHdrFormatMAC(&TxFrame, AxiEthernetMAC);
	AxiEthernetUtilFrameHdrFormatType(&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 interrupts
	 */
	XLlFifo_IntEnable(FifoInstancePtr, XLLF_INT_ALL_MASK);

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

	/*
	 * Make sure there is enough room for a full sized frame
	 * Vacancy is a value in 32 bit words. Multiply by 4 to get bytes.
	 */
	FifoFreeBytes = XLlFifo_TxVacancy(FifoInstancePtr) * 4;

	if (FifoFreeBytes < (XAE_MTU + XAE_HDR_SIZE)) {
		AxiEthernetUtilErrorTrap("Not enough room in FIFO for frame");
		return XST_FAILURE;
	}

	/*
	 * Write the header data
	 */
	XLlFifo_Write(FifoInstancePtr, TxFrame, XAE_HDR_SIZE);

	/*
	 * Write payload one byte at a time. Set the payload like the
	 * AxiEthernetUtilFrameSetPayloadData() function would. This is done
	 * so that the received packet will pass validation in
	 * AxiEthernetRecvHandler().
	 *
	 * Keep PayloadSize less than 255 since
	 * AxiEthernetUtilFrameSetPayloadData() switches to a 16 bit
	 * counter at 256.
	 *
	 * This is not the fastest way to send a frame of data but it does
	 * illustrate the flexibility of the API.
	 */
	PayloadData = 0;
	while ((PayloadData < PayloadSize) && (DeviceErrors == 0)) {
		XLlFifo_Write(FifoInstancePtr, &PayloadData, 1);
		PayloadData++;
	}

	/*
	 * Did it all get written without error
	 */
	if (DeviceErrors != 0) {
		AxiEthernetUtilErrorTrap
			("Error writing payload to FIFO, reset recommended");
		return XST_FAILURE;
	}

	/*
	 * Now begin transmission
	 */
	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 example sends a packet from non-contiguous memory locations. The header
* is stored in one area. The payload data is calculated and written to the
* packet  FIFO one byte at a time.
*
* @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 example sends a packet from non-contiguous memory locations. The header
is stored in one area. The payload data is calculated and written to the
packet  FIFO one byte at a time.
This example sends a packet from non - contiguous memory locations . The header is stored in one area . The payload data is calculated and written to the packet FIFO one byte at a time .
int AxiEthernetSingleFrameNonContIntrExample(XAxiEthernet
						*AxiEthernetInstancePtr,
						XLlFifo *FifoInstancePtr)
{
	u32 FifoFreeBytes;
	int PayloadSize = 20;
	u8 PayloadData;
	u32 TxFrameLength;
	FramesRx = 0;
	FramesRxInts = 0;
	FramesTxInts = 0;
	DeviceErrors = 0;
	FrameDataErrors = 0;
	AxiEthernetUtilFrameHdrFormatMAC(&TxFrame, AxiEthernetMAC);
	AxiEthernetUtilFrameHdrFormatType(&TxFrame, PayloadSize);
	AxiEthernetUtilFrameMemClear(&RxFrame);
	TxFrameLength = XAE_HDR_SIZE + PayloadSize;
	XAxiEthernet_Start(AxiEthernetInstancePtr);
	XLlFifo_IntEnable(FifoInstancePtr, XLLF_INT_ALL_MASK);
	FifoFreeBytes = XLlFifo_TxVacancy(FifoInstancePtr) * 4;
	if (FifoFreeBytes < (XAE_MTU + XAE_HDR_SIZE)) {
		AxiEthernetUtilErrorTrap("Not enough room in FIFO for frame");
		return XST_FAILURE;
	}
	XLlFifo_Write(FifoInstancePtr, TxFrame, XAE_HDR_SIZE);
	PayloadData = 0;
	while ((PayloadData < PayloadSize) && (DeviceErrors == 0)) {
		XLlFifo_Write(FifoInstancePtr, &PayloadData, 1);
		PayloadData++;
	}
	if (DeviceErrors != 0) {
		AxiEthernetUtilErrorTrap
			("Error writing payload to FIFO, reset recommended");
		return XST_FAILURE;
	}
	XLlFifo_TxSetLen(FifoInstancePtr, TxFrameLength);
	while ((FramesRx == 0) && (DeviceErrors == 0));
	XAxiEthernet_Stop(AxiEthernetInstancePtr);
	return XST_SUCCESS;
}
int AxiEthernetSingleFrameNonContIntrExample ( XAxiEthernet * AxiEthernetInstancePtr , XLlFifo * FifoInstancePtr ) { u32 FifoFreeBytes ; int PayloadSize = 20 ; u8 PayloadData ; u32 TxFrameLength ; FramesRx = 0 ; FramesRxInts = 0 ; FramesTxInts = 0 ; DeviceErrors = 0 ; FrameDataErrors = 0 ; AxiEthernetUtilFrameHdrFormatMAC ( & TxFrame , AxiEthernetMAC ) ; AxiEthernetUtilFrameHdrFormatType ( & TxFrame , PayloadSize ) ; AxiEthernetUtilFrameMemClear ( & RxFrame ) ; TxFrameLength = XAE_HDR_SIZE + PayloadSize ; XAxiEthernet_Start ( AxiEthernetInstancePtr ) ; XLlFifo_IntEnable ( FifoInstancePtr , XLLF_INT_ALL_MASK ) ; FifoFreeBytes = XLlFifo_TxVacancy ( FifoInstancePtr ) * 4 ; if ( FifoFreeBytes < ( XAE_MTU + XAE_HDR_SIZE ) ) { AxiEthernetUtilErrorTrap ( " " ) ; return XST_FAILURE ; } XLlFifo_Write ( FifoInstancePtr , TxFrame , XAE_HDR_SIZE ) ; PayloadData = 0 ; while ( ( PayloadData < PayloadSize ) && ( DeviceErrors == 0 ) ) { XLlFifo_Write ( FifoInstancePtr , & PayloadData , 1 ) ; PayloadData ++ ; } if ( DeviceErrors != 0 ) { AxiEthernetUtilErrorTrap ( " " ) ; return XST_FAILURE ; } XLlFifo_TxSetLen ( FifoInstancePtr , TxFrameLength ) ; while ( ( FramesRx == 0 ) && ( DeviceErrors == 0 ) ) ; XAxiEthernet_Stop ( AxiEthernetInstancePtr ) ; return XST_SUCCESS ; }
This example sends a packet from non-contiguous memory locations.
This example sends a packet from non - contiguous memory locations .
/*
	 * Clear variables shared with callbacks
	 */ /*
	 * Setup the transmit packet header
	 */ /*
	 * Clear out receive packet memory area
	 */ /*
	 * Calculate frame length (not including FCS)
	 */ /****************/ /* Setup device */ /****************/ /*
	 * Start the device
	 */ /*
	 * Enable interrupts
	 */ /*******************/ /* Send the packet */ /*******************/ /*
	 * Make sure there is enough room for a full sized frame
	 * Vacancy is a value in 32 bit words. Multiply by 4 to get bytes.
	 */ /*
	 * Write the header data
	 */ /*
	 * Write payload one byte at a time. Set the payload like the
	 * AxiEthernetUtilFrameSetPayloadData() function would. This is done
	 * so that the received packet will pass validation in
	 * AxiEthernetRecvHandler().
	 *
	 * Keep PayloadSize less than 255 since
	 * AxiEthernetUtilFrameSetPayloadData() switches to a 16 bit
	 * counter at 256.
	 *
	 * This is not the fastest way to send a frame of data but it does
	 * illustrate the flexibility of the API.
	 */ /*
	 * Did it all get written without error
	 */ /*
	 * Now begin transmission
	 */ /*
	 * Wait for receive indication or error
	 */ /*
	 * Stop the device
	 */