31#ifndef _AT32F4XX_ETH_DRIVER_H
32#define _AT32F4XX_ETH_DRIVER_H
38#ifndef AT32F4XX_ETH_TX_BUFFER_COUNT
39 #define AT32F4XX_ETH_TX_BUFFER_COUNT 3
40#elif (AT32F4XX_ETH_TX_BUFFER_COUNT < 1)
41 #error AT32F4XX_ETH_TX_BUFFER_COUNT parameter is not valid
45#ifndef AT32F4XX_ETH_TX_BUFFER_SIZE
46 #define AT32F4XX_ETH_TX_BUFFER_SIZE 1536
47#elif (AT32F4XX_ETH_TX_BUFFER_SIZE != 1536)
48 #error AT32F4XX_ETH_TX_BUFFER_SIZE parameter is not valid
52#ifndef AT32F4XX_ETH_RX_BUFFER_COUNT
53 #define AT32F4XX_ETH_RX_BUFFER_COUNT 6
54#elif (AT32F4XX_ETH_RX_BUFFER_COUNT < 1)
55 #error AT32F4XX_ETH_RX_BUFFER_COUNT parameter is not valid
59#ifndef AT32F4XX_ETH_RX_BUFFER_SIZE
60 #define AT32F4XX_ETH_RX_BUFFER_SIZE 1536
61#elif (AT32F4XX_ETH_RX_BUFFER_SIZE != 1536)
62 #error AT32F4XX_ETH_RX_BUFFER_SIZE parameter is not valid
66#ifndef AT32F4XX_ETH_IRQ_PRIORITY_GROUPING
67 #define AT32F4XX_ETH_IRQ_PRIORITY_GROUPING 3
68#elif (AT32F4XX_ETH_IRQ_PRIORITY_GROUPING < 0)
69 #error AT32F4XX_ETH_IRQ_PRIORITY_GROUPING parameter is not valid
73#ifndef AT32F4XX_ETH_IRQ_GROUP_PRIORITY
74 #define AT32F4XX_ETH_IRQ_GROUP_PRIORITY 12
75#elif (AT32F4XX_ETH_IRQ_GROUP_PRIORITY < 0)
76 #error AT32F4XX_ETH_IRQ_GROUP_PRIORITY parameter is not valid
80#ifndef AT32F4XX_ETH_IRQ_SUB_PRIORITY
81 #define AT32F4XX_ETH_IRQ_SUB_PRIORITY 0
82#elif (AT32F4XX_ETH_IRQ_SUB_PRIORITY < 0)
83 #error AT32F4XX_ETH_IRQ_SUB_PRIORITY parameter is not valid
87#define EMAC_CTRL_WD 0x00800000
88#define EMAC_CTRL_JD 0x00400000
89#define EMAC_CTRL_IFG 0x000E0000
90#define EMAC_CTRL_DCS 0x00010000
91#define EMAC_CTRL_RESERVED15 0x00008000
92#define EMAC_CTRL_FES 0x00004000
93#define EMAC_CTRL_DRO 0x00002000
94#define EMAC_CTRL_LM 0x00001000
95#define EMAC_CTRL_DM 0x00000800
96#define EMAC_CTRL_IPC 0x00000400
97#define EMAC_CTRL_DR 0x00000200
98#define EMAC_CTRL_ACS 0x00000080
99#define EMAC_CTRL_BL 0x00000060
100#define EMAC_CTRL_DC 0x00000010
101#define EMAC_CTRL_TE 0x00000008
102#define EMAC_CTRL_RE 0x00000004
105#define EMAC_FRMF_RA 0x80000000
106#define EMAC_FRMF_HPF 0x00000400
107#define EMAC_FRMF_SAF 0x00000200
108#define EMAC_FRMF_SAIF 0x00000100
109#define EMAC_FRMF_PCF 0x000000C0
110#define EMAC_FRMF_DBF 0x00000020
111#define EMAC_FRMF_PMC 0x00000010
112#define EMAC_FRMF_DAIF 0x00000008
113#define EMAC_FRMF_HMC 0x00000004
114#define EMAC_FRMF_HUC 0x00000002
115#define EMAC_FRMF_PR 0x00000001
118#define EMAC_MIIADDR_PA 0x0000F800
119#define EMAC_MIIADDR_MII 0x000007C0
120#define EMAC_MIIADDR_CR 0x0000003C
121#define EMAC_MIIADDR_CR_DIV_42 0x00000000
122#define EMAC_MIIADDR_CR_DIV_62 0x00000004
123#define EMAC_MIIADDR_CR_DIV_16 0x00000008
124#define EMAC_MIIADDR_CR_DIV_26 0x0000000C
125#define EMAC_MIIADDR_CR_DIV_102 0x00000010
126#define EMAC_MIIADDR_CR_DIV_124 0x00000014
127#define EMAC_MIIADDR_MW 0x00000002
128#define EMAC_MIIADDR_MB 0x00000001
131#define EMAC_MIIDT_MD 0x0000FFFF
134#define EMAC_IMR_TIM 0x00000200
135#define EMAC_IMR_PIM 0x00000008
138#define EMAC_A0H_AE 0x80000000
139#define EMAC_A0H_MA0H 0x0000FFFF
142#define EMAC_A1H_AE 0x80000000
143#define EMAC_A1H_SA 0x40000000
144#define EMAC_A1H_MBC 0x3F000000
145#define EMAC_A1H_MA1H 0x0000FFFF
148#define EMAC_A2H_AE 0x80000000
149#define EMAC_A2H_SA 0x40000000
150#define EMAC_A2H_MBC 0x3F000000
151#define EMAC_A2H_MA2H 0x0000FFFF
154#define EMAC_A3H_AE 0x80000000
155#define EMAC_A3H_SA 0x40000000
156#define EMAC_A3H_MBC 0x3F000000
157#define EMAC_A3H_MA3H 0x0000FFFF
160#define EMAC_MMC_RIM_RUGFCIM 0x00020000
161#define EMAC_MMC_RIM_RAEFACIM 0x00000040
162#define EMAC_MMC_RIM_RCEFCIM 0x00000020
165#define EMAC_MMC_TIM_TGFCIM 0x00200000
166#define EMAC_MMC_TIM_TMCGFCIM 0x00008000
167#define EMAC_MMC_TIM_TSCGFCIM 0x00004000
170#define EMAC_DMA_BM_AAB 0x02000000
171#define EMAC_DMA_BM_PBLX8 0x01000000
172#define EMAC_DMA_BM_USP 0x00800000
173#define EMAC_DMA_BM_RDP 0x007E0000
174#define EMAC_DMA_BM_RDP_1 0x00020000
175#define EMAC_DMA_BM_RDP_2 0x00040000
176#define EMAC_DMA_BM_RDP_4 0x00080000
177#define EMAC_DMA_BM_RDP_8 0x00100000
178#define EMAC_DMA_BM_RDP_16 0x00200000
179#define EMAC_DMA_BM_RDP_32 0x00400000
180#define EMAC_DMA_BM_FB 0x00010000
181#define EMAC_DMA_BM_PR 0x0000C000
182#define EMAC_DMA_BM_PR_1_1 0x00000000
183#define EMAC_DMA_BM_PR_2_1 0x00004000
184#define EMAC_DMA_BM_PR_3_1 0x00008000
185#define EMAC_DMA_BM_PR_4_1 0x0000C000
186#define EMAC_DMA_BM_PBL 0x00003F00
187#define EMAC_DMA_BM_PBL_1 0x00000100
188#define EMAC_DMA_BM_PBL_2 0x00000200
189#define EMAC_DMA_BM_PBL_4 0x00000400
190#define EMAC_DMA_BM_PBL_8 0x00000800
191#define EMAC_DMA_BM_PBL_16 0x00001000
192#define EMAC_DMA_BM_PBL_32 0x00002000
193#define EMAC_DMA_BM_DSL 0x0000007C
194#define EMAC_DMA_BM_DSL_0 0x00000000
195#define EMAC_DMA_BM_DSL_1 0x00000004
196#define EMAC_DMA_BM_DSL_2 0x00000008
197#define EMAC_DMA_BM_DSL_4 0x00000010
198#define EMAC_DMA_BM_DSL_8 0x00000020
199#define EMAC_DMA_BM_DSL_16 0x00000040
200#define EMAC_DMA_BM_DA 0x00000002
201#define EMAC_DMA_BM_SWR 0x00000001
204#define EMAC_DMA_STS_TTI 0x20000000
205#define EMAC_DMA_STS_MPI 0x10000000
206#define EMAC_DMA_STS_MMI 0x08000000
207#define EMAC_DMA_STS_EB 0x03800000
208#define EMAC_DMA_STS_TS 0x00700000
209#define EMAC_DMA_STS_RS 0x000E0000
210#define EMAC_DMA_STS_NIS 0x00010000
211#define EMAC_DMA_STS_AIS 0x00008000
212#define EMAC_DMA_STS_ERI 0x00004000
213#define EMAC_DMA_STS_BEI 0x00002000
214#define EMAC_DMA_STS_ETI 0x00000400
215#define EMAC_DMA_STS_RWT 0x00000200
216#define EMAC_DMA_STS_RPS 0x00000100
217#define EMAC_DMA_STS_RBU 0x00000080
218#define EMAC_DMA_STS_RI 0x00000040
219#define EMAC_DMA_STS_UNF 0x00000020
220#define EMAC_DMA_STS_OVF 0x00000010
221#define EMAC_DMA_STS_TJT 0x00000008
222#define EMAC_DMA_STS_TBU 0x00000004
223#define EMAC_DMA_STS_TPS 0x00000002
224#define EMAC_DMA_STS_TI 0x00000001
227#define EMAC_DMA_OPM_DT 0x04000000
228#define EMAC_DMA_OPM_RSF 0x02000000
229#define EMAC_DMA_OPM_DFRF 0x01000000
230#define EMAC_DMA_OPM_TSF 0x00200000
231#define EMAC_DMA_OPM_FTF 0x00100000
232#define EMAC_DMA_OPM_TTC 0x0001C000
233#define EMAC_DMA_OPM_SSTC 0x00002000
234#define EMAC_DMA_OPM_FEF 0x00000080
235#define EMAC_DMA_OPM_FUGF 0x00000040
236#define EMAC_DMA_OPM_RTC 0x00000018
237#define EMAC_DMA_OPM_OSF 0x00000004
238#define EMAC_DMA_OPM_SSR 0x00000002
241#define EMAC_DMA_IE_NIE 0x00010000
242#define EMAC_DMA_IE_AIE 0x00008000
243#define EMAC_DMA_IE_ERE 0x00004000
244#define EMAC_DMA_IE_FBEE 0x00002000
245#define EMAC_DMA_IE_EIE 0x00000400
246#define EMAC_DMA_IE_RWTE 0x00000200
247#define EMAC_DMA_IE_RSE 0x00000100
248#define EMAC_DMA_IE_RBUE 0x00000080
249#define EMAC_DMA_IE_RIE 0x00000040
250#define EMAC_DMA_IE_UNE 0x00000020
251#define EMAC_DMA_IE_OVE 0x00000010
252#define EMAC_DMA_IE_TJE 0x00000008
253#define EMAC_DMA_IE_TUE 0x00000004
254#define EMAC_DMA_IE_TSE 0x00000002
255#define EMAC_DMA_IE_TIE 0x00000001
258#define EMAC_TDES0_OWN 0x80000000
259#define EMAC_TDES0_IC 0x40000000
260#define EMAC_TDES0_LS 0x20000000
261#define EMAC_TDES0_FS 0x10000000
262#define EMAC_TDES0_DC 0x08000000
263#define EMAC_TDES0_DP 0x04000000
264#define EMAC_TDES0_TTSE 0x02000000
265#define EMAC_TDES0_CIC 0x00C00000
266#define EMAC_TDES0_TER 0x00200000
267#define EMAC_TDES0_TCH 0x00100000
268#define EMAC_TDES0_TTSS 0x00020000
269#define EMAC_TDES0_IHE 0x00010000
270#define EMAC_TDES0_ES 0x00008000
271#define EMAC_TDES0_JT 0x00004000
272#define EMAC_TDES0_FF 0x00002000
273#define EMAC_TDES0_IPE 0x00001000
274#define EMAC_TDES0_LOC 0x00000800
275#define EMAC_TDES0_NC 0x00000400
276#define EMAC_TDES0_LC 0x00000200
277#define EMAC_TDES0_EC 0x00000100
278#define EMAC_TDES0_VF 0x00000080
279#define EMAC_TDES0_CC 0x00000078
280#define EMAC_TDES0_ED 0x00000004
281#define EMAC_TDES0_UF 0x00000002
282#define EMAC_TDES0_DB 0x00000001
283#define EMAC_TDES1_TBS2 0x1FFF0000
284#define EMAC_TDES1_TBS1 0x00001FFF
285#define EMAC_TDES2_TBAP1 0xFFFFFFFF
286#define EMAC_TDES3_TBAP2 0xFFFFFFFF
289#define EMAC_RDES0_OWN 0x80000000
290#define EMAC_RDES0_AFM 0x40000000
291#define EMAC_RDES0_FL 0x3FFF0000
292#define EMAC_RDES0_ES 0x00008000
293#define EMAC_RDES0_DE 0x00004000
294#define EMAC_RDES0_SAF 0x00002000
295#define EMAC_RDES0_LE 0x00001000
296#define EMAC_RDES0_OE 0x00000800
297#define EMAC_RDES0_VLAN 0x00000400
298#define EMAC_RDES0_FS 0x00000200
299#define EMAC_RDES0_LS 0x00000100
300#define EMAC_RDES0_IPHCE 0x00000080
301#define EMAC_RDES0_LC 0x00000040
302#define EMAC_RDES0_FT 0x00000020
303#define EMAC_RDES0_RWT 0x00000010
304#define EMAC_RDES0_RE 0x00000008
305#define EMAC_RDES0_DBE 0x00000004
306#define EMAC_RDES0_CE 0x00000002
307#define EMAC_RDES0_PCE 0x00000001
308#define EMAC_RDES1_DIC 0x80000000
309#define EMAC_RDES1_RBS2 0x1FFF0000
310#define EMAC_RDES1_RER 0x00008000
311#define EMAC_RDES1_RCH 0x00004000
312#define EMAC_RDES1_RBS1 0x00001FFF
313#define EMAC_RDES2_RBAP1 0xFFFFFFFF
314#define EMAC_RDES3_RBAP2 0xFFFFFFFF
352error_t at32f4xxEthInit(NetInterface *interface);
353void at32f4xxEthInitGpio(NetInterface *interface);
354void at32f4xxEthInitDmaDesc(NetInterface *interface);
356void at32f4xxEthTick(NetInterface *interface);
358void at32f4xxEthEnableIrq(NetInterface *interface);
359void at32f4xxEthDisableIrq(NetInterface *interface);
360void at32f4xxEthEventHandler(NetInterface *interface);
362error_t at32f4xxEthSendPacket(NetInterface *interface,
363 const NetBuffer *buffer,
size_t offset, NetTxAncillary *ancillary);
365error_t at32f4xxEthReceivePacket(NetInterface *interface);
367error_t at32f4xxEthUpdateMacAddrFilter(NetInterface *interface);
368error_t at32f4xxEthUpdateMacConfig(NetInterface *interface);
370void at32f4xxEthWritePhyReg(uint8_t opcode, uint8_t phyAddr,
371 uint8_t regAddr, uint16_t data);
373uint16_t at32f4xxEthReadPhyReg(uint8_t opcode, uint8_t phyAddr,
376uint32_t at32f4xxEthCalcCrc(
const void *data,
size_t length);
error_t
Error codes.
Definition error.h:43
Network interface controller abstraction layer.
Enhanced RX DMA descriptor.
Definition at32f4xx_eth_driver.h:340
Enhanced TX DMA descriptor.
Definition at32f4xx_eth_driver.h:327
Structure describing a buffer that spans multiple chunks.
Definition net_mem.h:89
NIC driver.
Definition nic.h:283