w5100_driver.c
Go to the documentation of this file.
1 /**
2  * @file w5100_driver.c
3  * @brief WIZnet W5100 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 W5100 driver
42  **/
43 
45 {
47  ETH_MTU,
48  w5100Init,
49  w5100Tick,
55  NULL,
56  NULL,
57  NULL,
58  TRUE,
59  TRUE,
60  TRUE,
61  TRUE
62 };
63 
64 
65 /**
66  * @brief W5100 controller initialization
67  * @param[in] interface Underlying network interface
68  * @return Error code
69  **/
70 
72 {
73  uint8_t value;
74 
75  //Debug message
76  TRACE_INFO("Initializing W5100 Ethernet controller...\r\n");
77 
78  //Initialize SPI interface
79  interface->spiDriver->init();
80 
81  //Initialize external interrupt line driver
82  if(interface->extIntDriver != NULL)
83  {
84  interface->extIntDriver->init();
85  }
86 
87  //Perform software reset
89 
90  //Wait for reset completion
91  do
92  {
93  //Read mode register
94  value = w5100ReadReg8(interface, W5100_MR);
95 
96  //The RST bit is automatically cleared after reset completion
97  } while((value & W5100_MR_RST) != 0);
98 
99  //Set the MAC address of the station
100  w5100WriteReg8(interface, W5100_SHAR0, interface->macAddr.b[0]);
101  w5100WriteReg8(interface, W5100_SHAR1, interface->macAddr.b[1]);
102  w5100WriteReg8(interface, W5100_SHAR2, interface->macAddr.b[2]);
103  w5100WriteReg8(interface, W5100_SHAR3, interface->macAddr.b[3]);
104  w5100WriteReg8(interface, W5100_SHAR4, interface->macAddr.b[4]);
105  w5100WriteReg8(interface, W5100_SHAR5, interface->macAddr.b[5]);
106 
107  //Set TX buffer size
108  w5100WriteReg8(interface, W5100_TMSR,
111 
112  //Set RX buffer size
113  w5100WriteReg8(interface, W5100_RMSR,
116 
117  //Configure socket 0 in MACRAW mode
119 
120  //Open socket 0
122 
123  //Wait for command completion
124  do
125  {
126  //Read status register
127  value = w5100ReadReg8(interface, W5100_S0_SR);
128 
129  //Check the status of the socket
130  } while(value != W5100_Sn_SR_SOCK_MACRAW);
131 
132  //Enable socket 0 interrupts
134 
135  //Perform custom configuration
136  w5100InitHook(interface);
137 
138  //Dump registers for debugging purpose
139  w5100DumpReg(interface);
140 
141  //Accept any packets from the upper layer
142  osSetEvent(&interface->nicTxEvent);
143 
144  //Force the TCP/IP stack to poll the link state at startup
145  interface->nicEvent = TRUE;
146  //Notify the TCP/IP stack of the event
148 
149  //Successful initialization
150  return NO_ERROR;
151 }
152 
153 
154 /**
155  * @brief W5100 custom configuration
156  * @param[in] interface Underlying network interface
157  **/
158 
159 __weak_func void w5100InitHook(NetInterface *interface)
160 {
161 }
162 
163 
164 /**
165  * @brief W5100 timer handler
166  * @param[in] interface Underlying network interface
167  **/
168 
169 __weak_func void w5100Tick(NetInterface *interface)
170 {
171  //Check link state
172  if(!interface->linkState)
173  {
174  //Link is always up
175  interface->linkState = TRUE;
176  //Process link state change event
177  nicNotifyLinkChange(interface);
178  }
179 }
180 
181 
182 /**
183  * @brief Enable interrupts
184  * @param[in] interface Underlying network interface
185  **/
186 
187 void w5100EnableIrq(NetInterface *interface)
188 {
189  //Enable interrupts
190  if(interface->extIntDriver != NULL)
191  {
192  interface->extIntDriver->enableIrq();
193  }
194 }
195 
196 
197 /**
198  * @brief Disable interrupts
199  * @param[in] interface Underlying network interface
200  **/
201 
203 {
204  //Disable interrupts
205  if(interface->extIntDriver != NULL)
206  {
207  interface->extIntDriver->disableIrq();
208  }
209 }
210 
211 
212 /**
213  * @brief W5100 interrupt service routine
214  * @param[in] interface Underlying network interface
215  * @return TRUE if a higher priority task must be woken. Else FALSE is returned
216  **/
217 
219 {
220  bool_t flag;
221  uint16_t n;
222  uint8_t isr;
223 
224  //This flag will be set if a higher priority task must be woken
225  flag = FALSE;
226 
227  //Read socket interrupt register
228  isr = w5100ReadReg8(interface, W5100_IR);
229  //Disable interrupts to release the interrupt line
230  w5100WriteReg8(interface, W5100_IMR, 0);
231 
232  //Socket 0 interrupt?
233  if((isr & W5100_IR_S0_INT) != 0)
234  {
235  //Read socket 0 interrupt register
236  isr = w5100ReadReg8(interface, W5100_S0_IR);
237 
238  //Packet transmission complete?
239  if((isr & W5100_Sn_IR_SEND_OK) != 0)
240  {
241  //Get the amount of free memory available in the TX buffer
242  n = w5100ReadReg16(interface, W5100_S0_TX_FSR0);
243 
244  //Check whether the TX buffer is available for writing
245  if(n >= ETH_MAX_FRAME_SIZE)
246  {
247  //The transmitter can accept another packet
248  osSetEvent(&interface->nicTxEvent);
249  }
250  }
251 
252  //Packet received?
253  if((isr & W5100_Sn_IR_RECV) != 0)
254  {
255  //Set event flag
256  interface->nicEvent = TRUE;
257  //Notify the TCP/IP stack of the event
258  flag |= osSetEventFromIsr(&netEvent);
259  }
260 
261  //Clear interrupt flags
262  w5100WriteReg8(interface, W5100_S0_IR, isr &
264  }
265 
266  //Re-enable interrupts once the interrupt has been serviced
268 
269  //A higher priority task must be woken?
270  return flag;
271 }
272 
273 
274 /**
275  * @brief W5100 event handler
276  * @param[in] interface Underlying network interface
277  **/
278 
280 {
281  error_t error;
282 
283  //Process all pending packets
284  do
285  {
286  //Read incoming packet
287  error = w5100ReceivePacket(interface);
288 
289  //No more data in the receive buffer?
290  } while(error != ERROR_BUFFER_EMPTY);
291 }
292 
293 
294 /**
295  * @brief Send a packet
296  * @param[in] interface Underlying network interface
297  * @param[in] buffer Multi-part buffer containing the data to send
298  * @param[in] offset Offset to the first data byte
299  * @param[in] ancillary Additional options passed to the stack along with
300  * the packet
301  * @return Error code
302  **/
303 
305  const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
306 {
307  static uint8_t temp[W5100_ETH_TX_BUFFER_SIZE];
308  uint16_t n;
309  size_t length;
310 
311  //Retrieve the length of the packet
312  length = netBufferGetLength(buffer) - offset;
313 
314  //Check the frame length
316  {
317  //The transmitter can accept another packet
318  osSetEvent(&interface->nicTxEvent);
319  //Report an error
320  return ERROR_INVALID_LENGTH;
321  }
322 
323  //Get the amount of free memory available in the TX buffer
324  n = w5100ReadReg16(interface, W5100_S0_TX_FSR0);
325 
326  //Make sure the TX buffer is available for writing
327  if(n < length)
328  return ERROR_FAILURE;
329 
330  //Copy user data
331  netBufferRead(temp, buffer, offset, length);
332 
333  //Write packet data
334  w5100WriteData(interface, temp, length);
335 
336  //Get the amount of free memory available in the TX buffer
337  n = w5100ReadReg16(interface, W5100_S0_TX_FSR0);
338 
339  //Check whether the TX buffer is available for writing
340  if(n >= ETH_MAX_FRAME_SIZE)
341  {
342  //The transmitter can accept another packet
343  osSetEvent(&interface->nicTxEvent);
344  }
345 
346  //Successful processing
347  return NO_ERROR;
348 }
349 
350 
351 /**
352  * @brief Receive a packet
353  * @param[in] interface Underlying network interface
354  * @return Error code
355  **/
356 
358 {
359  static uint8_t temp[W5100_ETH_RX_BUFFER_SIZE];
360  error_t error;
361  size_t length;
362 
363  //Get the amount of data in the RX buffer
364  length = w5100ReadReg16(interface, W5100_S0_RX_RSR0);
365 
366  //Any packet pending in the receive buffer?
367  if(length > 0)
368  {
369  //Read packet header
370  w5100ReadData(interface, temp, 2);
371 
372  //Retrieve the length of the received packet
373  length = LOAD16BE(temp);
374 
375  //Ensure the packet size is acceptable
376  if(length >= 2 && length <= (ETH_MAX_FRAME_SIZE + 2))
377  {
378  //Read packet data
379  w5100ReadData(interface, temp, length - 2);
380  //Successful processing
381  error = NO_ERROR;
382  }
383  else
384  {
385  //The packet length is not valid
386  error = ERROR_INVALID_LENGTH;
387  }
388  }
389  else
390  {
391  //No more data in the receive buffer
392  error = ERROR_BUFFER_EMPTY;
393  }
394 
395  //Check whether a valid packet has been received
396  if(!error)
397  {
398  NetRxAncillary ancillary;
399 
400  //Additional options can be passed to the stack along with the packet
401  ancillary = NET_DEFAULT_RX_ANCILLARY;
402 
403  //Pass the packet to the upper layer
404  nicProcessPacket(interface, temp, length, &ancillary);
405  }
406 
407  //Return status code
408  return error;
409 }
410 
411 
412 /**
413  * @brief Configure MAC address filtering
414  * @param[in] interface Underlying network interface
415  * @return Error code
416  **/
417 
419 {
420  //Not implemented
421  return NO_ERROR;
422 }
423 
424 
425 /**
426  * @brief Write 8-bit register
427  * @param[in] interface Underlying network interface
428  * @param[in] address Register address
429  * @param[in] data Register value
430  **/
431 
432 void w5100WriteReg8(NetInterface *interface, uint16_t address, uint8_t data)
433 {
434  //Pull the CS pin low
435  interface->spiDriver->assertCs();
436 
437  //Control phase
438  interface->spiDriver->transfer(W5100_CTRL_WRITE);
439 
440  //Address phase
441  interface->spiDriver->transfer(MSB(address));
442  interface->spiDriver->transfer(LSB(address));
443 
444  //Data phase
445  interface->spiDriver->transfer(data);
446 
447  //Terminate the operation by raising the CS pin
448  interface->spiDriver->deassertCs();
449 }
450 
451 
452 /**
453  * @brief Read 8-bit register
454  * @param[in] interface Underlying network interface
455  * @param[in] address Register address
456  * @return Register value
457  **/
458 
459 uint8_t w5100ReadReg8(NetInterface *interface, uint16_t address)
460 {
461  uint8_t data;
462 
463  //Pull the CS pin low
464  interface->spiDriver->assertCs();
465 
466  //Control phase
467  interface->spiDriver->transfer(W5100_CTRL_READ);
468 
469  //Address phase
470  interface->spiDriver->transfer(MSB(address));
471  interface->spiDriver->transfer(LSB(address));
472 
473  //Data phase
474  data = interface->spiDriver->transfer(0x00);
475 
476  //Terminate the operation by raising the CS pin
477  interface->spiDriver->deassertCs();
478 
479  //Return register value
480  return data;
481 }
482 
483 
484 /**
485  * @brief Write 16-bit register
486  * @param[in] interface Underlying network interface
487  * @param[in] address Register address
488  * @param[in] data Register value
489  **/
490 
491 void w5100WriteReg16(NetInterface *interface, uint16_t address, uint16_t data)
492 {
493  //Write upper byte
494  w5100WriteReg8(interface, address, MSB(data));
495  //Write lower byte
496  w5100WriteReg8(interface, address + 1, LSB(data));
497 }
498 
499 
500 /**
501  * @brief Read 16-bit register
502  * @param[in] interface Underlying network interface
503  * @param[in] address Register address
504  * @return Register value
505  **/
506 
507 uint16_t w5100ReadReg16(NetInterface *interface, uint16_t address)
508 {
509  uint16_t data;
510  uint16_t data2;
511 
512  //It is recommended to read all 16-bit registers twice or more until
513  //getting the same value
514  do
515  {
516  //Read upper byte
517  data = w5100ReadReg8(interface, address) << 8;
518  //Read lower byte
519  data |= w5100ReadReg8(interface, address + 1);
520 
521  //Read upper byte
522  data2 = w5100ReadReg8(interface, address) << 8;
523  //Read lower byte
524  data2 |= w5100ReadReg8(interface, address + 1);
525 
526  //Compare 16-bit values
527  } while(data != data2);
528 
529  //Return register value
530  return data;
531 }
532 
533 
534 /**
535  * @brief Write data
536  * @param[in] interface Underlying network interface
537  * @param[in] data Pointer to the data being written
538  * @param[in] length Number of data to write
539  **/
540 
541 void w5100WriteData(NetInterface *interface, const uint8_t *data,
542  size_t length)
543 {
544  size_t p;
545  size_t size;
546  size_t offset;
547  uint8_t value;
548 
549  //Read TX memory size register
550  value = w5100ReadReg8(interface, W5100_TMSR);
551 
552  //Get TX buffer size
553  switch(value & W5100_TMSR_SOCKET0)
554  {
556  size = 1024;
557  break;
559  size = 2048;
560  break;
562  size = 4096;
563  break;
564  default:
565  size = 8192;
566  break;
567  }
568 
569  //Get TX write pointer
570  p = w5100ReadReg16(interface, W5100_S0_TX_WR0);
571 
572  //Retrieve current offset
573  offset = p & (size - 1);
574 
575  //Check whether the data crosses buffer boundaries
576  if((offset + length) < size)
577  {
578  //Write data
579  w5100WriteBuffer(interface, W5100_TX_BUFFER + offset, data, length);
580  }
581  else
582  {
583  //Write the first part of the data
584  w5100WriteBuffer(interface, W5100_TX_BUFFER + offset, data,
585  size - offset);
586 
587  //Wrap around to the beginning of the circular buffer
589  data + size - offset, offset + length - size);
590  }
591 
592  //Increment TX write pointer
593  w5100WriteReg16(interface, W5100_S0_TX_WR0, p + length);
594 
595  //Start packet transmission
597 }
598 
599 
600 /**
601  * @brief Read data
602  * @param[in] interface Underlying network interface
603  * @param[out] data Buffer where to store the incoming data
604  * @param[in] length Number of data to read
605  **/
606 
607 void w5100ReadData(NetInterface *interface, uint8_t *data, size_t length)
608 {
609  size_t p;
610  size_t size;
611  size_t offset;
612  uint8_t value;
613 
614  //Read RX memory size register
615  value = w5100ReadReg8(interface, W5100_RMSR);
616 
617  //Get RX buffer size
618  switch(value & W5100_RMSR_SOCKET0)
619  {
621  size = 1024;
622  break;
624  size = 2048;
625  break;
627  size = 4096;
628  break;
629  default:
630  size = 8192;
631  break;
632  }
633 
634  //Get RX read pointer
635  p = w5100ReadReg16(interface, W5100_S0_RX_RD0);
636 
637  //Retrieve current offset
638  offset = p & (size - 1);
639 
640  //Check whether the data crosses buffer boundaries
641  if((offset + length) < size)
642  {
643  //Read data
644  w5100ReadBuffer(interface, W5100_RX_BUFFER + offset, data, length);
645  }
646  else
647  {
648  //Read the first part of the data
649  w5100ReadBuffer(interface, W5100_RX_BUFFER + offset, data,
650  size - offset);
651 
652  //Wrap around to the beginning of the circular buffer
653  w5100ReadBuffer(interface, W5100_RX_BUFFER,
654  data + size - offset, offset + length - size);
655  }
656 
657  //Increment RX read pointer
658  w5100WriteReg16(interface, W5100_S0_RX_RD0, p + length);
659 
660  //Complete the processing of the receive data
662 }
663 
664 
665 /**
666  * @brief Write TX buffer
667  * @param[in] interface Underlying network interface
668  * @param[in] address Buffer address
669  * @param[in] data Pointer to the data being written
670  * @param[in] length Number of data to write
671  **/
672 
673 void w5100WriteBuffer(NetInterface *interface, uint16_t address,
674  const uint8_t *data, size_t length)
675 {
676  size_t i;
677 
678  //W5100 operates in unit of 32-bit stream
679  for(i = 0; i < length; i++)
680  {
681  //The unit of 32-bit stream is composed of a 1-byte opcode field,
682  //a 2-byte address field and a 1-byte data field
683  w5100WriteReg8(interface, address + i, data[i]);
684  }
685 }
686 
687 
688 /**
689  * @brief Read RX buffer
690  * @param[in] interface Underlying network interface
691  * @param[in] address Buffer address
692  * @param[out] data Buffer where to store the incoming data
693  * @param[in] length Number of data to read
694  **/
695 
696 void w5100ReadBuffer(NetInterface *interface, uint16_t address, uint8_t *data,
697  size_t length)
698 {
699  size_t i;
700 
701  //W5100 operates in unit of 32-bit stream
702  for(i = 0; i < length; i++)
703  {
704  //The unit of 32-bit stream is composed of a 1-byte opcode field,
705  //a 2-byte address field and a 1-byte data field
706  data[i] = w5100ReadReg8(interface, address + i);
707  }
708 }
709 
710 
711 /**
712  * @brief Dump registers for debugging purpose
713  * @param[in] interface Underlying network interface
714  **/
715 
716 void w5100DumpReg(NetInterface *interface)
717 {
718  uint16_t i;
719 
720  //Loop through registers
721  for(i = 0; i < 64; i++)
722  {
723  //Display current host MAC register
724  TRACE_DEBUG("%02" PRIX16 ": 0x%02" PRIX8 "\r\n", i,
725  w5100ReadReg8(interface, i));
726  }
727 
728  //Terminate with a line feed
729  TRACE_DEBUG("\r\n");
730 }
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 W5100_RMSR_SOCKET3_1KB
Definition: w5100_driver.h:293
void w5100ReadData(NetInterface *interface, uint8_t *data, size_t length)
Read data.
Definition: w5100_driver.c:607
#define W5100_SHAR5
Definition: w5100_driver.h:70
void w5100ReadBuffer(NetInterface *interface, uint16_t address, uint8_t *data, size_t length)
Read RX buffer.
Definition: w5100_driver.c:696
int bool_t
Definition: compiler_port.h:53
#define netEvent
Definition: net_legacy.h:196
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 W5100_RMSR_SOCKET0_8KB
Definition: w5100_driver.h:311
void w5100WriteBuffer(NetInterface *interface, uint16_t address, const uint8_t *data, size_t length)
Write TX buffer.
Definition: w5100_driver.c:673
uint8_t p
Definition: ndp.h:300
#define W5100_IMR
Definition: w5100_driver.h:76
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89
#define W5100_TMSR_SOCKET0
Definition: w5100_driver.h:329
#define W5100_Sn_CR_RECV
Definition: w5100_driver.h:356
#define TRUE
Definition: os_port.h:50
uint8_t data[]
Definition: ethernet.h:222
#define ETH_MAX_FRAME_SIZE
Definition: ethernet.h:110
#define W5100_SHAR4
Definition: w5100_driver.h:69
#define W5100_S0_IR
Definition: w5100_driver.h:96
#define W5100_TMSR_SOCKET0_4KB
Definition: w5100_driver.h:332
void w5100DumpReg(NetInterface *interface)
Dump registers for debugging purpose.
Definition: w5100_driver.c:716
#define W5100_TMSR_SOCKET0_1KB
Definition: w5100_driver.h:330
#define W5100_S0_TX_FSR0
Definition: w5100_driver.h:117
#define W5100_Sn_IR_SEND_OK
Definition: w5100_driver.h:359
#define W5100_ETH_RX_BUFFER_SIZE
Definition: w5100_driver.h:46
error_t w5100ReceivePacket(NetInterface *interface)
Receive a packet.
Definition: w5100_driver.c:357
#define W5100_TMSR_SOCKET0_8KB
Definition: w5100_driver.h:333
void w5100EventHandler(NetInterface *interface)
W5100 event handler.
Definition: w5100_driver.c:279
#define W5100_S0_CR
Definition: w5100_driver.h:95
void nicProcessPacket(NetInterface *interface, uint8_t *packet, size_t length, NetRxAncillary *ancillary)
Handle a packet received by the network controller.
Definition: nic.c:392
#define W5100_CTRL_READ
Definition: w5100_driver.h:52
void w5100WriteReg8(NetInterface *interface, uint16_t address, uint8_t data)
Write 8-bit register.
Definition: w5100_driver.c:432
#define W5100_MR_RST
Definition: w5100_driver.h:267
#define W5100_MR
Definition: w5100_driver.h:56
#define W5100_S0_MR
Definition: w5100_driver.h:94
#define W5100_S0_TX_WR0
Definition: w5100_driver.h:121
void w5100DisableIrq(NetInterface *interface)
Disable interrupts.
Definition: w5100_driver.c:202
uint8_t w5100ReadReg8(NetInterface *interface, uint16_t address)
Read 8-bit register.
Definition: w5100_driver.c:459
error_t w5100UpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
Definition: w5100_driver.c:418
#define W5100_RMSR
Definition: w5100_driver.h:80
#define FALSE
Definition: os_port.h:46
#define W5100_SHAR3
Definition: w5100_driver.h:68
WIZnet W5100 Ethernet controller.
error_t
Error codes.
Definition: error.h:43
#define W5100_S0_RX_RD0
Definition: w5100_driver.h:125
const NetRxAncillary NET_DEFAULT_RX_ANCILLARY
Definition: net_misc.c:104
@ ERROR_FAILURE
Generic error code.
Definition: error.h:45
void w5100WriteReg16(NetInterface *interface, uint16_t address, uint16_t data)
Write 16-bit register.
Definition: w5100_driver.c:491
#define W5100_Sn_MR_PROTOCOL_MACRAW
Definition: w5100_driver.h:344
#define NetRxAncillary
Definition: net_misc.h:40
#define NetInterface
Definition: net.h:36
const NicDriver w5100Driver
W5100 driver.
Definition: w5100_driver.c:44
#define W5100_RMSR_SOCKET0
Definition: w5100_driver.h:307
@ ERROR_INVALID_LENGTH
Definition: error.h:111
@ ERROR_BUFFER_EMPTY
Definition: error.h:141
void w5100WriteData(NetInterface *interface, const uint8_t *data, size_t length)
Write data.
Definition: w5100_driver.c:541
#define NetTxAncillary
Definition: net_misc.h:36
#define W5100_RX_BUFFER
Definition: w5100_driver.h:264
__weak_func void w5100Tick(NetInterface *interface)
W5100 timer handler.
Definition: w5100_driver.c:169
#define MSB(x)
Definition: os_port.h:59
#define W5100_Sn_IR_RECV
Definition: w5100_driver.h:361
#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 W5100_SHAR0
Definition: w5100_driver.h:65
uint16_t w5100ReadReg16(NetInterface *interface, uint16_t address)
Read 16-bit register.
Definition: w5100_driver.c:507
#define W5100_IR
Definition: w5100_driver.h:75
#define W5100_TMSR_SOCKET2_1KB
Definition: w5100_driver.h:320
#define W5100_SHAR2
Definition: w5100_driver.h:67
#define W5100_RMSR_SOCKET2_1KB
Definition: w5100_driver.h:298
bool_t w5100IrqHandler(NetInterface *interface)
W5100 interrupt service routine.
Definition: w5100_driver.c:218
#define W5100_ETH_TX_BUFFER_SIZE
Definition: w5100_driver.h:39
#define TRACE_DEBUG(...)
Definition: debug.h:107
#define W5100_RMSR_SOCKET1_1KB
Definition: w5100_driver.h:303
#define W5100_S0_RX_RSR0
Definition: w5100_driver.h:123
#define W5100_RMSR_SOCKET0_4KB
Definition: w5100_driver.h:310
#define W5100_SHAR1
Definition: w5100_driver.h:66
#define ETH_MTU
Definition: ethernet.h:116
void w5100EnableIrq(NetInterface *interface)
Enable interrupts.
Definition: w5100_driver.c:187
uint8_t n
Ipv6Addr address[]
Definition: ipv6.h:325
uint8_t value[]
Definition: tcp.h:369
#define W5100_CTRL_WRITE
Definition: w5100_driver.h:53
error_t w5100Init(NetInterface *interface)
W5100 controller initialization.
Definition: w5100_driver.c:71
#define W5100_TX_BUFFER
Definition: w5100_driver.h:263
#define W5100_Sn_SR_SOCK_MACRAW
Definition: w5100_driver.h:382
void osSetEvent(OsEvent *event)
Set the specified event object to the signaled state.
#define W5100_TMSR
Definition: w5100_driver.h:81
#define W5100_S0_SR
Definition: w5100_driver.h:97
#define W5100_RMSR_SOCKET0_2KB
Definition: w5100_driver.h:309
#define W5100_Sn_CR_OPEN
Definition: w5100_driver.h:348
#define LOAD16BE(p)
Definition: cpu_endian.h:186
TCP/IP stack core.
#define W5100_IR_S0_INT
Definition: w5100_driver.h:280
NIC driver.
Definition: nic.h:286
#define W5100_TMSR_SOCKET0_2KB
Definition: w5100_driver.h:331
#define W5100_TMSR_SOCKET1_1KB
Definition: w5100_driver.h:325
__weak_func void w5100InitHook(NetInterface *interface)
W5100 custom configuration.
Definition: w5100_driver.c:159
#define W5100_TMSR_SOCKET3_1KB
Definition: w5100_driver.h:315
#define W5100_RMSR_SOCKET0_1KB
Definition: w5100_driver.h:308
@ NO_ERROR
Success.
Definition: error.h:44
#define W5100_Sn_CR_SEND
Definition: w5100_driver.h:353
Debugging facilities.
error_t w5100SendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
Definition: w5100_driver.c:304
#define W5100_IMR_IM_IR0
Definition: w5100_driver.h:289
@ NIC_TYPE_ETHERNET
Ethernet interface.
Definition: nic.h:83