| NUC472_NUC442_BSP V3.04.000 The Board Support Package for NUC472/NUC442

emac.h
Go to the documentation of this file.
1/**************************************************************************/
12#ifndef __EMAC_H__
13#define __EMAC_H__
14
15#ifdef __cplusplus
16extern "C"
17{
18#endif
19
20
33#define EMAC_PHY_ADDR 1
34
35#define EMAC_RX_DESC_SIZE 4
36#define EMAC_TX_DESC_SIZE 4
37
38#define EMAC_TIMEOUT_ERR (-1L)
39#define EMAC_BUS_ERR (-2L) /* end of group NUC472_442_EMAC_EXPORTED_CONSTANTS */
42
43extern int32_t g_EMAC_i32ErrCode;
44
56#define EMAC_ENABLE_TX() (EMAC->CTL |= EMAC_CTL_TXON_Msk)
57
58
65#define EMAC_ENABLE_RX() do{EMAC->CTL |= EMAC_CTL_RXON_Msk; EMAC->RXST = 0;}while(0)
66
73#define EMAC_DISABLE_TX() (EMAC->CTL &= ~EMAC_CTL_TXON_Msk)
74
75
82#define EMAC_DISABLE_RX() (EMAC->CTL &= ~EMAC_CTL_RXON_Msk)
83
90#define EMAC_ENABLE_MAGIC_PKT_WAKEUP() (EMAC->CTL |= EMAC_CTL_WOLEN_Msk)
91
92
99#define EMAC_DISABLE_MAGIC_PKT_WAKEUP() (EMAC->CTL &= ~EMAC_CTL_WOLEN_Msk)
100
109#define EMAC_ENABLE_MII_INTF() (EMAC->CTL &= ~(EMAC_CTL_RMIIEN_Msk | EMAC_CTL_RMIIRXCTL_Msk))
110
117#define EMAC_ENABLE_RECV_BCASTPKT() (EMAC->CAMCTL |= EMAC_CAMCTL_ABP_Msk)
118
125#define EMAC_DISABLE_RECV_BCASTPKT() (EMAC->CAMCTL &= ~EMAC_CAMCTL_ABP_Msk)
126
133#define EMAC_ENABLE_RECV_MCASTPKT() (EMAC->CAMCTL |= EMAC_CAMCTL_AMP_Msk)
134
141#define EMAC_DISABLE_RECV_MCASTPKT() (EMAC->CAMCTL &= ~EMAC_CAMCTL_AMP_Msk)
142
151#define EMAC_GET_ALARM_FLAG() (EMAC->INTSTS & EMAC_INTSTS_TSALMIF_Msk ? 1 : 0)
152
159#define EMAC_CLR_ALARM_FLAG() (EMAC->INTSTS = EMAC_INTSTS_TSALMIF_Msk)
160
161
162int32_t EMAC_Open(uint8_t *pu8MacAddr);
163void EMAC_Close(void);
164void EMAC_SetMacAddr(uint8_t *pu8MacAddr);
165void EMAC_EnableCamEntry(uint32_t u32Entry, uint8_t *pu8MacAddr);
166void EMAC_DisableCamEntry(uint32_t u32Entry);
167
168uint32_t EMAC_RecvPkt(uint8_t *pu8Data, uint32_t *pu32Size);
169uint32_t EMAC_RecvPktTS(uint8_t *pu8Data, uint32_t *pu32Size, uint32_t *pu32Sec, uint32_t *pu32Nsec);
170void EMAC_RecvPktDone(void);
171
172uint32_t EMAC_SendPkt(uint8_t *pu8Data, uint32_t u32Size);
173uint32_t EMAC_SendPktDone(void);
174uint32_t EMAC_SendPktDoneTS(uint32_t *pu32Sec, uint32_t *pu32Nsec);
175
176void EMAC_EnableTS(uint32_t u32Sec, uint32_t u32Nsec);
177void EMAC_DisableTS(void);
178void EMAC_GetTime(uint32_t *pu32Sec, uint32_t *pu32Nsec);
179void EMAC_SetTime(uint32_t u32Sec, uint32_t u32Nsec);
180void EMAC_UpdateTime(uint32_t u32Neg, uint32_t u32Sec, uint32_t u32Nsec);
181void EMAC_EnableAlarm(uint32_t u32Sec, uint32_t u32Nsec);
182void EMAC_DisableAlarm(void);
183
184
185 /* end of group NUC472_442_EMAC_EXPORTED_FUNCTIONS */
187 /* end of group NUC472_442_EMAC_Driver */
189 /* end of group NUC472_442_Device_Driver */
191
192#ifdef __cplusplus
193}
194#endif
195
196#endif //__EMAC_H__
197
198/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/
g_EMAC_i32ErrCode
int32_t g_EMAC_i32ErrCode
Definition: emac.c:24
EMAC_SetTime
void EMAC_SetTime(uint32_t u32Sec, uint32_t u32Nsec)
Set current time stamp.
Definition: emac.c:929
EMAC_DisableTS
void EMAC_DisableTS(void)
Disable IEEE1588 time stamp function.
Definition: emac.c:905
EMAC_DisableAlarm
void EMAC_DisableAlarm(void)
Disable alarm function.
Definition: emac.c:959
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.
Definition: emac.c:802
EMAC_Close
void EMAC_Close(void)
This function stop all receive and transmit activity and disable MAC interface.
Definition: emac.c:456
EMAC_RecvPktDone
void EMAC_RecvPktDone(void)
Clean up process after a packet is received.
Definition: emac.c:649
EMAC_EnableCamEntry
void EMAC_EnableCamEntry(uint32_t u32Entry, uint8_t *pu8MacAddr)
Fill a CAM entry for MAC address comparison.
Definition: emac.c:478
EMAC_DisableCamEntry
void EMAC_DisableCamEntry(uint32_t u32Entry)
Disable a specified CAM entry.
Definition: emac.c:500
EMAC_SendPktDone
uint32_t EMAC_SendPktDone(void)
Clean up process after packet(s) are sent.
Definition: emac.c:723
EMAC_SetMacAddr
void EMAC_SetMacAddr(uint8_t *pu8MacAddr)
Set the device MAC address.
Definition: emac.c:466
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.
Definition: emac.c:584
EMAC_Open
int32_t EMAC_Open(uint8_t *pu8MacAddr)
Initialize EMAC interface, including descriptors, MAC address, and PHY.
Definition: emac.c:417
EMAC_GetTime
void EMAC_GetTime(uint32_t *pu32Sec, uint32_t *pu32Nsec)
Get current time stamp.
Definition: emac.c:916
EMAC_RecvPkt
uint32_t EMAC_RecvPkt(uint8_t *pu8Data, uint32_t *pu32Size)
Receive an Ethernet packet.
Definition: emac.c:516
EMAC_SendPkt
uint32_t EMAC_SendPkt(uint8_t *pu8Data, uint32_t u32Size)
Send an Ethernet packet.
Definition: emac.c:682
EMAC_UpdateTime
void EMAC_UpdateTime(uint32_t u32Neg, uint32_t u32Sec, uint32_t u32Nsec)
Add a offset to current time.
Definition: emac.c:973
EMAC_EnableAlarm
void EMAC_EnableAlarm(uint32_t u32Sec, uint32_t u32Nsec)
Enable alarm function and set alarm time.
Definition: emac.c:945
EMAC_EnableTS
void EMAC_EnableTS(uint32_t u32Sec, uint32_t u32Nsec)
Enable IEEE1588 time stamp function and set current time.
Definition: emac.c:877