NUC472_NUC442_BSP V3.03.005
The Board Support Package for NUC472/NUC442
Macros | Functions
Collaboration diagram for EMAC Exported Functions:

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_MII_INTF()
 Enable EMAC MII interface. 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...
 

Functions

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

Detailed Description

Macro Definition Documentation

◆ EMAC_CLR_ALARM_FLAG

#define EMAC_CLR_ALARM_FLAG ( )

Clear EMAC time stamp alarm interrupt flag.

Parameters
None
Returns
None

Definition at line 159 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 125 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 141 of file emac.h.

◆ EMAC_DISABLE_RX

#define EMAC_DISABLE_RX ( )

Disable EMAC Rx function.

Parameters
None
Returns
None

Definition at line 82 of file emac.h.

◆ EMAC_DISABLE_TX

#define EMAC_DISABLE_TX ( )

Disable EMAC Tx function.

Parameters
None
Returns
None

Definition at line 73 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 90 of file emac.h.

◆ EMAC_ENABLE_MII_INTF

#define EMAC_ENABLE_MII_INTF ( )

Enable EMAC MII interface.

Parameters
None
Returns
None

After calling EMAC_Open, EMAC use RMII interface by default, but can switch to MII interface by calling this macro

Definition at line 109 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 117 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 133 of file emac.h.

◆ EMAC_ENABLE_RX

#define EMAC_ENABLE_RX ( )

Enable EMAC Rx function.

Parameters
None
Returns
None

Definition at line 65 of file emac.h.

◆ EMAC_ENABLE_TX

#define EMAC_ENABLE_TX ( )

Enable EMAC Tx function.

Parameters
None
Returns
None

Definition at line 56 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
0Alarm interrupt does not occur
1Alarm interrupt occurred

Definition at line 151 of file emac.h.

Function Documentation

◆ 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 456 of file emac.c.

◆ EMAC_DisableAlarm()

void EMAC_DisableAlarm ( void  )

Disable alarm function.

Parameters
None
Returns
None

Definition at line 939 of file emac.c.

◆ EMAC_DisableCamEntry()

void EMAC_DisableCamEntry ( uint32_t  u32Entry)

Disable a specified CAM entry.

Parameters
[in]u32EntryCAM entry to be disabled
Returns
None

Definition at line 500 of file emac.c.

◆ EMAC_DisableTS()

void EMAC_DisableTS ( void  )

Disable IEEE1588 time stamp function.

Parameters
None
Returns
None

Definition at line 885 of file emac.c.

◆ EMAC_EnableAlarm()

void EMAC_EnableAlarm ( uint32_t  u32Sec,
uint32_t  u32Nsec 
)

Enable alarm function and set alarm time.

Parameters
[in]u32SecSecond value to trigger alarm
[in]u32NsecNano second value to trigger alarm
Returns
None

Definition at line 925 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]u32EntryMAC entry to fill. Entry 0 is used to store device MAC address, do not overwrite the setting in it.
[in]pu8MacAddrPointer to uint8_t array holds MAC address
Returns
None

Definition at line 478 of file emac.c.

Here is the caller graph for this function:

◆ EMAC_EnableTS()

void EMAC_EnableTS ( uint32_t  u32Sec,
uint32_t  u32Nsec 
)

Enable IEEE1588 time stamp function and set current time.

Parameters
[in]u32SecSecond value
[in]u32NsecNano second value
Returns
None

Definition at line 857 of file emac.c.

Here is the call graph for this function:

◆ EMAC_GetTime()

void EMAC_GetTime ( uint32_t *  pu32Sec,
uint32_t *  pu32Nsec 
)

Get current time stamp.

Parameters
[out]pu32SecCurrent second value
[out]pu32NsecCurrent nano second value
Returns
None

Definition at line 896 of file emac.c.

◆ EMAC_Open()

int32_t EMAC_Open ( uint8_t *  pu8MacAddr)

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

Parameters
[in]pu8MacAddrPointer to uint8_t array holds MAC address
Return values
0success
EMAC_TIMEOUT_ERRInitial PHY and auto-negotiation failed due to timeout error
Note
This API sets EMAC to work in RMII mode, but could configure to MII mode later with EMAC_ENABLE_MII_INTF macro
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 417 of file emac.c.

Here is the call graph for this function:

◆ EMAC_RecvPkt()

uint32_t EMAC_RecvPkt ( uint8_t *  pu8Data,
uint32_t *  pu32Size 
)

Receive an Ethernet packet.

Parameters
[in]pu8DataPointer to a buffer to store received packet (4 byte CRC removed)
[in]pu32SizeReceived packet size (without 4 byte CRC).
Returns
Packet receive success or not
Return values
0No packet available for receive
1A packet is received
EMAC_BUS_ERRBus error
Note
Return 0 doesn't guarantee the packet will be sent and received successfully.

Definition at line 516 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 643 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]pu8DataPointer to a buffer to store received packet (4 byte CRC removed)
[out]pu32SizeReceived packet size (without 4 byte CRC).
[out]pu32SecSecond value while packet sent
[out]pu32NsecNano second value while packet sent
Returns
Packet receive success or not
Return values
0No packet available for receive
1A packet is received
EMAC_BUS_ERRBus error
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 581 of file emac.c.

◆ EMAC_SendPkt()

uint32_t EMAC_SendPkt ( uint8_t *  pu8Data,
uint32_t  u32Size 
)

Send an Ethernet packet.

Parameters
[in]pu8DataPointer to a buffer holds the packet to transmit
[in]u32SizePacket size (without 4 byte CRC).
Returns
Packet transmit success or not
Return values
0Transmit failed due to descriptor unavailable.
1Packet 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 676 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
Return values
EMAC_BUS_ERRBus error
OtherwiseNumber 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 717 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]pu32SecSecond value while packet sent
[in]pu32NsecNano second value while packet sent
Returns
If a packet sent successfully
Return values
0No packet sent successfully, and the value in *pu32Sec and *pu32Nsec are meaningless
1A packet sent successfully, and the value in *pu32Sec and *pu32Nsec is the time stamp while packet sent
EMAC_BUS_ERRBus error

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

Definition at line 789 of file emac.c.

◆ EMAC_SetMacAddr()

void EMAC_SetMacAddr ( uint8_t *  pu8MacAddr)

Set the device MAC address.

Parameters
[in]pu8MacAddrPointer to uint8_t array holds MAC address
Returns
None

Definition at line 466 of file emac.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EMAC_SetTime()

void EMAC_SetTime ( uint32_t  u32Sec,
uint32_t  u32Nsec 
)

Set current time stamp.

Parameters
[in]u32SecSecond value
[in]u32NsecNano second value
Returns
None

Definition at line 909 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]u32NegOffset is negative value (u32Neg == 1) or positive value (u32Neg == 0).
[in]u32SecSecond value to add to current time
[in]u32NsecNano second value to add to current time
Returns
None

Definition at line 953 of file emac.c.