XilinxProcessorIPLib/drivers/axiethernet/examples/xaxiethernet_example_intr_fifo.c
int AxiEthernetFifoIntrExample(INTC *IntcInstancePtr,
			 XAxiEthernet *AxiEthernetInstancePtr,
			 XLlFifo *FifoInstancePtr,
			 u16 AxiEthernetDeviceId,
			 u16 FifoDeviceId, u16 AxiEthernetIntrId,
			 u16 FifoIntrId)
{
	int Status;
	XAxiEthernet_Config *MacCfgPtr;
	int LoopbackSpeed;


	/*************************************/
	/* Setup device for first-time usage */
	/*************************************/

	/*
	 *  Get the configuration of AxiEthernet hardware.
	 */
	MacCfgPtr = XAxiEthernet_LookupConfig(AxiEthernetDeviceId);

	/*
	 * Check whether AXIFIFO is present or not
	 */
	if(MacCfgPtr->AxiDevType != XPAR_AXI_FIFO) {
		AxiEthernetUtilErrorTrap
			("Device HW not configured for FIFO mode\r\n");
		return XST_FAILURE;
	}

	/*
	 * Initialize AXIFIFO hardware. AXIFIFO must be initialized before
	 * AxiEthernet. During AXIFIFO initialization, AXIFIFO hardware is
	 * reset, and since AXIFIFO reset line is connected to AxiEthernet,
	 * this would ensure a reset of AxiEthernet.
	 */
	XLlFifo_Initialize(FifoInstancePtr, MacCfgPtr->AxiDevBaseAddress);

	/*
	 * Initialize AxiEthernet hardware.
	 */
	Status = XAxiEthernet_CfgInitialize(AxiEthernetInstancePtr, MacCfgPtr,
					MacCfgPtr->BaseAddress);
	if (Status != XST_SUCCESS) {
		AxiEthernetUtilErrorTrap("Error in initialize");
		return XST_FAILURE;
	}

	/*
	 * Set the MAC  address
	 */
	Status = XAxiEthernet_SetMacAddress(AxiEthernetInstancePtr,
							(u8 *) AxiEthernetMAC);
	if (Status != XST_SUCCESS) {
		AxiEthernetUtilErrorTrap("Error setting MAC address");
		return XST_FAILURE;
	}

	/*
	 * Set PHY to loopback, speed depends on phy type.
	 * MII is 100 and all others are 1000.
	 */
	if (XAxiEthernet_GetPhysicalInterface(AxiEthernetInstancePtr) ==
							XAE_PHY_TYPE_MII) {
		LoopbackSpeed = AXIETHERNET_LOOPBACK_SPEED;
	} else {
		LoopbackSpeed = AXIETHERNET_LOOPBACK_SPEED_1G;
	}
	Status = AxiEthernetUtilEnterLoopback(AxiEthernetInstancePtr,
							LoopbackSpeed);
	if (Status != XST_SUCCESS) {
		AxiEthernetUtilErrorTrap("Error setting the PHY loopback");
		return XST_FAILURE;
	}

	/*
	 * Set PHY<-->MAC data clock
	 */
	Status = XAxiEthernet_SetOperatingSpeed(AxiEthernetInstancePtr,
					(u16)LoopbackSpeed);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/*
	 * Setting the operating speed of the MAC needs a delay.  There
	 * doesn't seem to be register to poll, so please consider this
	 * during your application design.
	 */
	AxiEthernetUtilPhyDelay(2);

	/* Clear any pending FIFO interrupts from any previous
	 * examples (e.g., polled)
	 */
	XLlFifo_IntClear(FifoInstancePtr, XLLF_INT_ALL_MASK);

	/*
	 * Connect to the interrupt controller and enable interrupts
	 */
	Status = AxiEthernetSetupIntrSystem(IntcInstancePtr,
				      AxiEthernetInstancePtr,
				      FifoInstancePtr, AxiEthernetIntrId,
				      FifoIntrId);

	/****************************/
	/* Run through the examples */
	/****************************/


	/*
	 * Run the AxiEthernet Single Frame Interrupt example
	 */
	Status = AxiEthernetSingleFrameIntrExample(AxiEthernetInstancePtr,
							FifoInstancePtr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/*
	 * Run the AxiEthernet Single Frame Non Continuous Interrupt example
	 */
	Status = AxiEthernetSingleFrameNonContIntrExample
				(AxiEthernetInstancePtr, FifoInstancePtr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	DeferRx = 1;
	Status = AxiEthernetMultipleFramesIntrExample(AxiEthernetInstancePtr,
							   FifoInstancePtr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	Status = AxiEthernetResetDevice(AxiEthernetInstancePtr,
							FifoInstancePtr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/*
	 * Disable the interrupts for the AxiEthernet device
	 */
	AxiEthernetDisableIntrSystem(IntcInstancePtr, AxiEthernetIntrId,
								FifoIntrId);


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


	return XST_SUCCESS;

}
/*****************************************************************************/
/**
*
* This function demonstrates the usage usage of the Axi Ethernet by sending
* and receiving frames in interrupt driven fifo mode.
*
*
* @param	IntcInstancePtr is a pointer to the instance of the Intc
*		component.
* @param	AxiEthernetInstancePtr is a pointer to the instance of the
*		Axi Ethernet component.
* @param	FifoInstancePtr is a pointer to the instance of the AXIFIFO
*		component.
* @param	AxiEthernetDeviceId is Device ID of the Axi Ethernet Device ,
*		typically XPAR_<AXIETHERNET_instance>_DEVICE_ID value from
*		xparameters.h.
* @param	FifoDeviceId is the Interrupt ID and is typically
*		XPAR_<INTC_instance>_<AXIETHERNET_instance>_VEC_ID
*		value from xparameters.h.
* @param	AxiEthernetIntrId is the Interrupt ID and is typically
*		XPAR_<INTC_instance>_<AXIETHERNET_instance>_VEC_ID
*		value from xparameters.h.
* @param	FifoIntrId is the interrupt id for fifo.
*
* @return
*		- XST_SUCCESS to indicate success.
*		- XST_FAILURE.to indicate failure.
*
* @note		AxiFifo hardware must be initialized before initializing
*		AxiEthernet. Since AxiFifo reset line is connected to the
*		AxiEthernet reset line, a reset of AxiFifo hardware during its
*		initialization would reset AxiEthernet.
*
******************************************************************************/
This function demonstrates the usage usage of the Axi Ethernet by sending
and receiving frames in interrupt driven fifo mode.
This function demonstrates the usage usage of the Axi Ethernet by sending and receiving frames in interrupt driven fifo mode .
int AxiEthernetFifoIntrExample(INTC *IntcInstancePtr,
			 XAxiEthernet *AxiEthernetInstancePtr,
			 XLlFifo *FifoInstancePtr,
			 u16 AxiEthernetDeviceId,
			 u16 FifoDeviceId, u16 AxiEthernetIntrId,
			 u16 FifoIntrId)
{
	int Status;
	XAxiEthernet_Config *MacCfgPtr;
	int LoopbackSpeed;
	MacCfgPtr = XAxiEthernet_LookupConfig(AxiEthernetDeviceId);
	if(MacCfgPtr->AxiDevType != XPAR_AXI_FIFO) {
		AxiEthernetUtilErrorTrap
			("Device HW not configured for FIFO mode\r\n");
		return XST_FAILURE;
	}
	XLlFifo_Initialize(FifoInstancePtr, MacCfgPtr->AxiDevBaseAddress);
	Status = XAxiEthernet_CfgInitialize(AxiEthernetInstancePtr, MacCfgPtr,
					MacCfgPtr->BaseAddress);
	if (Status != XST_SUCCESS) {
		AxiEthernetUtilErrorTrap("Error in initialize");
		return XST_FAILURE;
	}
	Status = XAxiEthernet_SetMacAddress(AxiEthernetInstancePtr,
							(u8 *) AxiEthernetMAC);
	if (Status != XST_SUCCESS) {
		AxiEthernetUtilErrorTrap("Error setting MAC address");
		return XST_FAILURE;
	}
	if (XAxiEthernet_GetPhysicalInterface(AxiEthernetInstancePtr) ==
							XAE_PHY_TYPE_MII) {
		LoopbackSpeed = AXIETHERNET_LOOPBACK_SPEED;
	} else {
		LoopbackSpeed = AXIETHERNET_LOOPBACK_SPEED_1G;
	}
	Status = AxiEthernetUtilEnterLoopback(AxiEthernetInstancePtr,
							LoopbackSpeed);
	if (Status != XST_SUCCESS) {
		AxiEthernetUtilErrorTrap("Error setting the PHY loopback");
		return XST_FAILURE;
	}
	Status = XAxiEthernet_SetOperatingSpeed(AxiEthernetInstancePtr,
					(u16)LoopbackSpeed);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	AxiEthernetUtilPhyDelay(2);
	XLlFifo_IntClear(FifoInstancePtr, XLLF_INT_ALL_MASK);
	Status = AxiEthernetSetupIntrSystem(IntcInstancePtr,
				      AxiEthernetInstancePtr,
				      FifoInstancePtr, AxiEthernetIntrId,
				      FifoIntrId);
	Status = AxiEthernetSingleFrameIntrExample(AxiEthernetInstancePtr,
							FifoInstancePtr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	Status = AxiEthernetSingleFrameNonContIntrExample
				(AxiEthernetInstancePtr, FifoInstancePtr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	DeferRx = 1;
	Status = AxiEthernetMultipleFramesIntrExample(AxiEthernetInstancePtr,
							   FifoInstancePtr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	Status = AxiEthernetResetDevice(AxiEthernetInstancePtr,
							FifoInstancePtr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	AxiEthernetDisableIntrSystem(IntcInstancePtr, AxiEthernetIntrId,
								FifoIntrId);
	XAxiEthernet_Stop(AxiEthernetInstancePtr);
	return XST_SUCCESS;
}
int AxiEthernetFifoIntrExample ( INTC * IntcInstancePtr , XAxiEthernet * AxiEthernetInstancePtr , XLlFifo * FifoInstancePtr , u16 AxiEthernetDeviceId , u16 FifoDeviceId , u16 AxiEthernetIntrId , u16 FifoIntrId ) { int Status ; XAxiEthernet_Config * MacCfgPtr ; int LoopbackSpeed ; MacCfgPtr = XAxiEthernet_LookupConfig ( AxiEthernetDeviceId ) ; if ( MacCfgPtr -> AxiDevType != XPAR_AXI_FIFO ) { AxiEthernetUtilErrorTrap ( " \r \n " ) ; return XST_FAILURE ; } XLlFifo_Initialize ( FifoInstancePtr , MacCfgPtr -> AxiDevBaseAddress ) ; Status = XAxiEthernet_CfgInitialize ( AxiEthernetInstancePtr , MacCfgPtr , MacCfgPtr -> BaseAddress ) ; if ( Status != XST_SUCCESS ) { AxiEthernetUtilErrorTrap ( " " ) ; return XST_FAILURE ; } Status = XAxiEthernet_SetMacAddress ( AxiEthernetInstancePtr , ( u8 * ) AxiEthernetMAC ) ; if ( Status != XST_SUCCESS ) { AxiEthernetUtilErrorTrap ( " " ) ; return XST_FAILURE ; } if ( XAxiEthernet_GetPhysicalInterface ( AxiEthernetInstancePtr ) == XAE_PHY_TYPE_MII ) { LoopbackSpeed = AXIETHERNET_LOOPBACK_SPEED ; } else { LoopbackSpeed = AXIETHERNET_LOOPBACK_SPEED_1G ; } Status = AxiEthernetUtilEnterLoopback ( AxiEthernetInstancePtr , LoopbackSpeed ) ; if ( Status != XST_SUCCESS ) { AxiEthernetUtilErrorTrap ( " " ) ; return XST_FAILURE ; } Status = XAxiEthernet_SetOperatingSpeed ( AxiEthernetInstancePtr , ( u16 ) LoopbackSpeed ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } AxiEthernetUtilPhyDelay ( 2 ) ; XLlFifo_IntClear ( FifoInstancePtr , XLLF_INT_ALL_MASK ) ; Status = AxiEthernetSetupIntrSystem ( IntcInstancePtr , AxiEthernetInstancePtr , FifoInstancePtr , AxiEthernetIntrId , FifoIntrId ) ; Status = AxiEthernetSingleFrameIntrExample ( AxiEthernetInstancePtr , FifoInstancePtr ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Status = AxiEthernetSingleFrameNonContIntrExample ( AxiEthernetInstancePtr , FifoInstancePtr ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } DeferRx = 1 ; Status = AxiEthernetMultipleFramesIntrExample ( AxiEthernetInstancePtr , FifoInstancePtr ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Status = AxiEthernetResetDevice ( AxiEthernetInstancePtr , FifoInstancePtr ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } AxiEthernetDisableIntrSystem ( IntcInstancePtr , AxiEthernetIntrId , FifoIntrId ) ; XAxiEthernet_Stop ( AxiEthernetInstancePtr ) ; return XST_SUCCESS ; }
This function demonstrates the usage usage of the Axi Ethernet by sending
and receiving frames in interrupt driven fifo mode.
This function demonstrates the usage usage of the Axi Ethernet by sending and receiving frames in interrupt driven fifo mode .
/*************************************/ /* Setup device for first-time usage */ /*************************************/ /*
	 *  Get the configuration of AxiEthernet hardware.
	 */ /*
	 * Check whether AXIFIFO is present or not
	 */ /*
	 * Initialize AXIFIFO hardware. AXIFIFO must be initialized before
	 * AxiEthernet. During AXIFIFO initialization, AXIFIFO hardware is
	 * reset, and since AXIFIFO reset line is connected to AxiEthernet,
	 * this would ensure a reset of AxiEthernet.
	 */ /*
	 * Initialize AxiEthernet hardware.
	 */ /*
	 * Set the MAC  address
	 */ /*
	 * Set PHY to loopback, speed depends on phy type.
	 * MII is 100 and all others are 1000.
	 */ /*
	 * Set PHY<-->MAC data clock
	 */ /*
	 * Setting the operating speed of the MAC needs a delay.  There
	 * doesn't seem to be register to poll, so please consider this
	 * during your application design.
	 */ /* Clear any pending FIFO interrupts from any previous
	 * examples (e.g., polled)
	 */ /*
	 * Connect to the interrupt controller and enable interrupts
	 */ /****************************/ /* Run through the examples */ /****************************/ /*
	 * Run the AxiEthernet Single Frame Interrupt example
	 */ /*
	 * Run the AxiEthernet Single Frame Non Continuous Interrupt example
	 */ /*
	 * Disable the interrupts for the AxiEthernet device
	 */ /*
	 * Stop the device
	 */