axiethernet: xaxiethernet_example_polled.c File Reference

| axiethernet Xilinx SDK Drivers API Documentation

- Overview
- Data Structures
- APIs
- File List
- Examples

Functions
xaxiethernet_example_polled.c File Reference

## Overview

Implements examples that utilize the Axi Ethernet's FIFO direct frame transfer mode in a polled fashion to send and receive frames.

These examples demonstrate:

- How to perform simple polling send and receive.
- Advanced frame processing
- Error handling

Functional guide to example:

- AxiEthernetSingleFramePolledExample() demonstrates the simplest way to send and receive frames in polled mode.
- AxiEthernetMultipleFramesPolledExample() demonstrates how to transmit a "burst" of frames by queueing up several in the packet FIFO prior to transmission.
- AxiEthernetPollForTxStatus() demonstrates how to poll for transmit complete status and how to handle error conditions.
- AxiEthernetPollForRxStatus() demonstrates how to poll for receive status and how to handle error conditions.
- AxiEthernetResetDevice() demonstrates how to reset the driver/HW without losing all configuration settings.

Note that the advanced frame processing algorithms shown here are not limited to polled mode operation. The same techniques can be used for FIFO direct interrupt driven mode as well.

    MODIFICATION HISTORY:

    Ver   Who  Date     Changes

    1.00a asa  4/30/10 First release based on the ll temac driver
    5.4   ms   01/23/17 Modified xil_printf statement in main function to
                        ensure that "Successfully ran" and "Failed" strings are
                        available in all examples. This is a fix for CR-965028.
          ms   04/05/17 Added tabspace for return statements in functions
                        for proper documentation while generating doxygen.

## Functions
int | AxiEthernetPolledExample (u16 AxiEthernetDeviceId, u16 FifoDeviceId)
| This function demonstrates the usage of the Axi Ethernet by sending and receiving frames in polled mode. More...
int | AxiEthernetSingleFramePolledExample (void)
| This function demonstrates the usage of the Axi Ethernet by sending and receiving a single frame in polled mode. More...
int | AxiEthernetMultipleFramesPolledExample (void)
| This example uses polled mode to queue up multiple frames in the packet FIFOs before sending them in a single burst. More...
int | AxiEthernetPollForTxStatus (void)
| This functions polls the Tx status and waits for an indication that a frame has been transmitted successfully or a transmit related error has occurred. More...
int | AxiEthernetPollForRxStatus (void)
| This functions polls the Rx status and waits for an indication that a frame has arrived or a receive related error has occurred. More...
int | AxiEthernetResetDevice (void)
| This function resets the device but preserves the options set by the user. More...
int | main (void)
| This is the main function for the AxiEthernet example. More...

## Function Documentation

int AxiEthernetMultipleFramesPolledExample | ( | void |  | ) |

This example uses polled mode to queue up multiple frames in the packet FIFOs before sending them in a single burst.

Receive packets are handled in a similar way.

Parameters

  None. |

Returns
  -XST_SUCCESS to indicate success -XST_FAILURE to indicate failure

Note
  None.

References AxiEthernetPollForRxStatus(), AxiEthernetPollForTxStatus(), AxiEthernetResetDevice(), AxiEthernetUtilErrorTrap(), AxiEthernetUtilFrameHdrFormatMAC(), AxiEthernetUtilFrameHdrFormatType(), AxiEthernetUtilFrameSetPayloadData(), AxiEthernetUtilFrameVerify(), XAxiEthernet_Start(), and XAxiEthernet_Stop().

Referenced by AxiEthernetPolledExample().

int AxiEthernetPolledExample | ( | u16 | AxiEthernetDeviceId,
|  | u16 | FifoDeviceId
| ) |  |

This function demonstrates the usage of the Axi Ethernet by sending and receiving frames in polled mode.

Parameters

  AxiEthernetDeviceId | is device ID of the AxiEthernet Device , typically XPAR_<AXIETHERNET_instance>_DEVICE_ID value from xparameters.h
  FifoDeviceId | is device ID of the Fifo device taken from xparameters.h

Returns
  -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.

References XAxiEthernet_Config::AxiDevBaseAddress, XAxiEthernet_Config::AxiDevType, AxiEthernetMultipleFramesPolledExample(), AxiEthernetSingleFramePolledExample(), AxiEthernetUtilEnterLoopback(), AxiEthernetUtilErrorTrap(), AxiEthernetUtilPhyDelay(), XAxiEthernet_Config::BaseAddress, XAxiEthernet_CfgInitialize(), XAxiEthernet_GetPhysicalInterface, XAxiEthernet_LookupConfig(), XAxiEthernet_SetMacAddress(), and XAxiEthernet_SetOperatingSpeed().

Referenced by main().

int AxiEthernetPollForRxStatus | ( | void |  | ) |

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.

Parameters

  None. |

Returns
  - 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.

References AxiEthernetResetDevice(), AxiEthernetUtilErrorTrap(), XAE_INT_RXFIFOOVR_MASK, XAE_INT_RXRJECT_MASK, and XAxiEthernet_GetIntStatus.

Referenced by AxiEthernetMultipleFramesPolledExample(), and AxiEthernetSingleFramePolledExample().

int AxiEthernetPollForTxStatus | ( | void |  | ) |

This functions polls the Tx status and waits for an indication that a frame has been transmitted successfully or a transmit related error has occurred.

If an error is reported, it handles all the possible error conditions.

Parameters

  None. |

Returns
  - XST_SUCCESS, Tx has completed
  - XST_NO_DATA, Timeout. Tx failure.
  - XST_FIFO_ERROR, Error in the FIFO.

Note
  None.

References AxiEthernetResetDevice(), and AxiEthernetUtilErrorTrap().

Referenced by AxiEthernetMultipleFramesPolledExample(), and AxiEthernetSingleFramePolledExample().

int AxiEthernetResetDevice | ( | void |  | ) |

This function resets the device but preserves the options set by the user.

Parameters

  None. |

Returns
  -XST_SUCCESS if reset is successful -XST_FAILURE. if reset is not successful

Note
  None.

References AxiEthernetUtilErrorTrap(), XAxiEthernet_ClearOptions(), XAxiEthernet_GetMacAddress(), XAxiEthernet_GetOptions(), XAxiEthernet_Reset(), XAxiEthernet_SetMacAddress(), XAxiEthernet_SetOptions(), and XAxiEthernet_Stop().

Referenced by AxiEthernetFifoIntrExample(), AxiEthernetMultipleFramesPolledExample(), AxiEthernetPollForRxStatus(), and AxiEthernetPollForTxStatus().

int AxiEthernetSingleFramePolledExample | ( | void |  | ) |

This function demonstrates the usage of the Axi Ethernet by sending and receiving a single frame in polled mode.

Parameters

  None. |

Returns
  -XST_SUCCESS to indicate success -XST_FAILURE to indicate failure

Note
  None.

References AxiEthernetPollForRxStatus(), AxiEthernetPollForTxStatus(), AxiEthernetUtilErrorTrap(), AxiEthernetUtilFrameHdrFormatMAC(), AxiEthernetUtilFrameHdrFormatType(), AxiEthernetUtilFrameMemClear(), AxiEthernetUtilFrameSetPayloadData(), AxiEthernetUtilFrameVerify(), XAxiEthernet_Start(), and XAxiEthernet_Stop().

Referenced by AxiEthernetPolledExample().

int main | ( | void |  | ) |

This is the main function for the AxiEthernet example.

This function is not included if the example is generated from the TestAppGen test tool.

Parameters

  None. |

Returns
  -XST_SUCCESS to indicate success -XST_FAILURE to indicate failure

Note
  None.

References AXIETHERNET_DEVICE_ID, AxiEthernetPolledExample(), and AxiEthernetUtilErrorTrap().