XilinxProcessorIPLib/drivers/axiethernet/examples/xaxiethernet_example_polled.c
int AxiEthernetPolledExample(u16 AxiEthernetDeviceId, u16 FifoDeviceId)
{
	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(&FifoInstance, MacCfgPtr->AxiDevBaseAddress);

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

	/*
	 * Set the MAC  address
	 */
	Status = XAxiEthernet_SetMacAddress(&AxiEthernetInstance,
							(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(&AxiEthernetInstance) ==
							XAE_PHY_TYPE_MII) {
		LoopbackSpeed = AXIETHERNET_LOOPBACK_SPEED;
	} else {
		LoopbackSpeed = AXIETHERNET_LOOPBACK_SPEED_1G;
	}
	Status = AxiEthernetUtilEnterLoopback(&AxiEthernetInstance,
								LoopbackSpeed);
	if (Status != XST_SUCCESS) {
		AxiEthernetUtilErrorTrap("Error setting the PHY loopback");
		return XST_FAILURE;
	}

	/*
	 * Set PHY<-->MAC data clock
	 */
	Status =  XAxiEthernet_SetOperatingSpeed(&AxiEthernetInstance,
							(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);

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

	/*
	 * Run the Single Frame polled example
	 */
	Status = AxiEthernetSingleFramePolledExample();
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/*
	 * Run the Multiple Frames polled example
	 */
	Status = AxiEthernetMultipleFramesPolledExample();
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	return XST_SUCCESS;


}
/*****************************************************************************/
/**
*
* This function demonstrates the usage of the Axi Ethernet by sending and
* receiving frames in polled mode.
*
*
* @param	AxiEthernetDeviceId is device ID of the AxiEthernet Device ,
*		typically XPAR_<AXIETHERNET_instance>_DEVICE_ID value from
*		xparameters.h
* @param	FifoDeviceId is device ID of the Fifo device taken from
*		xparameters.h
*
* @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 of the Axi Ethernet by sending and
receiving frames in polled mode.
This function demonstrates the usage of the Axi Ethernet by sending and receiving frames in polled mode .
int AxiEthernetPolledExample(u16 AxiEthernetDeviceId, u16 FifoDeviceId)
{
	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(&FifoInstance, MacCfgPtr->AxiDevBaseAddress);
	Status = XAxiEthernet_CfgInitialize(&AxiEthernetInstance, MacCfgPtr,
					MacCfgPtr->BaseAddress);
	if (Status != XST_SUCCESS) {
		AxiEthernetUtilErrorTrap("Error in initialize");
		return XST_FAILURE;
	}
	Status = XAxiEthernet_SetMacAddress(&AxiEthernetInstance,
							(u8 *) AxiEthernetMAC);
	if (Status != XST_SUCCESS) {
		AxiEthernetUtilErrorTrap("Error setting MAC address");
		return XST_FAILURE;
	}
	if (XAxiEthernet_GetPhysicalInterface(&AxiEthernetInstance) ==
							XAE_PHY_TYPE_MII) {
		LoopbackSpeed = AXIETHERNET_LOOPBACK_SPEED;
	} else {
		LoopbackSpeed = AXIETHERNET_LOOPBACK_SPEED_1G;
	}
	Status = AxiEthernetUtilEnterLoopback(&AxiEthernetInstance,
								LoopbackSpeed);
	if (Status != XST_SUCCESS) {
		AxiEthernetUtilErrorTrap("Error setting the PHY loopback");
		return XST_FAILURE;
	}
	Status =  XAxiEthernet_SetOperatingSpeed(&AxiEthernetInstance,
							(u16)LoopbackSpeed);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	AxiEthernetUtilPhyDelay(2);
	Status = AxiEthernetSingleFramePolledExample();
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	Status = AxiEthernetMultipleFramesPolledExample();
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	return XST_SUCCESS;
}
int AxiEthernetPolledExample ( u16 AxiEthernetDeviceId , u16 FifoDeviceId ) { 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 ( & FifoInstance , MacCfgPtr -> AxiDevBaseAddress ) ; Status = XAxiEthernet_CfgInitialize ( & AxiEthernetInstance , MacCfgPtr , MacCfgPtr -> BaseAddress ) ; if ( Status != XST_SUCCESS ) { AxiEthernetUtilErrorTrap ( " " ) ; return XST_FAILURE ; } Status = XAxiEthernet_SetMacAddress ( & AxiEthernetInstance , ( u8 * ) AxiEthernetMAC ) ; if ( Status != XST_SUCCESS ) { AxiEthernetUtilErrorTrap ( " " ) ; return XST_FAILURE ; } if ( XAxiEthernet_GetPhysicalInterface ( & AxiEthernetInstance ) == XAE_PHY_TYPE_MII ) { LoopbackSpeed = AXIETHERNET_LOOPBACK_SPEED ; } else { LoopbackSpeed = AXIETHERNET_LOOPBACK_SPEED_1G ; } Status = AxiEthernetUtilEnterLoopback ( & AxiEthernetInstance , LoopbackSpeed ) ; if ( Status != XST_SUCCESS ) { AxiEthernetUtilErrorTrap ( " " ) ; return XST_FAILURE ; } Status = XAxiEthernet_SetOperatingSpeed ( & AxiEthernetInstance , ( u16 ) LoopbackSpeed ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } AxiEthernetUtilPhyDelay ( 2 ) ; Status = AxiEthernetSingleFramePolledExample ( ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Status = AxiEthernetMultipleFramesPolledExample ( ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } return XST_SUCCESS ; }
This function demonstrates the usage of the Axi Ethernet by sending and
receiving frames in polled mode.
This function demonstrates the usage of the Axi Ethernet by sending and receiving frames in polled 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.
	 */ /****************************/ /* Run through the examples */ /****************************/ /*
	 * Run the Single Frame polled example
	 */ /*
	 * Run the Multiple Frames polled example
	 */