w5200_driver.c
Go to the documentation of this file.
1 /**
2  * @file w5200_driver.c
3  * @brief WIZnet W5200 Ethernet controller
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.4
29  **/
30 
31 //Switch to the appropriate trace level
32 #define TRACE_LEVEL NIC_TRACE_LEVEL
33 
34 //Dependencies
35 #include "core/net.h"
37 #include "debug.h"
38 
39 
40 /**
41  * @brief W5200 driver
42  **/
43 
45 {
47  ETH_MTU,
48  w5200Init,
49  w5200Tick,
55  NULL,
56  NULL,
57  NULL,
58  TRUE,
59  TRUE,
60  TRUE,
61  TRUE
62 };
63 
64 
65 /**
66  * @brief W5200 controller initialization
67  * @param[in] interface Underlying network interface
68  * @return Error code
69  **/
70 
72 {
73  uint_t i;
74  uint8_t value;
75 
76  //Debug message
77  TRACE_INFO("Initializing W5200 Ethernet controller...\r\n");
78 
79  //Initialize SPI interface
80  interface->spiDriver->init();
81 
82  //Initialize external interrupt line driver
83  if(interface->extIntDriver != NULL)
84  {
85  interface->extIntDriver->init();
86  }
87 
88  //Wait for the SPI interface to be ready
89  do
90  {
91  //Read chip version register
92  value = w5200ReadReg8(interface, W5200_VERSIONR);
93 
94  //Check chip version
95  } while(value != W5200_VERSIONR_DEFAULT);
96 
97  //Perform software reset
99 
100  //Wait for reset completion
101  do
102  {
103  //Read mode register
104  value = w5200ReadReg8(interface, W5200_MR);
105 
106  //The RST bit is automatically cleared after reset completion
107  } while((value & W5200_MR_RST) != 0);
108 
109  //Set the MAC address of the station
110  w5200WriteReg8(interface, W5200_SHAR0, interface->macAddr.b[0]);
111  w5200WriteReg8(interface, W5200_SHAR1, interface->macAddr.b[1]);
112  w5200WriteReg8(interface, W5200_SHAR2, interface->macAddr.b[2]);
113  w5200WriteReg8(interface, W5200_SHAR3, interface->macAddr.b[3]);
114  w5200WriteReg8(interface, W5200_SHAR4, interface->macAddr.b[4]);
115  w5200WriteReg8(interface, W5200_SHAR5, interface->macAddr.b[5]);
116 
117  //Set TX and RX buffer size for socket 0
120 
121  //Sockets 1 to 7 are not used
122  for(i = 1; i <= 7; i++)
123  {
124  w5200WriteReg8(interface, W5200_Sn_TXMEM_SIZE(i),
126 
127  w5200WriteReg8(interface, W5200_Sn_RXMEM_SIZE(i),
129  }
130 
131  //Configure socket 0 in MACRAW mode
134 
135  //Open socket 0
137 
138  //Wait for command completion
139  do
140  {
141  //Read status register
142  value = w5200ReadReg8(interface, W5200_S0_SR);
143 
144  //Check the status of the socket
145  } while(value != W5200_Sn_SR_SOCK_MACRAW);
146 
147  //Configure socket 0 interrupts
150 
151  //Enable socket 0 interrupts
153 
154  //Perform custom configuration
155  w5200InitHook(interface);
156 
157  //Dump registers for debugging purpose
158  w5200DumpReg(interface);
159 
160  //Accept any packets from the upper layer
161  osSetEvent(&interface->nicTxEvent);
162 
163  //Force the TCP/IP stack to poll the link state at startup
164  interface->nicEvent = TRUE;
165  //Notify the TCP/IP stack of the event
167 
168  //Successful initialization
169  return NO_ERROR;
170 }
171 
172 
173 /**
174  * @brief W5200 custom configuration
175  * @param[in] interface Underlying network interface
176  **/
177 
178 __weak_func void w5200InitHook(NetInterface *interface)
179 {
180 }
181 
182 
183 /**
184  * @brief W5200 timer handler
185  * @param[in] interface Underlying network interface
186  **/
187 
188 void w5200Tick(NetInterface *interface)
189 {
190  uint8_t value;
191  bool_t linkState;
192 
193  //Read PHY status register
194  value = w5200ReadReg8(interface, W5200_PSTATUS);
195  //Retrieve current link state
196  linkState = (value & W5200_PSTATUS_LINK) ? TRUE : FALSE;
197 
198  //Check link state
199  if(linkState && !interface->linkState)
200  {
201  //Link is up
202  interface->linkState = TRUE;
203  //Process link state change event
204  nicNotifyLinkChange(interface);
205  }
206  else if(!linkState && interface->linkState)
207  {
208  //Link is down
209  interface->linkState = FALSE;
210  //Process link state change event
211  nicNotifyLinkChange(interface);
212  }
213  else
214  {
215  //No link change detected
216  }
217 }
218 
219 
220 /**
221  * @brief Enable interrupts
222  * @param[in] interface Underlying network interface
223  **/
224 
225 void w5200EnableIrq(NetInterface *interface)
226 {
227  //Enable interrupts
228  if(interface->extIntDriver != NULL)
229  {
230  interface->extIntDriver->enableIrq();
231  }
232 }
233 
234 
235 /**
236  * @brief Disable interrupts
237  * @param[in] interface Underlying network interface
238  **/
239 
241 {
242  //Disable interrupts
243  if(interface->extIntDriver != NULL)
244  {
245  interface->extIntDriver->disableIrq();
246  }
247 }
248 
249 
250 /**
251  * @brief W5200 interrupt service routine
252  * @param[in] interface Underlying network interface
253  * @return TRUE if a higher priority task must be woken. Else FALSE is returned
254  **/
255 
257 {
258  bool_t flag;
259  uint16_t n;
260  uint8_t isr;
261 
262  //This flag will be set if a higher priority task must be woken
263  flag = FALSE;
264 
265  //Read socket interrupt register
266  isr = w5200ReadReg8(interface, W5200_IR2);
267  //Disable interrupts to release the interrupt line
268  w5200WriteReg8(interface, W5200_IMR, 0);
269 
270  //Socket 0 interrupt?
271  if((isr & W5200_IR2_S0_INT) != 0)
272  {
273  //Read socket 0 interrupt register
274  isr = w5200ReadReg8(interface, W5200_S0_IR);
275 
276  //Packet transmission complete?
277  if((isr & W5200_Sn_IR_SENDOK) != 0)
278  {
279  //Get the amount of free memory available in the TX buffer
280  n = w5200ReadReg16(interface, W5200_S0_TX_FSR0);
281 
282  //Check whether the TX buffer is available for writing
283  if(n >= ETH_MAX_FRAME_SIZE)
284  {
285  //The transmitter can accept another packet
286  osSetEvent(&interface->nicTxEvent);
287  }
288  }
289 
290  //Packet received?
291  if((isr & W5200_Sn_IR_RECV) != 0)
292  {
293  //Set event flag
294  interface->nicEvent = TRUE;
295  //Notify the TCP/IP stack of the event
296  flag |= osSetEventFromIsr(&netEvent);
297  }
298 
299  //Clear interrupt flags
300  w5200WriteReg8(interface, W5200_S0_IR, isr &
302  }
303 
304  //Re-enable interrupts once the interrupt has been serviced
306 
307  //A higher priority task must be woken?
308  return flag;
309 }
310 
311 
312 /**
313  * @brief W5200 event handler
314  * @param[in] interface Underlying network interface
315  **/
316 
318 {
319  error_t error;
320 
321  //Process all pending packets
322  do
323  {
324  //Read incoming packet
325  error = w5200ReceivePacket(interface);
326 
327  //No more data in the receive buffer?
328  } while(error != ERROR_BUFFER_EMPTY);
329 }
330 
331 
332 /**
333  * @brief Send a packet
334  * @param[in] interface Underlying network interface
335  * @param[in] buffer Multi-part buffer containing the data to send
336  * @param[in] offset Offset to the first data byte
337  * @param[in] ancillary Additional options passed to the stack along with
338  * the packet
339  * @return Error code
340  **/
341 
343  const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
344 {
345  static uint8_t temp[W5200_ETH_TX_BUFFER_SIZE];
346  uint16_t n;
347  size_t length;
348 
349  //Retrieve the length of the packet
350  length = netBufferGetLength(buffer) - offset;
351 
352  //Check the frame length
354  {
355  //The transmitter can accept another packet
356  osSetEvent(&interface->nicTxEvent);
357  //Report an error
358  return ERROR_INVALID_LENGTH;
359  }
360 
361  //Get the amount of free memory available in the TX buffer
362  n = w5200ReadReg16(interface, W5200_S0_TX_FSR0);
363 
364  //Make sure the TX buffer is available for writing
365  if(n < length)
366  return ERROR_FAILURE;
367 
368  //Copy user data
369  netBufferRead(temp, buffer, offset, length);
370 
371  //Write packet data
372  w5200WriteData(interface, temp, length);
373 
374  //Get the amount of free memory available in the TX buffer
375  n = w5200ReadReg16(interface, W5200_S0_TX_FSR0);
376 
377  //Check whether the TX buffer is available for writing
378  if(n >= ETH_MAX_FRAME_SIZE)
379  {
380  //The transmitter can accept another packet
381  osSetEvent(&interface->nicTxEvent);
382  }
383 
384  //Successful processing
385  return NO_ERROR;
386 }
387 
388 
389 /**
390  * @brief Receive a packet
391  * @param[in] interface Underlying network interface
392  * @return Error code
393  **/
394 
396 {
397  static uint8_t temp[W5200_ETH_RX_BUFFER_SIZE];
398  error_t error;
399  size_t length;
400 
401  //Get the amount of data in the RX buffer
402  length = w5200ReadReg16(interface, W5200_S0_RX_RSR0);
403 
404  //Any packet pending in the receive buffer?
405  if(length > 0)
406  {
407  //Read packet header
408  w5200ReadData(interface, temp, 2);
409 
410  //Retrieve the length of the received packet
411  length = LOAD16BE(temp);
412 
413  //Ensure the packet size is acceptable
414  if(length >= 2 && length <= (ETH_MAX_FRAME_SIZE + 2))
415  {
416  //Read packet data
417  w5200ReadData(interface, temp, length - 2);
418  //Successful processing
419  error = NO_ERROR;
420  }
421  else
422  {
423  //The packet length is not valid
424  error = ERROR_INVALID_LENGTH;
425  }
426  }
427  else
428  {
429  //No more data in the receive buffer
430  error = ERROR_BUFFER_EMPTY;
431  }
432 
433  //Check whether a valid packet has been received
434  if(!error)
435  {
436  NetRxAncillary ancillary;
437 
438  //Additional options can be passed to the stack along with the packet
439  ancillary = NET_DEFAULT_RX_ANCILLARY;
440 
441  //Pass the packet to the upper layer
442  nicProcessPacket(interface, temp, length, &ancillary);
443  }
444 
445  //Return status code
446  return error;
447 }
448 
449 
450 /**
451  * @brief Configure MAC address filtering
452  * @param[in] interface Underlying network interface
453  * @return Error code
454  **/
455 
457 {
458  //Not implemented
459  return NO_ERROR;
460 }
461 
462 
463 /**
464  * @brief Write 8-bit register
465  * @param[in] interface Underlying network interface
466  * @param[in] address Register address
467  * @param[in] data Register value
468  **/
469 
470 void w5200WriteReg8(NetInterface *interface, uint16_t address, uint8_t data)
471 {
472  //Pull the CS pin low
473  interface->spiDriver->assertCs();
474 
475  //Write address
476  interface->spiDriver->transfer(MSB(address));
477  interface->spiDriver->transfer(LSB(address));
478 
479  //Write opcode and data length
480  interface->spiDriver->transfer(W5200_OP_WRITE);
481  interface->spiDriver->transfer(1);
482 
483  //Write data
484  interface->spiDriver->transfer(data);
485 
486  //Terminate the operation by raising the CS pin
487  interface->spiDriver->deassertCs();
488 }
489 
490 
491 /**
492  * @brief Read 8-bit register
493  * @param[in] interface Underlying network interface
494  * @param[in] address Register address
495  * @return Register value
496  **/
497 
498 uint8_t w5200ReadReg8(NetInterface *interface, uint16_t address)
499 {
500  uint8_t data;
501 
502  //Pull the CS pin low
503  interface->spiDriver->assertCs();
504 
505  //Write address
506  interface->spiDriver->transfer(MSB(address));
507  interface->spiDriver->transfer(LSB(address));
508 
509  //Write opcode and data length
510  interface->spiDriver->transfer(W5200_OP_READ);
511  interface->spiDriver->transfer(1);
512 
513  //Read data
514  data = interface->spiDriver->transfer(0x00);
515 
516  //Terminate the operation by raising the CS pin
517  interface->spiDriver->deassertCs();
518 
519  //Return register value
520  return data;
521 }
522 
523 
524 /**
525  * @brief Write 16-bit register
526  * @param[in] interface Underlying network interface
527  * @param[in] address Register address
528  * @param[in] data Register value
529  **/
530 
531 void w5200WriteReg16(NetInterface *interface, uint16_t address, uint16_t data)
532 {
533  //Pull the CS pin low
534  interface->spiDriver->assertCs();
535 
536  //Write address
537  interface->spiDriver->transfer(MSB(address));
538  interface->spiDriver->transfer(LSB(address));
539 
540  //Write opcode and data length
541  interface->spiDriver->transfer(W5200_OP_WRITE);
542  interface->spiDriver->transfer(2);
543 
544  //Write data
545  interface->spiDriver->transfer(MSB(data));
546  interface->spiDriver->transfer(LSB(data));
547 
548  //Terminate the operation by raising the CS pin
549  interface->spiDriver->deassertCs();
550 }
551 
552 
553 /**
554  * @brief Read 16-bit register
555  * @param[in] interface Underlying network interface
556  * @param[in] address Register address
557  * @return Register value
558  **/
559 
560 uint16_t w5200ReadReg16(NetInterface *interface, uint16_t address)
561 {
562  uint16_t data;
563 
564  //Pull the CS pin low
565  interface->spiDriver->assertCs();
566 
567  //Write address
568  interface->spiDriver->transfer(MSB(address));
569  interface->spiDriver->transfer(LSB(address));
570 
571  //Write opcode and data length
572  interface->spiDriver->transfer(W5200_OP_READ);
573  interface->spiDriver->transfer(2);
574 
575  //Read data
576  data = interface->spiDriver->transfer(0x00) << 8;
577  data |= interface->spiDriver->transfer(0x00);
578 
579  //Terminate the operation by raising the CS pin
580  interface->spiDriver->deassertCs();
581 
582  //Return register value
583  return data;
584 }
585 
586 
587 /**
588  * @brief Write data
589  * @param[in] interface Underlying network interface
590  * @param[in] data Pointer to the data being written
591  * @param[in] length Number of data to write
592  **/
593 
594 void w5200WriteData(NetInterface *interface, const uint8_t *data,
595  size_t length)
596 {
597  size_t p;
598  size_t size;
599  size_t offset;
600 
601  //Get TX buffer size
602  size = w5200ReadReg8(interface, W5200_S0_TXMEM_SIZE) * 1024;
603  //Get TX write pointer
604  p = w5200ReadReg16(interface, W5200_S0_TX_WR0);
605 
606  //Retrieve current offset
607  offset = p & (size - 1);
608 
609  //Check whether the data crosses buffer boundaries
610  if((offset + length) < size)
611  {
612  //Write data
613  w5200WriteBuffer(interface, W5200_TX_BUFFER + offset, data, length);
614  }
615  else
616  {
617  //Write the first part of the data
618  w5200WriteBuffer(interface, W5200_TX_BUFFER + offset, data,
619  size - offset);
620 
621  //Wrap around to the beginning of the circular buffer
623  data + size - offset, offset + length - size);
624  }
625 
626  //Increment TX write pointer
627  w5200WriteReg16(interface, W5200_S0_TX_WR0, p + length);
628 
629  //Start packet transmission
631 }
632 
633 
634 /**
635  * @brief Read data
636  * @param[in] interface Underlying network interface
637  * @param[out] data Buffer where to store the incoming data
638  * @param[in] length Number of data to read
639  **/
640 
641 void w5200ReadData(NetInterface *interface, uint8_t *data, size_t length)
642 {
643  size_t p;
644  size_t size;
645  size_t offset;
646 
647  //Get RX buffer size
648  size = w5200ReadReg8(interface, W5200_S0_RXMEM_SIZE) * 1024;
649  //Get RX read pointer
650  p = w5200ReadReg16(interface, W5200_S0_RX_RD0);
651 
652  //Retrieve current offset
653  offset = p & (size - 1);
654 
655  //Check whether the data crosses buffer boundaries
656  if((offset + length) < size)
657  {
658  //Read data
659  w5200ReadBuffer(interface, W5200_RX_BUFFER + offset, data, length);
660  }
661  else
662  {
663  //Read the first part of the data
664  w5200ReadBuffer(interface, W5200_RX_BUFFER + offset, data,
665  size - offset);
666 
667  //Wrap around to the beginning of the circular buffer
668  w5200ReadBuffer(interface, W5200_RX_BUFFER,
669  data + size - offset, offset + length - size);
670  }
671 
672  //Increment RX read pointer
673  w5200WriteReg16(interface, W5200_S0_RX_RD0, p + length);
674 
675  //Complete the processing of the receive data
677 }
678 
679 
680 /**
681  * @brief Write TX buffer
682  * @param[in] interface Underlying network interface
683  * @param[in] address Buffer address
684  * @param[in] data Pointer to the data being written
685  * @param[in] length Number of data to write
686  **/
687 
688 void w5200WriteBuffer(NetInterface *interface, uint16_t address,
689  const uint8_t *data, size_t length)
690 {
691  size_t i;
692 
693  //Pull the CS pin low
694  interface->spiDriver->assertCs();
695 
696  //Write address
697  interface->spiDriver->transfer(MSB(address));
698  interface->spiDriver->transfer(LSB(address));
699 
700  //Write opcode and data length
701  interface->spiDriver->transfer(W5200_OP_WRITE | MSB(length));
702  interface->spiDriver->transfer(LSB(length));
703 
704  //Write data
705  for(i = 0; i < length; i++)
706  {
707  interface->spiDriver->transfer(data[i]);
708  }
709 
710  //Terminate the operation by raising the CS pin
711  interface->spiDriver->deassertCs();
712 }
713 
714 
715 /**
716  * @brief Read RX buffer
717  * @param[in] interface Underlying network interface
718  * @param[in] address Buffer address
719  * @param[out] data Buffer where to store the incoming data
720  * @param[in] length Number of data to read
721  **/
722 
723 void w5200ReadBuffer(NetInterface *interface, uint16_t address, uint8_t *data,
724  size_t length)
725 {
726  size_t i;
727 
728  //Pull the CS pin low
729  interface->spiDriver->assertCs();
730 
731  //Write address
732  interface->spiDriver->transfer(MSB(address));
733  interface->spiDriver->transfer(LSB(address));
734 
735  //Write opcode and data length
736  interface->spiDriver->transfer(W5200_OP_READ | MSB(length));
737  interface->spiDriver->transfer(LSB(length));
738 
739  //Read data
740  for(i = 0; i < length; i++)
741  {
742  data[i] = interface->spiDriver->transfer(0x00);
743  }
744 
745  //Terminate the operation by raising the CS pin
746  interface->spiDriver->deassertCs();
747 }
748 
749 
750 /**
751  * @brief Dump registers for debugging purpose
752  * @param[in] interface Underlying network interface
753  **/
754 
755 void w5200DumpReg(NetInterface *interface)
756 {
757  uint16_t i;
758 
759  //Loop through registers
760  for(i = 0; i < 64; i++)
761  {
762  //Display current host MAC register
763  TRACE_DEBUG("%02" PRIX16 ": 0x%02" PRIX8 "\r\n", i,
764  w5200ReadReg8(interface, i));
765  }
766 
767  //Terminate with a line feed
768  TRACE_DEBUG("\r\n");
769 }
bool_t osSetEventFromIsr(OsEvent *event)
Set an event object to the signaled state from an interrupt service routine.
void nicNotifyLinkChange(NetInterface *interface)
Process link state change notification.
Definition: nic.c:559
#define W5200_Sn_IR_RECV
Definition: w5200_driver.h:537
#define W5200_Sn_RXMEM_SIZE(n)
Definition: w5200_driver.h:438
#define W5200_SHAR4
Definition: w5200_driver.h:69
int bool_t
Definition: compiler_port.h:53
#define W5200_Sn_MR_MF
Definition: w5200_driver.h:504
#define netEvent
Definition: net_legacy.h:196
#define W5200_TX_BUFFER
Definition: w5200_driver.h:457
bool_t w5200IrqHandler(NetInterface *interface)
W5200 interrupt service routine.
Definition: w5200_driver.c:256
#define W5200_S0_MR
Definition: w5200_driver.h:93
size_t netBufferRead(void *dest, const NetBuffer *src, size_t srcOffset, size_t length)
Read data from a multi-part buffer.
Definition: net_mem.c:690
#define W5200_IR2
Definition: w5200_driver.h:88
uint8_t p
Definition: ndp.h:300
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89
#define TRUE
Definition: os_port.h:50
uint8_t data[]
Definition: ethernet.h:222
#define W5200_Sn_RXMEM_SIZE_16KB
Definition: w5200_driver.h:565
#define ETH_MAX_FRAME_SIZE
Definition: ethernet.h:110
__weak_func void w5200InitHook(NetInterface *interface)
W5200 custom configuration.
Definition: w5200_driver.c:178
#define W5200_OP_READ
Definition: w5200_driver.h:52
void w5200WriteReg16(NetInterface *interface, uint16_t address, uint16_t data)
Write 16-bit register.
Definition: w5200_driver.c:531
#define W5200_Sn_IMR_RECV
Definition: w5200_driver.h:581
#define W5200_MR
Definition: w5200_driver.h:56
#define W5200_Sn_TXMEM_SIZE_0KB
Definition: w5200_driver.h:568
#define W5200_Sn_CR_RECV
Definition: w5200_driver.h:529
void nicProcessPacket(NetInterface *interface, uint8_t *packet, size_t length, NetRxAncillary *ancillary)
Handle a packet received by the network controller.
Definition: nic.c:392
void w5200WriteBuffer(NetInterface *interface, uint16_t address, const uint8_t *data, size_t length)
Write TX buffer.
Definition: w5200_driver.c:688
void w5200ReadData(NetInterface *interface, uint8_t *data, size_t length)
Read data.
Definition: w5200_driver.c:641
void w5200ReadBuffer(NetInterface *interface, uint16_t address, uint8_t *data, size_t length)
Read RX buffer.
Definition: w5200_driver.c:723
#define W5200_Sn_TXMEM_SIZE_16KB
Definition: w5200_driver.h:573
#define W5200_S0_RX_RSR0
Definition: w5200_driver.h:124
#define W5200_RX_BUFFER
Definition: w5200_driver.h:458
void w5200WriteData(NetInterface *interface, const uint8_t *data, size_t length)
Write data.
Definition: w5200_driver.c:594
#define W5200_MR_RST
Definition: w5200_driver.h:461
#define W5200_SHAR1
Definition: w5200_driver.h:66
#define FALSE
Definition: os_port.h:46
#define W5200_S0_IR
Definition: w5200_driver.h:95
#define W5200_S0_CR
Definition: w5200_driver.h:94
error_t
Error codes.
Definition: error.h:43
#define W5200_SHAR0
Definition: w5200_driver.h:65
error_t w5200ReceivePacket(NetInterface *interface)
Receive a packet.
Definition: w5200_driver.c:395
const NetRxAncillary NET_DEFAULT_RX_ANCILLARY
Definition: net_misc.c:104
void w5200WriteReg8(NetInterface *interface, uint16_t address, uint8_t data)
Write 8-bit register.
Definition: w5200_driver.c:470
@ ERROR_FAILURE
Generic error code.
Definition: error.h:45
#define W5200_Sn_IR_SENDOK
Definition: w5200_driver.h:535
#define W5200_S0_TX_WR0
Definition: w5200_driver.h:122
#define W5200_SHAR3
Definition: w5200_driver.h:68
#define NetRxAncillary
Definition: net_misc.h:40
#define NetInterface
Definition: net.h:36
error_t w5200Init(NetInterface *interface)
W5200 controller initialization.
Definition: w5200_driver.c:71
#define W5200_Sn_IMR_SENDOK
Definition: w5200_driver.h:579
@ ERROR_INVALID_LENGTH
Definition: error.h:111
void w5200DumpReg(NetInterface *interface)
Dump registers for debugging purpose.
Definition: w5200_driver.c:755
#define W5200_S0_RXMEM_SIZE
Definition: w5200_driver.h:116
#define W5200_Sn_CR_OPEN
Definition: w5200_driver.h:516
@ ERROR_BUFFER_EMPTY
Definition: error.h:141
void w5200DisableIrq(NetInterface *interface)
Disable interrupts.
Definition: w5200_driver.c:240
void w5200Tick(NetInterface *interface)
W5200 timer handler.
Definition: w5200_driver.c:188
#define NetTxAncillary
Definition: net_misc.h:36
#define W5200_OP_WRITE
Definition: w5200_driver.h:53
#define W5200_ETH_RX_BUFFER_SIZE
Definition: w5200_driver.h:46
#define MSB(x)
Definition: os_port.h:59
error_t w5200SendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
Definition: w5200_driver.c:342
#define W5200_IMR_S0_IMR
Definition: w5200_driver.h:478
#define TRACE_INFO(...)
Definition: debug.h:95
uint8_t length
Definition: tcp.h:368
size_t netBufferGetLength(const NetBuffer *buffer)
Get the actual length of a multi-part buffer.
Definition: net_mem.c:297
#define LSB(x)
Definition: os_port.h:55
#define W5200_VERSIONR_DEFAULT
Definition: w5200_driver.h:481
#define W5200_ETH_TX_BUFFER_SIZE
Definition: w5200_driver.h:39
#define W5200_Sn_RXMEM_SIZE_0KB
Definition: w5200_driver.h:560
#define TRACE_DEBUG(...)
Definition: debug.h:107
#define W5200_Sn_MR_PROTOCOL_MACRAW
Definition: w5200_driver.h:512
#define W5200_IR2_S0_INT
Definition: w5200_driver.h:491
uint16_t w5200ReadReg16(NetInterface *interface, uint16_t address)
Read 16-bit register.
Definition: w5200_driver.c:560
#define ETH_MTU
Definition: ethernet.h:116
uint8_t n
#define W5200_S0_TXMEM_SIZE
Definition: w5200_driver.h:117
Ipv6Addr address[]
Definition: ipv6.h:325
const NicDriver w5200Driver
W5200 driver.
Definition: w5200_driver.c:44
#define W5200_Sn_TXMEM_SIZE(n)
Definition: w5200_driver.h:439
#define W5200_Sn_SR_SOCK_MACRAW
Definition: w5200_driver.h:556
WIZnet W5200 Ethernet controller.
#define W5200_VERSIONR
Definition: w5200_driver.h:83
void w5200EnableIrq(NetInterface *interface)
Enable interrupts.
Definition: w5200_driver.c:225
uint8_t value[]
Definition: tcp.h:369
#define W5200_PSTATUS_LINK
Definition: w5200_driver.h:494
#define W5200_SHAR2
Definition: w5200_driver.h:67
uint8_t w5200ReadReg8(NetInterface *interface, uint16_t address)
Read 8-bit register.
Definition: w5200_driver.c:498
#define W5200_PSTATUS
Definition: w5200_driver.h:89
void osSetEvent(OsEvent *event)
Set the specified event object to the signaled state.
error_t w5200UpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
Definition: w5200_driver.c:456
#define W5200_SHAR5
Definition: w5200_driver.h:70
#define W5200_S0_SR
Definition: w5200_driver.h:96
unsigned int uint_t
Definition: compiler_port.h:50
#define LOAD16BE(p)
Definition: cpu_endian.h:186
TCP/IP stack core.
#define W5200_Sn_CR_SEND
Definition: w5200_driver.h:521
NIC driver.
Definition: nic.h:286
#define W5200_S0_RX_RD0
Definition: w5200_driver.h:126
void w5200EventHandler(NetInterface *interface)
W5200 event handler.
Definition: w5200_driver.c:317
@ NO_ERROR
Success.
Definition: error.h:44
Debugging facilities.
#define W5200_IMR
Definition: w5200_driver.h:76
#define W5200_S0_TX_FSR0
Definition: w5200_driver.h:118
@ NIC_TYPE_ETHERNET
Ethernet interface.
Definition: nic.h:83
#define W5200_S0_IMR
Definition: w5200_driver.h:130