PSOC E8XXGP Device Support Library

| PSOC E8XXGP Device Support Library

Functions
Functions
PDL API Reference » EMAC (Ethernet MAC)

## General Description

## Functions
cy_en_ethif_status_t | Cy_ETHIF_MdioInit (ETH_Type *base, cy_stc_ethif_mac_config_t *pstcEthIfConfig)
| Initializes the Ethernet MAC with minimal parameters which is required to enable mdio interface. More...
cy_en_ethif_status_t | Cy_ETHIF_Init (ETH_Type *base, cy_stc_ethif_mac_config_t *pstcEthIfConfig, cy_stc_ethif_intr_config_t *pstcInterruptList)
| Initializes the Ethernet MAC, Cadence Driver, EthIf and PHY. More...
void | Cy_ETHIF_RegisterCallbacks (ETH_Type *base, cy_stc_ethif_cb_t *cbFuncsList)
| Function loads callback functions to its local data structures. More...
void | Cy_ETHIF_DecodeEvent (ETH_Type *base)
| Interrupt handler for a particular Ethernet instance. More...
cy_en_ethif_status_t | Cy_ETHIF_TransmitFrame (ETH_Type *base, uint8_t *pu8TxBuffer, uint16_t u16Length, uint8_t u8QueueIndex, bool bEndBuffer)
| Function initiates transmission of frame data. More...
cy_en_ethif_status_t | Cy_ETHIF_Get1588TimerValue (ETH_Type *base, cy_stc_ethif_1588_timer_val_t *stcRetTmrValue)
| Returns the current timer value from TSU register. More...
cy_en_ethif_status_t | Cy_ETHIF_Set1588TimerValue (ETH_Type *base, cy_stc_ethif_1588_timer_val_t *pstcTmrValue)
| Setting the current timer value in TSU register. More...
cy_en_ethif_status_t | Cy_ETHIF_TxPauseFrame (ETH_Type *base, bool bZeroTQ)
| Transmits IEEE 802.3X standard Pause Frame. More...
cy_en_ethif_status_t | Cy_ETHIF_ConfigPause (ETH_Type *base, uint16_t u16PauseQuanta)
| Configures the Pause Frame transmission according to IEEE 802.3X standard. More...
cy_en_ethif_status_t | Cy_ETHIF_PhyRegWrite (ETH_Type *base, uint8_t u8RegNo, uint16_t u16Data, uint8_t u8PHYAddr)
| Local function used by other APIs to write the PHY register. More...
uint32_t | Cy_ETHIF_PhyRegRead (ETH_Type *base, uint8_t u8RegNo, uint8_t u8PHYAddr)
| Local function used by other APIs to read the PHY register. More...
cy_en_ethif_status_t | Cy_ETHIF_SetFilterAddress (ETH_Type *base, cy_en_ethif_filter_num_t filterNo, const cy_stc_ethif_filter_config_t *config)
| Set Filter Address with specific filter number. More...
void | Cy_ETHIF_SetPromiscuousMode (ETH_Type *base, bool toBeEnabled)
| Enable/Disable to capture all frames. More...
void | Cy_ETHIF_SetNoBroadCast (ETH_Type *base, bool rejectBC)
| Enable/Disable receive of broadcast frames. More...
void | Cy_ETHIF_DiscardNonVLANFrames (ETH_Type *base, bool enable)
| With VLAN tagged frame processing setup, this function configure MAC to receive only VLAN tagged frames and discard all. More...
void * | Cy_ETHIF_GetPrivateData (ETH_Type *base)
| Get pointer to private data. More...

## Function Documentation

## ◆ Cy_ETHIF_MdioInit()

cy_en_ethif_status_t Cy_ETHIF_MdioInit | ( | ETH_Type * | base,
|  | cy_stc_ethif_mac_config_t * | pstcEthIfConfig
| ) |  |

Initializes the Ethernet MAC with minimal parameters which is required to enable mdio interface.

Parameters

  base | Pointer to register area of Ethernet MAC
  pstcEthIfConfig | Pointer to Ethernet configuration parameters

Returns
  CY_ETHIF_SUCCESS Ethernet MAC has been initialized along with Cadence driver and external PHY
  CY_ETHIF_BAD_PARAM If following conditions are met: pstcEth == NULL pstcEthIfConfig == NULL GEM_GXL Object could not be created.

Note
  This function Initializes the Ethernet MAC partially. This function is only required if user wants to access PHY registers before Cy_ETHIF_Init().

Load the Ethernet instance

## ◆ Cy_ETHIF_Init()

cy_en_ethif_status_t Cy_ETHIF_Init | ( | ETH_Type * | base,
|  | cy_stc_ethif_mac_config_t * | pstcEthIfConfig,
|  | cy_stc_ethif_intr_config_t * | pstcInterruptList
| ) |  |

Initializes the Ethernet MAC, Cadence Driver, EthIf and PHY.

Parameters

  base | Pointer to register area of Ethernet MAC
  pstcEthIfConfig | Pointer to Ethernet configuration parameters
  pstcInterruptList | List of Interrupts to enable

Returns
  CY_ETHIF_SUCCESS Ethernet MAC has been initialized along with Cadence driver and external PHY
  CY_ETHIF_BAD_PARAM If following conditions are met: pstcEth == NULL pstcEthIfConfig == NULL pstcInterruptList == NULL GEM_GXL Object could not be created Memory assigned by Interface layer is not enough Cadence driver could not initialize Ethernet MAC
  CY_ETHIF_MEMORY_NOT_ENOUGH Assigned memory for BDs or for Private data is not enough

Note
  This function Initializes the Ethernet MAC, Cadence driver, EthIf layer and external PHY with the provided parameters. Port init for the Ethernet must be done before calling Cy_ETHIF_Init function. Buffer configuration parameters shall be done in cy_ethif.h file

Load the Ethernet instance

## ◆ Cy_ETHIF_RegisterCallbacks()

void Cy_ETHIF_RegisterCallbacks | ( | ETH_Type * | base,
|  | cy_stc_ethif_cb_t * | cbFuncsList
| ) |  |

Function loads callback functions to its local data structures.

The callback functions are called from ISR context.

Parameters

  base | Pointer to register area of Ethernet MAC
  cbFuncsList | pointer to callback function list

## ◆ Cy_ETHIF_DecodeEvent()

void Cy_ETHIF_DecodeEvent | ( | ETH_Type * | base | ) |

Interrupt handler for a particular Ethernet instance.

It decodes the interrupt cause and calls the appropriate registered callback functions.

Parameters

  base | Pointer to register area of Ethernet MAC

## ◆ Cy_ETHIF_TransmitFrame()

cy_en_ethif_status_t Cy_ETHIF_TransmitFrame | ( | ETH_Type * | base,
|  | uint8_t * | pu8TxBuffer,
|  | uint16_t | u16Length,
|  | uint8_t | u8QueueIndex,
|  | bool | bEndBuffer
| ) |  |

Function initiates transmission of frame data.

Parameters

  base | Pointer to register area of Ethernet MAC
  pu8TxBuffer | pointer to Transmit source buffer. Its caller's responsibility to make sure this buffer is not overwritten until transmit is not completed. Cy_ETHIF_RegisterCallbacks for Tx completion callback.
  u16Length | Length of data to transmit from source buffer, Length should include source and destination buffer address. CRC bytes shall not be included in the length
  u8QueueIndex | Queue to be used to transmit the frame
  bEndBuffer | True - Last buffer of the frame to be transmitted. False - Other Buffers to be provided after function call IP will not start transmitting until it gets EndBuffer True.

Returns
  CY_ETHIF_SUCCESS Frame transmission started
  CY_ETHIF_BAD_PARAM Parameter passed contains invalid values
  CY_ETHIF_BUFFER_NOT_AVAILABLE Buffer not available to load the source data

## ◆ Cy_ETHIF_Get1588TimerValue()

cy_en_ethif_status_t Cy_ETHIF_Get1588TimerValue | ( | ETH_Type * | base,
|  | cy_stc_ethif_1588_timer_val_t * | stcRetTmrValue
| ) |  |

Returns the current timer value from TSU register.

Parameters

  base | Pointer to register area of Ethernet MAC
  stcRetTmrValue | [out] pointer to data structure to return the values

Returns
  CY_ETHIF_SUCCESS Timer value is successfully retrieved
  CY_ETHIF_BAD_PARAM Parameter passed contains invalid values
  CY_ETHIF_NOT_INITIALIZED Ethernet Interface not initialized

## ◆ Cy_ETHIF_Set1588TimerValue()

cy_en_ethif_status_t Cy_ETHIF_Set1588TimerValue | ( | ETH_Type * | base,
|  | cy_stc_ethif_1588_timer_val_t * | pstcTmrValue
| ) |  |

Setting the current timer value in TSU register.

Parameters

  base | Pointer to register area of Ethernet MAC
  pstcTmrValue | pointer to data structure to configure register with

Returns
  CY_ETHIF_SUCCESS Timer value is set
  CY_ETHIF_BAD_PARAM Parameter passed contains invalid values
  CY_ETHIF_NOT_INITIALIZED Ethernet Interface not initialized

## ◆ Cy_ETHIF_TxPauseFrame()

cy_en_ethif_status_t Cy_ETHIF_TxPauseFrame | ( | ETH_Type * | base,
|  | bool | bZeroTQ
| ) |  |

Transmits IEEE 802.3X standard Pause Frame.

Parameters

  base | Pointer to register area of Ethernet MAC
  bZeroTQ | True - Zero Time Quanta bZeroTQ False - Transmit pause frame with set time quanta

Returns
  CY_ETHIF_SUCCESS for success
  CY_ETHIF_BAD_PARAM for wrong input parameters

Note
  If interrupt enabled, interrupt will be triggered at the end of the transmission

## ◆ Cy_ETHIF_ConfigPause()

cy_en_ethif_status_t Cy_ETHIF_ConfigPause | ( | ETH_Type * | base,
|  | uint16_t | u16PauseQuanta
| ) |  |

Configures the Pause Frame transmission according to IEEE 802.3X standard.

Parameters

  base | Pointer to register area of Ethernet MAC
  u16PauseQuanta | Time Quanta

Returns
  CY_ETHIF_SUCCESS for success
  CY_ETHIF_BAD_PARAM for wrong input parameters

## ◆ Cy_ETHIF_PhyRegWrite()

cy_en_ethif_status_t Cy_ETHIF_PhyRegWrite | ( | ETH_Type * | base,
|  | uint8_t | u8RegNo,
|  | uint16_t | u16Data,
|  | uint8_t | u8PHYAddr
| ) |  |

Local function used by other APIs to write the PHY register.

Parameters

  base | Pointer to register area of Ethernet MAC
  u8RegNo | Register to write
  u16Data | data to write
  u8PHYAddr | u8PHYAddr

Returns
  CY_ETHIF_SUCCESS PHY write is successful
  CY_ETHIF_BAD_PARAM Parameter passed contains invalid values

Note
  u8PHYAddr must match with PHY. PHY data-sheet and hardware schematic shall be checked

## ◆ Cy_ETHIF_PhyRegRead()

uint32_t Cy_ETHIF_PhyRegRead | ( | ETH_Type * | base,
|  | uint8_t | u8RegNo,
|  | uint8_t | u8PHYAddr
| ) |  |

Local function used by other APIs to read the PHY register.

Parameters

  base | Pointer to register area of Ethernet MAC
  u8RegNo | Register to read
  u8PHYAddr | u8PHYAddr

Returns
  read data from the register

Note
  CY_ETH_PHY_ADDR must match with PHY. PHY data-sheet and hardware schematic shall be checked

## ◆ Cy_ETHIF_SetFilterAddress()

cy_en_ethif_status_t Cy_ETHIF_SetFilterAddress | ( | ETH_Type * | base,
|  | cy_en_ethif_filter_num_t | filterNo,
|  | const cy_stc_ethif_filter_config_t * | config
| ) |  |

Set Filter Address with specific filter number.

Parameters

  base | Pointer to register area of Ethernet MAC
  filterNo | Filter number config Filter configuration for Ethernet MAC
  config | config

Returns
  CY_ETHIF_SUCCESS Filter is set
  CY_ETHIF_BAD_PARAM Parameter passed contains invalid values

Note
  Maximum 4 filters can be set

## ◆ Cy_ETHIF_SetPromiscuousMode()

void Cy_ETHIF_SetPromiscuousMode | ( | ETH_Type * | base,
|  | bool | toBeEnabled
| ) |  |

Enable/Disable to capture all frames.

Parameters

  base | Pointer to register area of Ethernet MAC
  toBeEnabled | if =1 enables copy all frames mode, if =0 then this is disabled

## ◆ Cy_ETHIF_SetNoBroadCast()

void Cy_ETHIF_SetNoBroadCast | ( | ETH_Type * | base,
|  | bool | rejectBC
| ) |  |

Enable/Disable receive of broadcast frames.

Parameters

  base | Pointer to register area of Ethernet MAC
  rejectBC | if =0 broadcasts are accepted, if =1 they are rejected.

## ◆ Cy_ETHIF_DiscardNonVLANFrames()

void Cy_ETHIF_DiscardNonVLANFrames | ( | ETH_Type * | base,
|  | bool | enable
| ) |  |

With VLAN tagged frame processing setup, this function configure MAC to receive only VLAN tagged frames and discard all.

Parameters

  base | Pointer to Ethernet Instance
  enable | if =1 reject non-VLAN-tagged frames, if =0 then accept

## ◆ Cy_ETHIF_GetPrivateData()

void * Cy_ETHIF_GetPrivateData | ( | ETH_Type * | base | ) |

Get pointer to private data.

Parameters

  base | Pointer to register area of Ethernet MAC

Returns
  Pointer to private data or NULL in case wrong parameter