Go to the documentation of this file.
31 #ifndef _W5500_DRIVER_H
32 #define _W5500_DRIVER_H
38 #ifndef W5500_ETH_TX_BUFFER_SIZE
39 #define W5500_ETH_TX_BUFFER_SIZE 1536
40 #elif (W5500_ETH_TX_BUFFER_SIZE != 1536)
41 #error W5500_ETH_TX_BUFFER_SIZE parameter is not valid
45 #ifndef W5500_ETH_RX_BUFFER_SIZE
46 #define W5500_ETH_RX_BUFFER_SIZE 1536
47 #elif (W5500_ETH_RX_BUFFER_SIZE != 1536)
48 #error W5500_ETH_RX_BUFFER_SIZE parameter is not valid
52 #define W5500_CTRL_BSB 0xF8
53 #define W5500_CTRL_BSB_COMMON_REG 0x00
54 #define W5500_CTRL_BSB_S0_REG 0x08
55 #define W5500_CTRL_BSB_S0_TX_BUFFER 0x10
56 #define W5500_CTRL_BSB_S0_RX_BUFFER 0x18
57 #define W5500_CTRL_BSB_S1_REG 0x28
58 #define W5500_CTRL_BSB_S1_TX_BUFFER 0x30
59 #define W5500_CTRL_BSB_S1_RX_BUFFER 0x38
60 #define W5500_CTRL_BSB_S2_REG 0x48
61 #define W5500_CTRL_BSB_S2_TX_BUFFER 0x50
62 #define W5500_CTRL_BSB_S2_RX_BUFFER 0x58
63 #define W5500_CTRL_BSB_S3_REG 0x68
64 #define W5500_CTRL_BSB_S3_TX_BUFFER 0x70
65 #define W5500_CTRL_BSB_S3_RX_BUFFER 0x78
66 #define W5500_CTRL_BSB_S4_REG 0x88
67 #define W5500_CTRL_BSB_S4_TX_BUFFER 0x90
68 #define W5500_CTRL_BSB_S4_RX_BUFFER 0x98
69 #define W5500_CTRL_BSB_S5_REG 0xA8
70 #define W5500_CTRL_BSB_S5_TX_BUFFER 0xB0
71 #define W5500_CTRL_BSB_S5_RX_BUFFER 0xB8
72 #define W5500_CTRL_BSB_S6_REG 0xC8
73 #define W5500_CTRL_BSB_S6_TX_BUFFER 0xD0
74 #define W5500_CTRL_BSB_S6_RX_BUFFER 0xD8
75 #define W5500_CTRL_BSB_S7_REG 0xE8
76 #define W5500_CTRL_BSB_S7_TX_BUFFER 0xF0
77 #define W5500_CTRL_BSB_S7_RX_BUFFER 0xF8
78 #define W5500_CTRL_RWB 0x04
79 #define W5500_CTRL_RWB_READ 0x00
80 #define W5500_CTRL_RWB_WRITE 0x04
81 #define W5500_CTRL_OM 0x03
82 #define W5500_CTRL_OM_VDM 0x00
83 #define W5500_CTRL_OM_FDM1 0x01
84 #define W5500_CTRL_OM_FDM2 0x02
85 #define W5500_CTRL_OM_FDM4 0x03
89 #define W5500_GAR0 0x01
90 #define W5500_GAR1 0x01
91 #define W5500_GAR2 0x02
92 #define W5500_GAR3 0x03
93 #define W5500_SUBR0 0x05
94 #define W5500_SUBR1 0x06
95 #define W5500_SUBR2 0x07
96 #define W5500_SUBR3 0x08
97 #define W5500_SHAR0 0x09
98 #define W5500_SHAR1 0x0A
99 #define W5500_SHAR2 0x0B
100 #define W5500_SHAR3 0x0C
101 #define W5500_SHAR4 0x0D
102 #define W5500_SHAR5 0x0E
103 #define W5500_SIPR0 0x0F
104 #define W5500_SIPR1 0x10
105 #define W5500_SIPR2 0x11
106 #define W5500_SIPR3 0x12
107 #define W5500_INTLEVEL0 0x13
108 #define W5500_INTLEVEL1 0x14
109 #define W5500_IR 0x15
110 #define W5500_IMR 0x16
111 #define W5500_SIR 0x17
112 #define W5500_SIMR 0x18
113 #define W5500_RTR0 0x19
114 #define W5500_RTR1 0x1A
115 #define W5500_RCR 0x1B
116 #define W5500_PTIMER 0x1C
117 #define W5500_PMAGIC 0x1D
118 #define W5500_PHAR0 0x1E
119 #define W5500_PHAR1 0x1F
120 #define W5500_PHAR2 0x20
121 #define W5500_PHAR3 0x21
122 #define W5500_PHAR4 0x22
123 #define W5500_PHAR5 0x23
124 #define W5500_PSID0 0x24
125 #define W5500_PSID1 0x25
126 #define W5500_PMRU0 0x26
127 #define W5500_PMRU1 0x27
128 #define W5500_UIPR0 0x28
129 #define W5500_UIPR1 0x29
130 #define W5500_UIPR2 0x2A
131 #define W5500_UIPR3 0x2B
132 #define W5500_UPORTR0 0x2C
133 #define W5500_UPORTR1 0x2D
134 #define W5500_PHYCFGR 0x2E
135 #define W5500_VERSIONR 0x39
138 #define W5500_Sn_MR 0x00
139 #define W5500_Sn_CR 0x01
140 #define W5500_Sn_IR 0x02
141 #define W5500_Sn_SR 0x03
142 #define W5500_Sn_PORT0 0x04
143 #define W5500_Sn_PORT1 0x05
144 #define W5500_Sn_DHAR0 0x06
145 #define W5500_Sn_DHAR1 0x07
146 #define W5500_Sn_DHAR2 0x08
147 #define W5500_Sn_DHAR3 0x09
148 #define W5500_Sn_DHAR4 0x0A
149 #define W5500_Sn_DHAR5 0x0B
150 #define W5500_Sn_DIPR0 0x0C
151 #define W5500_Sn_DIPR1 0x0D
152 #define W5500_Sn_DIPR2 0x0E
153 #define W5500_Sn_DIPR3 0x0F
154 #define W5500_Sn_DPORT0 0x10
155 #define W5500_Sn_DPORT1 0x11
156 #define W5500_Sn_MSSR0 0x12
157 #define W5500_Sn_MSSR1 0x13
158 #define W5500_Sn_TOS 0x15
159 #define W5500_Sn_TTL 0x16
160 #define W5500_Sn_RXBUF_SIZE 0x1E
161 #define W5500_Sn_TXBUF_SIZE 0x1F
162 #define W5500_Sn_TX_FSR0 0x20
163 #define W5500_Sn_TX_FSR1 0x21
164 #define W5500_Sn_TX_RD0 0x22
165 #define W5500_Sn_TX_RD1 0x23
166 #define W5500_Sn_TX_WR0 0x24
167 #define W5500_Sn_TX_WR1 0x25
168 #define W5500_Sn_RX_RSR0 0x26
169 #define W5500_Sn_RX_RSR1 0x27
170 #define W5500_Sn_RX_RD0 0x28
171 #define W5500_Sn_RX_RD1 0x29
172 #define W5500_Sn_RX_WR0 0x2A
173 #define W5500_Sn_RX_WR1 0x2B
174 #define W5500_Sn_IMR 0x2C
175 #define W5500_Sn_FRAG0 0x2D
176 #define W5500_Sn_FRAG1 0x2E
177 #define W5500_Sn_KPALVTR 0x2F
180 #define W5500_MR_RST 0x80
181 #define W5500_MR_WOL 0x20
182 #define W5500_MR_PB 0x10
183 #define W5500_MR_PPPOE 0x08
184 #define W5500_MR_FARP 0x02
187 #define W5500_IR_CONFLICT 0x80
188 #define W5500_IR_UNREACH 0x40
189 #define W5500_IR_PPPOE 0x20
190 #define W5500_IR_MP 0x10
193 #define W5500_IMR_CONFLICT 0x80
194 #define W5500_IMR_UNREACH 0x40
195 #define W5500_IMR_PPPOE 0x20
196 #define W5500_IMR_MP 0x10
199 #define W5500_SIR_S7_INT 0x80
200 #define W5500_SIR_S6_INT 0x40
201 #define W5500_SIR_S5_INT 0x20
202 #define W5500_SIR_S4_INT 0x10
203 #define W5500_SIR_S3_INT 0x08
204 #define W5500_SIR_S2_INT 0x04
205 #define W5500_SIR_S1_INT 0x02
206 #define W5500_SIR_S0_INT 0x01
209 #define W5500_SIMR_S7_IMR 0x80
210 #define W5500_SIMR_S6_IMR 0x40
211 #define W5500_SIMR_S5_IMR 0x20
212 #define W5500_SIMR_S4_IMR 0x10
213 #define W5500_SIMR_S3_IMR 0x08
214 #define W5500_SIMR_S2_IMR 0x04
215 #define W5500_SIMR_S1_IMR 0x02
216 #define W5500_SIMR_S0_IMR 0x01
219 #define W5500_PHYCFGR_RST 0x80
220 #define W5500_PHYCFGR_OPMD 0x40
221 #define W5500_PHYCFGR_OPMDC 0x38
222 #define W5500_PHYCFGR_OPMDC_10BT_HD 0x00
223 #define W5500_PHYCFGR_OPMDC_10BT_FD 0x08
224 #define W5500_PHYCFGR_OPMDC_100BT_HD 0x10
225 #define W5500_PHYCFGR_OPMDC_100BT_FD 0x18
226 #define W5500_PHYCFGR_OPMDC_100BT_HD_AN 0x20
227 #define W5500_PHYCFGR_OPMDC_PD 0x30
228 #define W5500_PHYCFGR_OPMDC_ALL_AN 0x38
229 #define W5500_PHYCFGR_DPX 0x04
230 #define W5500_PHYCFGR_SPD 0x02
231 #define W5500_PHYCFGR_LNK 0x01
234 #define W5500_VERSIONR_DEFAULT 0x04
237 #define W5500_Sn_MR_MULTI 0x80
238 #define W5500_Sn_MR_MFEN 0x80
239 #define W5500_Sn_MR_BCASTB 0x40
240 #define W5500_Sn_MR_ND 0x20
241 #define W5500_Sn_MR_MC 0x20
242 #define W5500_Sn_MR_MMB 0x20
243 #define W5500_Sn_MR_UCASTB 0x10
244 #define W5500_Sn_MR_MIP6B 0x10
245 #define W5500_Sn_MR_PROTOCOL 0x0F
246 #define W5500_Sn_MR_PROTOCOL_CLOSED 0x00
247 #define W5500_Sn_MR_PROTOCOL_TCP 0x01
248 #define W5500_Sn_MR_PROTOCOL_UDP 0x02
249 #define W5500_Sn_MR_PROTOCOL_MACRAW 0x04
252 #define W5500_Sn_CR_OPEN 0x01
253 #define W5500_Sn_CR_LISTEN 0x02
254 #define W5500_Sn_CR_CONNECT 0x04
255 #define W5500_Sn_CR_DISCON 0x08
256 #define W5500_Sn_CR_CLOSE 0x10
257 #define W5500_Sn_CR_SEND 0x20
258 #define W5500_Sn_CR_SEND_MAC 0x21
259 #define W5500_Sn_CR_SEND_KEEP 0x22
260 #define W5500_Sn_CR_RECV 0x40
263 #define W5500_Sn_IR_SEND_OK 0x10
264 #define W5500_Sn_IR_TIMEOUT 0x08
265 #define W5500_Sn_IR_RECV 0x04
266 #define W5500_Sn_IR_DISCON 0x02
267 #define W5500_Sn_IR_CON 0x01
270 #define W5500_Sn_SR_SOCK_CLOSED 0x00
271 #define W5500_Sn_SR_SOCK_INIT 0x13
272 #define W5500_Sn_SR_SOCK_LISTEN 0x14
273 #define W5500_Sn_SR_SOCK_SYNSENT 0x15
274 #define W5500_Sn_SR_SOCK_SYNRECV 0x16
275 #define W5500_Sn_SR_SOCK_ESTABLISHED 0x17
276 #define W5500_Sn_SR_SOCK_FIN_WAIT 0x18
277 #define W5500_Sn_SR_SOCK_CLOSING 0x1A
278 #define W5500_Sn_SR_SOCK_TIME_WAIT 0x1B
279 #define W5500_Sn_SR_SOCK_CLOSE_WAIT 0x1C
280 #define W5500_Sn_SR_SOCK_LAST_ACK 0x1D
281 #define W5500_Sn_SR_SOCK_UDP 0x22
282 #define W5500_Sn_SR_SOCK_MACRAW 0x42
285 #define W5500_Sn_RXBUF_SIZE_0KB 0x00
286 #define W5500_Sn_RXBUF_SIZE_1KB 0x01
287 #define W5500_Sn_RXBUF_SIZE_2KB 0x02
288 #define W5500_Sn_RXBUF_SIZE_4KB 0x04
289 #define W5500_Sn_RXBUF_SIZE_8KB 0x08
290 #define W5500_Sn_RXBUF_SIZE_16KB 0x10
293 #define W5500_Sn_TXBUF_SIZE_0KB 0x00
294 #define W5500_Sn_TXBUF_SIZE_1KB 0x01
295 #define W5500_Sn_TXBUF_SIZE_2KB 0x02
296 #define W5500_Sn_TXBUF_SIZE_4KB 0x04
297 #define W5500_Sn_TXBUF_SIZE_8KB 0x08
298 #define W5500_Sn_TXBUF_SIZE_16KB 0x10
301 #define W5500_Sn_IMR_SEND_OK 0x10
302 #define W5500_Sn_IMR_TIMEOUT 0x08
303 #define W5500_Sn_IMR_RECV 0x04
304 #define W5500_Sn_IMR_DISCON 0x02
305 #define W5500_Sn_IMR_CON 0x01
308 #define W5500_CTRL_BSB_Sn_REG(n) (0x08 + (n) * 0x20)
309 #define W5500_CTRL_BSB_Sn_TX_BUFFER(n) (0x10 + (n) * 0x20)
310 #define W5500_CTRL_BSB_Sn_RX_BUFFER(n) (0x18 + (n) * 0x20)
error_t w5500UpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
error_t w5500ReceivePacket(NetInterface *interface)
Receive a packet.
Structure describing a buffer that spans multiple chunks.
void w5500EnableIrq(NetInterface *interface)
Enable interrupts.
error_t w5500SendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
bool_t w5500IrqHandler(NetInterface *interface)
W5500 interrupt service routine.
void w5500EventHandler(NetInterface *interface)
W5500 event handler.
const NicDriver w5500Driver
W5500 driver.
void w5500InitHook(NetInterface *interface)
W5500 custom configuration.
void w5500WriteBuffer(NetInterface *interface, uint8_t control, uint16_t address, const uint8_t *data, size_t length)
Write TX buffer.
void w5500WriteReg8(NetInterface *interface, uint8_t control, uint16_t address, uint8_t data)
Write 8-bit register.
void w5500Tick(NetInterface *interface)
W5500 timer handler.
void w5500WriteReg16(NetInterface *interface, uint8_t control, uint16_t address, uint16_t data)
Write 16-bit register.
uint16_t w5500ReadReg16(NetInterface *interface, uint8_t control, uint16_t address)
Read 16-bit register.
void w5500ReadBuffer(NetInterface *interface, uint8_t control, uint16_t address, uint8_t *data, size_t length)
Read RX buffer.
uint8_t w5500ReadReg8(NetInterface *interface, uint8_t control, uint16_t address)
Read 8-bit register.
error_t w5500Init(NetInterface *interface)
W5500 controller initialization.
Network interface controller abstraction layer.
void w5500DumpReg(NetInterface *interface)
Dump registers for debugging purpose.
void w5500DisableIrq(NetInterface *interface)
Disable interrupts.