| M480 BSP V3.05.001 The Board Support Package for M480 Series

Macros | Functions
EMAC Exported Functions
Standard Driver » EMAC Driver

## Macros
#define | EMAC_ENABLE_TX()
| Enable EMAC Tx function. More...
#define | EMAC_ENABLE_RX()
| Enable EMAC Rx function. More...
#define | EMAC_DISABLE_TX()
| Disable EMAC Tx function. More...
#define | EMAC_DISABLE_RX()
| Disable EMAC Rx function. More...
#define | EMAC_ENABLE_MAGIC_PKT_WAKEUP()
| Enable EMAC Magic Packet Wakeup function. More...
#define | EMAC_DISABLE_MAGIC_PKT_WAKEUP()
| Disable EMAC Magic Packet Wakeup function. More...
#define | EMAC_ENABLE_RECV_BCASTPKT()
| Enable EMAC to receive broadcast packets. More...
#define | EMAC_DISABLE_RECV_BCASTPKT()
| Disable EMAC to receive broadcast packets. More...
#define | EMAC_ENABLE_RECV_MCASTPKT()
| Enable EMAC to receive multicast packets. More...
#define | EMAC_DISABLE_RECV_MCASTPKT()
| Disable EMAC Magic Packet Wakeup function. More...
#define | EMAC_GET_ALARM_FLAG()
| Check if EMAC time stamp alarm interrupt occurred or not. More...
#define | EMAC_CLR_ALARM_FLAG()
| Clear EMAC time stamp alarm interrupt flag. More...
#define | EMAC_TRIGGER_RX() do{EMAC->RXST = 0UL;}while(0)
| Trigger EMAC Rx function. More...
#define | EMAC_TRIGGER_TX() do{EMAC->TXST = 0UL;}while(0)
| Trigger EMAC Tx function. More...
#define | EMAC_ENABLE_INT(emac, u32eIntSel)
| Enable specified EMAC interrupt. More...
#define | EMAC_DISABLE_INT(emac, u32eIntSel)
| Disable specified EMAC interrupt. More...
#define | EMAC_GET_INT_FLAG(emac, u32eIntTypeFlag)
| Get specified interrupt flag/status. More...
#define | EMAC_CLEAR_INT_FLAG(emac, u32eIntTypeFlag)
| Clear specified interrupt flag/status. More...

## Functions
void | EMAC_Open (uint8_t *pu8MacAddr)
| Initialize EMAC interface, including descriptors, MAC address, and PHY. More...
void | EMAC_Close (void)
| This function stop all receive and transmit activity and disable MAC interface. More...
void | EMAC_SetMacAddr (uint8_t *pu8MacAddr)
| Set the device MAC address. More...
void | EMAC_EnableCamEntry (uint32_t u32Entry, uint8_t pu8MacAddr[])
| Fill a CAM entry for MAC address comparison. More...
void | EMAC_DisableCamEntry (uint32_t u32Entry)
| Disable a specified CAM entry. More...
uint32_t | EMAC_RecvPkt (uint8_t *pu8Data, uint32_t *pu32Size)
| Receive an Ethernet packet. More...
uint32_t | EMAC_RecvPktTS (uint8_t *pu8Data, uint32_t *pu32Size, uint32_t *pu32Sec, uint32_t *pu32Nsec)
| Receive an Ethernet packet and the time stamp while it's received. More...
void | EMAC_RecvPktDone (void)
| Clean up process after a packet is received. More...
uint32_t | EMAC_SendPkt (uint8_t *pu8Data, uint32_t u32Size)
| Send an Ethernet packet. More...
uint32_t | EMAC_SendPktDone (void)
| Clean up process after packet(s) are sent. More...
uint32_t | EMAC_SendPktDoneTS (uint32_t *pu32Sec, uint32_t *pu32Nsec)
| Clean up process after a packet is sent, and get the time stamp while packet is sent. More...
void | EMAC_EnableTS (uint32_t u32Sec, uint32_t u32Nsec)
| Enable IEEE1588 time stamp function and set current time. More...
void | EMAC_DisableTS (void)
| Disable IEEE1588 time stamp function. More...
void | EMAC_GetTime (uint32_t *pu32Sec, uint32_t *pu32Nsec)
| Get current time stamp. More...
void | EMAC_SetTime (uint32_t u32Sec, uint32_t u32Nsec)
| Set current time stamp. More...
void | EMAC_UpdateTime (uint32_t u32Neg, uint32_t u32Sec, uint32_t u32Nsec)
| Add a offset to current time. More...
void | EMAC_EnableAlarm (uint32_t u32Sec, uint32_t u32Nsec)
| Enable alarm function and set alarm time. More...
void | EMAC_DisableAlarm (void)
| Disable alarm function. More...
uint32_t | EMAC_CheckLinkStatus (void)
| Check Ethernet link status. More...
void | EMAC_PhyInit (void)
int32_t | EMAC_FillCamEntry (uint8_t pu8MacAddr[])
| Fill a MAC address to list and enable. More...
uint8_t * | EMAC_ClaimFreeTXBuf (void)
| Get avaiable TX buffer address. More...
uint32_t | EMAC_GetAvailRXBufSize (void)
| Get data length of avaiable RX buffer. More...
uint32_t | EMAC_SendPktWoCopy (uint32_t u32Size)
| Send an Ethernet packet. More...
void | EMAC_RecvPktDoneWoRxTrigger (void)
| Clean up process after a packet is received. More...

## Detailed Description

HIDDEN_SYMBOLS

## Macro Definition Documentation

## ◆ EMAC_CLEAR_INT_FLAG

#define EMAC_CLEAR_INT_FLAG | ( |  | emac,
|  |  | u32eIntTypeFlag
| ) |  |

Clear specified interrupt flag/status.

Parameters

  [in] | emac | The pointer of the specified EMAC module
  [in] | u32eIntTypeFlag | Interrupt Type Flag, should be EMAC_INTSTS_RXIF_Msk : Receive EMAC_INTSTS_CRCEIF_Msk : CRC Error EMAC_INTSTS_RXOVIF_Msk : Receive FIFO Overflow EMAC_INTSTS_LPIF_Msk : Long Packet EMAC_INTSTS_RXGDIF_Msk : Receive Good EMAC_INTSTS_ALIEIF_Msk : Alignment Error EMAC_INTSTS_RPIF_Msk : Runt Packet EMAC_INTSTS_MPCOVIF_Msk : Missed Packet Counter EMAC_INTSTS_MFLEIF_Msk : Maximum Frame Length Exceed EMAC_INTSTS_DENIF_Msk : DMA Early Notification EMAC_INTSTS_RDUIF_Msk : Receive Descriptor Unavailable EMAC_INTSTS_RXBEIF_Msk : Receive Bus Error EMAC_INTSTS_CFRIF_Msk : Control Frame Receive EMAC_INTSTS_WOLIF_Msk : Wake on LAN EMAC_INTSTS_TXIF_Msk : Transmit EMAC_INTSTS_TXUDIF_Msk : Transmit FIFO Underflow EMAC_INTSTS_TXCPIF_Msk : Transmit Completion EMAC_INTSTS_EXDEFIF_Msk : Defer Exceed EMAC_INTSTS_NCSIF_Msk : No Carrier Sense EMAC_INTSTS_TXABTIF_Msk : Transmit Abort EMAC_INTSTS_LCIF_Msk : Late Collision EMAC_INTSTS_TDUIF_Msk : Transmit Descriptor Unavailable EMAC_INTSTS_TXBEIF_Msk : Transmit Bus Error EMAC_INTSTS_TSALMIF_Msk : Time Stamp Alarm

Return values

  0 | The specified interrupt is not happened. 1 The specified interrupt is happened.

This macro clear specified interrupt flag or interrupt indicator status.

Definition at line 312 of file emac.h.

## ◆ EMAC_CLR_ALARM_FLAG

#define EMAC_CLR_ALARM_FLAG | ( |  | ) |

Clear EMAC time stamp alarm interrupt flag.

Parameters

  None |

Returns
  None

Definition at line 149 of file emac.h.

## ◆ EMAC_DISABLE_INT

#define EMAC_DISABLE_INT | ( |  | emac,
|  |  | u32eIntSel
| ) |  |

Disable specified EMAC interrupt.

Parameters

  [in] | emac | The pointer of the specified EMAC module
  [in] | u32eIntSel | Interrupt type select EMAC_INTEN_RXIEN_Msk : Receive EMAC_INTEN_CRCEIEN_Msk : CRC Error EMAC_INTEN_RXOVIEN_Msk : Receive FIFO Overflow EMAC_INTEN_LPIEN_Msk : Long Packet EMAC_INTEN_RXGDIEN_Msk : Receive Good EMAC_INTEN_ALIEIEN_Msk : Alignment Error EMAC_INTEN_RPIEN_Msk : Runt Packet EMAC_INTEN_MPCOVIEN_Msk : Miss Packet Counter Overrun EMAC_INTEN_MFLEIEN_Msk : Maximum Frame Length Exceed EMAC_INTEN_DENIEN_Msk : DMA Early Notification EMAC_INTEN_RDUIEN_Msk : Receive Descriptor Unavailable EMAC_INTEN_RXBEIEN_Msk : Receive Bus Error EMAC_INTEN_CFRIEN_Msk : Control Frame Receive EMAC_INTEN_WOLIEN_Msk : Wake on LAN Interrupt EMAC_INTEN_TXIEN_Msk : Transmit EMAC_INTEN_TXUDIEN_Msk : Transmit FIFO Underflow EMAC_INTEN_TXCPIEN_Msk : Transmit Completion EMAC_INTEN_EXDEFIEN_Msk : Defer Exceed EMAC_INTEN_NCSIEN_Msk : No Carrier Sense EMAC_INTEN_TXABTIEN_Msk : Transmit Abort EMAC_INTEN_LCIEN_Msk : Late Collision EMAC_INTEN_TDUIEN_Msk : Transmit Descriptor Unavailable EMAC_INTEN_TXBEIEN_Msk : Transmit Bus Error EMAC_INTEN_TSALMIEN_Msk : Time Stamp Alarm

Returns
  None

This macro disable specified EMAC interrupt.

Definition at line 237 of file emac.h.

## ◆ EMAC_DISABLE_MAGIC_PKT_WAKEUP

#define EMAC_DISABLE_MAGIC_PKT_WAKEUP | ( |  | ) |

Disable EMAC Magic Packet Wakeup function.

Parameters

  None |

Returns
  None

Definition at line 99 of file emac.h.

## ◆ EMAC_DISABLE_RECV_BCASTPKT

#define EMAC_DISABLE_RECV_BCASTPKT | ( |  | ) |

Disable EMAC to receive broadcast packets.

Parameters

  None |

Returns
  None

Definition at line 115 of file emac.h.

## ◆ EMAC_DISABLE_RECV_MCASTPKT

#define EMAC_DISABLE_RECV_MCASTPKT | ( |  | ) |

Disable EMAC Magic Packet Wakeup function.

Parameters

  None |

Returns
  None

Definition at line 131 of file emac.h.

## ◆ EMAC_DISABLE_RX

#define EMAC_DISABLE_RX | ( |  | ) |

Disable EMAC Rx function.

Parameters

  None |

Returns
  None

Definition at line 83 of file emac.h.

## ◆ EMAC_DISABLE_TX

#define EMAC_DISABLE_TX | ( |  | ) |

Disable EMAC Tx function.

Parameters

  None |

Returns
  None

Definition at line 74 of file emac.h.

## ◆ EMAC_ENABLE_INT

#define EMAC_ENABLE_INT | ( |  | emac,
|  |  | u32eIntSel
| ) |  |

Enable specified EMAC interrupt.

Parameters

  [in] | emac | The pointer of the specified EMAC module
  [in] | u32eIntSel | Interrupt type select EMAC_INTEN_RXIEN_Msk : Receive EMAC_INTEN_CRCEIEN_Msk : CRC Error EMAC_INTEN_RXOVIEN_Msk : Receive FIFO Overflow EMAC_INTEN_LPIEN_Msk : Long Packet EMAC_INTEN_RXGDIEN_Msk : Receive Good EMAC_INTEN_ALIEIEN_Msk : Alignment Error EMAC_INTEN_RPIEN_Msk : Runt Packet EMAC_INTEN_MPCOVIEN_Msk : Miss Packet Counter Overrun EMAC_INTEN_MFLEIEN_Msk : Maximum Frame Length Exceed EMAC_INTEN_DENIEN_Msk : DMA Early Notification EMAC_INTEN_RDUIEN_Msk : Receive Descriptor Unavailable EMAC_INTEN_RXBEIEN_Msk : Receive Bus Error EMAC_INTEN_CFRIEN_Msk : Control Frame Receive EMAC_INTEN_WOLIEN_Msk : Wake on LAN Interrupt EMAC_INTEN_TXIEN_Msk : Transmit EMAC_INTEN_TXUDIEN_Msk : Transmit FIFO Underflow EMAC_INTEN_TXCPIEN_Msk : Transmit Completion EMAC_INTEN_EXDEFIEN_Msk : Defer Exceed EMAC_INTEN_NCSIEN_Msk : No Carrier Sense EMAC_INTEN_TXABTIEN_Msk : Transmit Abort EMAC_INTEN_LCIEN_Msk : Late Collision EMAC_INTEN_TDUIEN_Msk : Transmit Descriptor Unavailable EMAC_INTEN_TXBEIEN_Msk : Transmit Bus Error EMAC_INTEN_TSALMIEN_Msk : Time Stamp Alarm

Returns
  None

This macro enable specified EMAC interrupt.

Definition at line 200 of file emac.h.

## ◆ EMAC_ENABLE_MAGIC_PKT_WAKEUP

#define EMAC_ENABLE_MAGIC_PKT_WAKEUP | ( |  | ) |

Enable EMAC Magic Packet Wakeup function.

Parameters

  None |

Returns
  None

Definition at line 91 of file emac.h.

## ◆ EMAC_ENABLE_RECV_BCASTPKT

#define EMAC_ENABLE_RECV_BCASTPKT | ( |  | ) |

Enable EMAC to receive broadcast packets.

Parameters

  None |

Returns
  None

Definition at line 107 of file emac.h.

## ◆ EMAC_ENABLE_RECV_MCASTPKT

#define EMAC_ENABLE_RECV_MCASTPKT | ( |  | ) |

Enable EMAC to receive multicast packets.

Parameters

  None |

Returns
  None

Definition at line 123 of file emac.h.

## ◆ EMAC_ENABLE_RX

#define EMAC_ENABLE_RX | ( |  | ) |

Enable EMAC Rx function.

Parameters

  None |

Returns
  None

Definition at line 66 of file emac.h.

## ◆ EMAC_ENABLE_TX

#define EMAC_ENABLE_TX | ( |  | ) |

Enable EMAC Tx function.

Parameters

  None |

Returns
  None

Definition at line 57 of file emac.h.

## ◆ EMAC_GET_ALARM_FLAG

#define EMAC_GET_ALARM_FLAG | ( |  | ) |

Check if EMAC time stamp alarm interrupt occurred or not.

Parameters

  None |

Returns
  If time stamp alarm interrupt occurred or not

Return values

  0 | Alarm interrupt does not occur
  1 | Alarm interrupt occurred

Definition at line 141 of file emac.h.

## ◆ EMAC_GET_INT_FLAG

#define EMAC_GET_INT_FLAG | ( |  | emac,
|  |  | u32eIntTypeFlag
| ) |  |

Get specified interrupt flag/status.

Parameters

  [in] | emac | The pointer of the specified EMAC module
  [in] | u32eIntTypeFlag | Interrupt Type Flag, should be EMAC_INTSTS_RXIF_Msk : Receive EMAC_INTSTS_CRCEIF_Msk : CRC Error EMAC_INTSTS_RXOVIF_Msk : Receive FIFO Overflow EMAC_INTSTS_LPIF_Msk : Long Packet EMAC_INTSTS_RXGDIF_Msk : Receive Good EMAC_INTSTS_ALIEIF_Msk : Alignment Error EMAC_INTSTS_RPIF_Msk : Runt Packet EMAC_INTSTS_MPCOVIF_Msk : Missed Packet Counter EMAC_INTSTS_MFLEIF_Msk : Maximum Frame Length Exceed EMAC_INTSTS_DENIF_Msk : DMA Early Notification EMAC_INTSTS_RDUIF_Msk : Receive Descriptor Unavailable EMAC_INTSTS_RXBEIF_Msk : Receive Bus Error EMAC_INTSTS_CFRIF_Msk : Control Frame Receive EMAC_INTSTS_WOLIF_Msk : Wake on LAN EMAC_INTSTS_TXIF_Msk : Transmit EMAC_INTSTS_TXUDIF_Msk : Transmit FIFO Underflow EMAC_INTSTS_TXCPIF_Msk : Transmit Completion EMAC_INTSTS_EXDEFIF_Msk : Defer Exceed EMAC_INTSTS_NCSIF_Msk : No Carrier Sense EMAC_INTSTS_TXABTIF_Msk : Transmit Abort EMAC_INTSTS_LCIF_Msk : Late Collision EMAC_INTSTS_TDUIF_Msk : Transmit Descriptor Unavailable EMAC_INTSTS_TXBEIF_Msk : Transmit Bus Error EMAC_INTSTS_TSALMIF_Msk : Time Stamp Alarm

Returns
  None

This macro get specified interrupt flag or interrupt indicator status.

Definition at line 274 of file emac.h.

## ◆ EMAC_TRIGGER_RX

#define EMAC_TRIGGER_RX | ( |  | ) | do{EMAC->RXST = 0UL;}while(0)

Trigger EMAC Rx function.

Parameters

  None |

Returns
  None

Definition at line 156 of file emac.h.

## ◆ EMAC_TRIGGER_TX

#define EMAC_TRIGGER_TX | ( |  | ) | do{EMAC->TXST = 0UL;}while(0)

Trigger EMAC Tx function.

Parameters

  None |

Returns
  None

Definition at line 163 of file emac.h.

## Function Documentation

## ◆ EMAC_CheckLinkStatus()

uint32_t EMAC_CheckLinkStatus | ( | void |  | ) |

Check Ethernet link status.

Parameters

  None |

Returns
  Current link status, could be one of following value.
  - EMAC_LINK_DOWN
  - EMAC_LINK_100F
  - EMAC_LINK_100H
  - EMAC_LINK_10F
  - EMAC_LINK_10H

Note
  This API should be called regularly to sync EMAC setting with real connection status

Definition at line 965 of file emac.c.

## ◆ EMAC_ClaimFreeTXBuf()

uint8_t * EMAC_ClaimFreeTXBuf | ( | void |  | ) |

Get avaiable TX buffer address.

Parameters

  None |

Returns
  An avaiable TX buffer.

Note
  This API should be called before EMAC_SendPkt_WoCopy calling. Caller will do data-copy.

Definition at line 1098 of file emac.c.

## ◆ EMAC_Close()

void EMAC_Close | ( | void |  | ) |

This function stop all receive and transmit activity and disable MAC interface.

Parameters

  None |

Returns
  None

Definition at line 420 of file emac.c.

## ◆ EMAC_DisableAlarm()

void EMAC_DisableAlarm | ( | void |  | ) |

Disable alarm function.

Parameters

  None |

Returns
  None

Definition at line 926 of file emac.c.

## ◆ EMAC_DisableCamEntry()

void EMAC_DisableCamEntry | ( | uint32_t | u32Entry | ) |

Disable a specified CAM entry.

Parameters

  [in] | u32Entry | CAM entry to be disabled

Returns
  None

Definition at line 468 of file emac.c.

## ◆ EMAC_DisableTS()

void EMAC_DisableTS | ( | void |  | ) |

Disable IEEE1588 time stamp function.

Parameters

  None |

Returns
  None

Definition at line 872 of file emac.c.

## ◆ EMAC_EnableAlarm()

void EMAC_EnableAlarm | ( | uint32_t | u32Sec,
|  | uint32_t | u32Nsec
| ) |  |

Enable alarm function and set alarm time.

Parameters

  [in] | u32Sec | Second value to trigger alarm
  [in] | u32Nsec | Nano second value to trigger alarm

Returns
  None

Definition at line 912 of file emac.c.

## ◆ EMAC_EnableCamEntry()

void EMAC_EnableCamEntry | ( | uint32_t | u32Entry,
|  | uint8_t | pu8MacAddr[]
| ) |  |

Fill a CAM entry for MAC address comparison.

Parameters

  [in] | u32Entry | MAC entry to fill. Entry 0 is used to store device MAC address, do not overwrite the setting in it.
  [in] | pu8MacAddr | Pointer to uint8_t array holds MAC address

Returns
  None

Definition at line 444 of file emac.c.

## ◆ EMAC_EnableTS()

void EMAC_EnableTS | ( | uint32_t | u32Sec,
|  | uint32_t | u32Nsec
| ) |  |

Enable IEEE1588 time stamp function and set current time.

Parameters

  [in] | u32Sec | Second value
  [in] | u32Nsec | Nano second value

Returns
  None

Definition at line 844 of file emac.c.

## ◆ EMAC_FillCamEntry()

int32_t EMAC_FillCamEntry | ( | uint8_t | pu8MacAddr[] | ) |

Fill a MAC address to list and enable.

Parameters

  pu8MacAddr | A MAC address

Returns
  The CAM index

Return values

  -1 | Failed to fill the MAC address.
  0~(EMAC_CAMENTRY_NB-1) | The index number of entry location.

Definition at line 1011 of file emac.c.

## ◆ EMAC_GetAvailRXBufSize()

uint32_t EMAC_GetAvailRXBufSize | ( | void |  | ) |

Get data length of avaiable RX buffer.

Parameters

  None |

Returns
  An data length of avaiable RX buffer.

Note
  This API should be called before EMAC_RecvPktDone_WoTrigger calling. Caller will do data-copy.

Definition at line 1118 of file emac.c.

## ◆ EMAC_GetTime()

void EMAC_GetTime | ( | uint32_t * | pu32Sec,
|  | uint32_t * | pu32Nsec
| ) |  |

Get current time stamp.

Parameters

  [out] | pu32Sec | Current second value
  [out] | pu32Nsec | Current nano second value

Returns
  None

Definition at line 883 of file emac.c.

## ◆ EMAC_Open()

void EMAC_Open | ( | uint8_t * | pu8MacAddr | ) |

Initialize EMAC interface, including descriptors, MAC address, and PHY.

Parameters

  [in] | pu8MacAddr | Pointer to uint8_t array holds MAC address

Returns
  None

Note
  This API configures EMAC to receive all broadcast and multicast packets, but could configure to other settings with EMAC_ENABLE_RECV_BCASTPKT, EMAC_DISABLE_RECV_BCASTPKT, EMAC_ENABLE_RECV_MCASTPKT, and EMAC_DISABLE_RECV_MCASTPKT
  Receive(RX) and transmit(TX) are not enabled yet, application must call EMAC_ENABLE_RX and EMAC_ENABLE_TX to enable receive and transmit function.

Definition at line 381 of file emac.c.

## ◆ EMAC_PhyInit()

void EMAC_PhyInit | ( | void |  | ) |

## ◆ EMAC_RecvPkt()

uint32_t EMAC_RecvPkt | ( | uint8_t * | pu8Data,
|  | uint32_t * | pu32Size
| ) |  |

Receive an Ethernet packet.

Parameters

  [in] | pu8Data | Pointer to a buffer to store received packet (4 byte CRC removed)
  [in] | pu32Size | Received packet size (without 4 byte CRC).

Returns
  Packet receive success or not

Return values

  0 | No packet available for receive
  1 | A packet is received

Note
  Return 0 doesn't guarantee the packet will be sent and received successfully.

Definition at line 483 of file emac.c.

## ◆ EMAC_RecvPktDone()

void EMAC_RecvPktDone | ( | void |  | ) |

Clean up process after a packet is received.

Parameters

  None |

Returns
  None

EMAC Rx interrupt service routine must call this API to release the resource use by receive process

Note
  Application can only call this function once every time EMAC_RecvPkt or EMAC_RecvPktTS returns 1

Definition at line 614 of file emac.c.

## ◆ EMAC_RecvPktDoneWoRxTrigger()

void EMAC_RecvPktDoneWoRxTrigger | ( | void |  | ) |

Clean up process after a packet is received.

Parameters

  None |

Returns
  None

Caller must call the function to release the resource.

Note
  Application can only call this function once every time EMAC_RecvPkt or EMAC_RecvPktTS returns 1
  This function is without doing EMAC_TRIGGER_RX.

Definition at line 1150 of file emac.c.

## ◆ EMAC_RecvPktTS()

uint32_t EMAC_RecvPktTS | ( | uint8_t * | pu8Data,
|  | uint32_t * | pu32Size,
|  | uint32_t * | pu32Sec,
|  | uint32_t * | pu32Nsec
| ) |  |

Receive an Ethernet packet and the time stamp while it's received.

Parameters

  [out] | pu8Data | Pointer to a buffer to store received packet (4 byte CRC removed)
  [out] | pu32Size | Received packet size (without 4 byte CRC).
  [out] | pu32Sec | Second value while packet received
  [out] | pu32Nsec | Nano second value while packet received

Returns
  Packet receive success or not

Return values

  0 | No packet available for receive
  1 | A packet is received

Note
  Return 0 doesn't guarantee the packet will be sent and received successfully.
  Largest Ethernet packet is 1514 bytes after stripped CRC, application must give a buffer large enough to store such packet

Definition at line 548 of file emac.c.

## ◆ EMAC_SendPkt()

uint32_t EMAC_SendPkt | ( | uint8_t * | pu8Data,
|  | uint32_t | u32Size
| ) |  |

Send an Ethernet packet.

Parameters

  [in] | pu8Data | Pointer to a buffer holds the packet to transmit
  [in] | u32Size | Packet size (without 4 byte CRC).

Returns
  Packet transmit success or not

Return values

  0 | Transmit failed due to descriptor unavailable.
  1 | Packet is copied to descriptor and triggered to transmit.

Note
  Return 1 doesn't guarantee the packet will be sent and received successfully.

Definition at line 646 of file emac.c.

## ◆ EMAC_SendPktDone()

uint32_t EMAC_SendPktDone | ( | void |  | ) |

Clean up process after packet(s) are sent.

Parameters

  None |

Returns
  Number of packet sent between two function calls

EMAC Tx interrupt service routine must call this API or EMAC_SendPktDoneTS to release the resource use by transmit process

Definition at line 686 of file emac.c.

## ◆ EMAC_SendPktDoneTS()

uint32_t EMAC_SendPktDoneTS | ( | uint32_t * | pu32Sec,
|  | uint32_t * | pu32Nsec
| ) |  |

Clean up process after a packet is sent, and get the time stamp while packet is sent.

Parameters

  [in] | pu32Sec | Second value while packet sent
  [in] | pu32Nsec | Nano second value while packet sent

Returns
  If a packet sent successfully

Return values

  0 | No packet sent successfully, and the value in *pu32Sec and *pu32Nsec are meaningless
  1 | A packet sent successfully, and the value in *pu32Sec and *pu32Nsec is the time stamp while packet sent

EMAC Tx interrupt service routine must call this API or EMAC_SendPktDone to release the resource use by transmit process

Definition at line 769 of file emac.c.

## ◆ EMAC_SendPktWoCopy()

uint32_t EMAC_SendPktWoCopy | ( | uint32_t | u32Size | ) |

Send an Ethernet packet.

Parameters

  [in] | u32Size | Packet size (without 4 byte CRC).

Returns
  Packet transmit success or not

Return values

  0 | Transmit failed due to descriptor unavailable.
  1 | Triggered to transmit.

Note
  Return 1 doesn't guarantee the packet will be sent and received successfully.

Definition at line 1062 of file emac.c.

## ◆ EMAC_SetMacAddr()

void EMAC_SetMacAddr | ( | uint8_t * | pu8MacAddr | ) |

Set the device MAC address.

Parameters

  [in] | pu8MacAddr | Pointer to uint8_t array holds MAC address

Returns
  None

Definition at line 432 of file emac.c.

## ◆ EMAC_SetTime()

void EMAC_SetTime | ( | uint32_t | u32Sec,
|  | uint32_t | u32Nsec
| ) |  |

Set current time stamp.

Parameters

  [in] | u32Sec | Second value
  [in] | u32Nsec | Nano second value

Returns
  None

Definition at line 896 of file emac.c.

## ◆ EMAC_UpdateTime()

void EMAC_UpdateTime | ( | uint32_t | u32Neg,
|  | uint32_t | u32Sec,
|  | uint32_t | u32Nsec
| ) |  |

Add a offset to current time.

Parameters

  [in] | u32Neg | Offset is negative value (u32Neg == 1) or positive value (u32Neg == 0).
  [in] | u32Sec | Second value to add to current time
  [in] | u32Nsec | Nano second value to add to current time

Returns
  None

Definition at line 940 of file emac.c.