mikroSDK Reference Manual
gd32f3xx_eth_driver.h
Go to the documentation of this file.
1
31#ifndef _GD32F3XX_ETH_DRIVER_H
32#define _GD32F3XX_ETH_DRIVER_H
33
34//Dependencies
35#include "core/nic.h"
36
37//Number of TX buffers
38#ifndef GD32F3XX_ETH_TX_BUFFER_COUNT
39 #define GD32F3XX_ETH_TX_BUFFER_COUNT 3
40#elif (GD32F3XX_ETH_TX_BUFFER_COUNT < 1)
41 #error GD32F3XX_ETH_TX_BUFFER_COUNT parameter is not valid
42#endif
43
44//TX buffer size
45#ifndef GD32F3XX_ETH_TX_BUFFER_SIZE
46 #define GD32F3XX_ETH_TX_BUFFER_SIZE 1536
47#elif (GD32F3XX_ETH_TX_BUFFER_SIZE != 1536)
48 #error GD32F3XX_ETH_TX_BUFFER_SIZE parameter is not valid
49#endif
50
51//Number of RX buffers
52#ifndef GD32F3XX_ETH_RX_BUFFER_COUNT
53 #define GD32F3XX_ETH_RX_BUFFER_COUNT 6
54#elif (GD32F3XX_ETH_RX_BUFFER_COUNT < 1)
55 #error GD32F3XX_ETH_RX_BUFFER_COUNT parameter is not valid
56#endif
57
58//RX buffer size
59#ifndef GD32F3XX_ETH_RX_BUFFER_SIZE
60 #define GD32F3XX_ETH_RX_BUFFER_SIZE 1536
61#elif (GD32F3XX_ETH_RX_BUFFER_SIZE != 1536)
62 #error GD32F3XX_ETH_RX_BUFFER_SIZE parameter is not valid
63#endif
64
65//Interrupt priority grouping
66#ifndef GD32F3XX_ETH_IRQ_PRIORITY_GROUPING
67 #define GD32F3XX_ETH_IRQ_PRIORITY_GROUPING 3
68#elif (GD32F3XX_ETH_IRQ_PRIORITY_GROUPING < 0)
69 #error GD32F3XX_ETH_IRQ_PRIORITY_GROUPING parameter is not valid
70#endif
71
72//Ethernet interrupt group priority
73#ifndef GD32F3XX_ETH_IRQ_GROUP_PRIORITY
74 #define GD32F3XX_ETH_IRQ_GROUP_PRIORITY 12
75#elif (GD32F3XX_ETH_IRQ_GROUP_PRIORITY < 0)
76 #error GD32F3XX_ETH_IRQ_GROUP_PRIORITY parameter is not valid
77#endif
78
79//Ethernet interrupt subpriority
80#ifndef GD32F3XX_ETH_IRQ_SUB_PRIORITY
81 #define GD32F3XX_ETH_IRQ_SUB_PRIORITY 0
82#elif (GD32F3XX_ETH_IRQ_SUB_PRIORITY < 0)
83 #error GD32F3XX_ETH_IRQ_SUB_PRIORITY parameter is not valid
84#endif
85
86//C++ guard
87#ifdef __cplusplus
88extern "C" {
89#endif
90
91
96typedef struct
97{
98 uint32_t tdes0;
99 uint32_t tdes1;
100 uint32_t tdes2;
101 uint32_t tdes3;
102 uint32_t tdes4;
103 uint32_t tdes5;
104 uint32_t tdes6;
105 uint32_t tdes7;
107
108
113typedef struct
114{
115 uint32_t rdes0;
116 uint32_t rdes1;
117 uint32_t rdes2;
118 uint32_t rdes3;
119 uint32_t rdes4;
120 uint32_t rdes5;
121 uint32_t rdes6;
122 uint32_t rdes7;
124
125
126//GD32F3XX Ethernet MAC driver
127extern const NicDriver gd32f3xxEthDriver;
128
129//GD32F3XX Ethernet MAC related functions
130error_t gd32f3xxEthInit(NetInterface *interface);
131void gd32f3xxEthInitGpio(NetInterface *interface);
132void gd32f3xxEthInitDmaDesc(NetInterface *interface);
133
134void gd32f3xxEthTick(NetInterface *interface);
135
136void gd32f3xxEthEnableIrq(NetInterface *interface);
137void gd32f3xxEthDisableIrq(NetInterface *interface);
138void gd32f3xxEthEventHandler(NetInterface *interface);
139
140error_t gd32f3xxEthSendPacket(NetInterface *interface,
141 const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary);
142
143error_t gd32f3xxEthReceivePacket(NetInterface *interface);
144
145error_t gd32f3xxEthUpdateMacAddrFilter(NetInterface *interface);
146error_t gd32f3xxEthUpdateMacConfig(NetInterface *interface);
147
148void gd32f3xxEthWritePhyReg(uint8_t opcode, uint8_t phyAddr,
149 uint8_t regAddr, uint16_t data);
150
151uint16_t gd32f3xxEthReadPhyReg(uint8_t opcode, uint8_t phyAddr,
152 uint8_t regAddr);
153
154uint32_t gd32f3xxEthCalcCrc(const void *data, size_t length);
155
156//C++ guard
157#ifdef __cplusplus
158}
159#endif
160
161#endif
error_t
Error codes.
Definition error.h:43
Network interface controller abstraction layer.
Enhanced RX DMA descriptor.
Definition gd32f3xx_eth_driver.h:114
Enhanced TX DMA descriptor.
Definition gd32f3xx_eth_driver.h:97
Structure describing a buffer that spans multiple chunks.
Definition net_mem.h:89
NIC driver.
Definition nic.h:283