| NUC472_NUC442_BSP V3.03.003 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
16 extern "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
43 extern 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);
163 void EMAC_Close(void);
164 void EMAC_SetMacAddr(uint8_t *pu8MacAddr);
165 void EMAC_EnableCamEntry(uint32_t u32Entry, uint8_t *pu8MacAddr);
166 void 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);
170 void 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
176 void EMAC_EnableTS(uint32_t u32Sec, uint32_t u32Nsec);
177 void EMAC_DisableTS(void);
178 void EMAC_GetTime(uint32_t *pu32Sec, uint32_t *pu32Nsec);
179 void EMAC_SetTime(uint32_t u32Sec, uint32_t u32Nsec);
180 void EMAC_UpdateTime(uint32_t u32Neg, uint32_t u32Sec, uint32_t u32Nsec);
181 void EMAC_EnableAlarm(uint32_t u32Sec, uint32_t u32Nsec);
182 void 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:909
EMAC_DisableTS
void EMAC_DisableTS(void)
Disable IEEE1588 time stamp function.
Definition: emac.c:885
EMAC_DisableAlarm
void EMAC_DisableAlarm(void)
Disable alarm function.
Definition: emac.c:939
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:789
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:643
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:717
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:581
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:896
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:676
EMAC_UpdateTime
void EMAC_UpdateTime(uint32_t u32Neg, uint32_t u32Sec, uint32_t u32Nsec)
Add a offset to current time.
Definition: emac.c:953
EMAC_EnableAlarm
void EMAC_EnableAlarm(uint32_t u32Sec, uint32_t u32Nsec)
Enable alarm function and set alarm time.
Definition: emac.c:925
EMAC_EnableTS
void EMAC_EnableTS(uint32_t u32Sec, uint32_t u32Nsec)
Enable IEEE1588 time stamp function and set current time.
Definition: emac.c:857