Skip to content
This repository was archived by the owner on Feb 9, 2022. It is now read-only.

Commit 46eafc6

Browse files
authored
v1.0.16
### Releases v1.0.16 1. Sync with EthernetWebServer v.1.0.9 2. Use 25MHz for W5x00. 3. Use EthernetWrapper feature of EthernetWebServer v.1.0.9.
1 parent 0e2a7fb commit 46eafc6

25 files changed

+598
-247
lines changed

LibraryPatches/Ethernet/src/Ethernet.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases
77
Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer
88
Licensed under MIT license
9-
Version: 1.0.8
9+
Version: 1.0.9
1010
1111
Copyright 2018 Paul Stoffregen
1212
@@ -39,7 +39,8 @@
3939
More Custom Ethernet libraries supported such as Ethernet2, Ethernet3, EthernetLarge
4040
1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards
4141
1.0.7 K Hoang 30/04/2020 Add ENC28J60 support to ESP32/ESP8266 boards
42-
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards. Sync with ESP8266 core 2.7.1.
42+
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards.
43+
1.0.9 K Hoang 15/05/2020 Add EthernetWrapper.h for easier W5x00 support as well as more Ethernet libs in the future.
4344
*****************************************************************************************************************************/
4445

4546
#include <Arduino.h>
@@ -63,6 +64,7 @@ void EthernetClass::setRstPin(uint8_t pinRST)
6364
void EthernetClass::setCsPin(uint8_t pinCS)
6465
{
6566
_pinCS = pinCS;
67+
W5100.setSS(pinCS);
6668

6769
#if ( ETHERNET_DEBUG > 0 )
6870
Serial.print("Input pinCS = ");
@@ -104,11 +106,9 @@ int EthernetClass::begin(uint8_t *mac, unsigned long timeout, unsigned long resp
104106
#endif
105107

106108
// Initialise the basic info
107-
// KH
108-
if (W5100.init(MAX_SOCK_NUM, _pinCS) == 0)
109+
if (W5100.init() == 0)
109110
return 0;
110111

111-
112112
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
113113
W5100.setMACAddress(mac);
114114
W5100.setIPAddress(IPAddress(0,0,0,0).raw_address());
@@ -157,7 +157,8 @@ void EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress g
157157

158158
void EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet)
159159
{
160-
if (W5100.init(MAX_SOCK_NUM, _pinCS) == 0)
160+
// Initialise the basic info
161+
if (W5100.init() == 0)
161162
return;
162163

163164
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);

LibraryPatches/Ethernet/src/Ethernet.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases
77
Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer
88
Licensed under MIT license
9-
Version: 1.0.8
9+
Version: 1.0.9
1010
1111
Copyright 2018 Paul Stoffregen
1212
@@ -39,7 +39,8 @@
3939
More Custom Ethernet libraries supported such as Ethernet2, Ethernet3, EthernetLarge
4040
1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards
4141
1.0.7 K Hoang 30/04/2020 Add ENC28J60 support to ESP32/ESP8266 boards
42-
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards. Sync with ESP8266 core 2.7.1.
42+
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards.
43+
1.0.9 K Hoang 15/05/2020 Add EthernetWrapper.h for easier W5x00 support as well as more Ethernet libs in the future.
4344
*****************************************************************************************************************************/
4445

4546
#ifndef ethernet_h_

LibraryPatches/Ethernet/src/EthernetServer.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases
77
Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer
88
Licensed under MIT license
9-
Version: 1.0.8
9+
Version: 1.0.9
1010
1111
Copyright 2018 Paul Stoffregen
1212
@@ -37,9 +37,10 @@
3737
1.0.5 K Hoang 24/04/2020 Add support to nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense,
3838
Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B30_ublox, etc.
3939
More Custom Ethernet libraries supported such as Ethernet2, Ethernet3, EthernetLarge
40-
1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards
40+
1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards
4141
1.0.7 K Hoang 30/04/2020 Add ENC28J60 support to ESP32/ESP8266 boards
42-
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards. Sync with ESP8266 core 2.7.1.
42+
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards.
43+
1.0.9 K Hoang 15/05/2020 Add EthernetWrapper.h for easier W5x00 support as well as more Ethernet libs in the future.
4344
*****************************************************************************************************************************/
4445

4546
#include <Arduino.h>

LibraryPatches/Ethernet/src/utility/w5100.cpp

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,26 @@
66
Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases
77
Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer
88
Licensed under MIT license
9-
Version: 1.0.8
9+
Version: 1.0.9
1010
1111
Copyright 2018 Paul Stoffregen
12-
Copyright (c) 2010 by Cristian Maglie <c.maglie@bug.st>
1312
14-
This file is free software; you can redistribute it and/or modify
15-
it under the terms of either the GNU General Public License version 2
16-
or the GNU Lesser General Public License version 2.1, both as
17-
published by the Free Software Foundation.
13+
Permission is hereby granted, free of charge, to any person obtaining a copy of this
14+
software and associated documentation files (the "Software"), to deal in the Software
15+
without restriction, including without limitation the rights to use, copy, modify,
16+
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
17+
permit persons to whom the Software is furnished to do so, subject to the following
18+
conditions:
19+
20+
The above copyright notice and this permission notice shall be included in all
21+
copies or substantial portions of the Software.
22+
23+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
24+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
25+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1829
1930
Version Modified By Date Comments
2031
------- ----------- ---------- -----------
@@ -26,9 +37,10 @@
2637
1.0.5 K Hoang 24/04/2020 Add support to nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense,
2738
Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B30_ublox, etc.
2839
More Custom Ethernet libraries supported such as Ethernet2, Ethernet3, EthernetLarge
29-
1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards
40+
1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards
3041
1.0.7 K Hoang 30/04/2020 Add ENC28J60 support to ESP32/ESP8266 boards
31-
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards. Sync with ESP8266 core 2.7.1.
42+
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards.
43+
1.0.9 K Hoang 15/05/2020 Add EthernetWrapper.h for easier W5x00 support as well as more Ethernet libs in the future.
3244
*****************************************************************************************************************************/
3345

3446
#include <Arduino.h>
@@ -91,16 +103,16 @@
91103
//KH for ESP32
92104
#elif defined(ESP32)
93105
//pin SS already defined in ESP32 as pin 5, don't use this as conflict with SPIFFS, EEPROM, etc.
94-
// Use in GPIO13
95-
#warning w5100.cpp Use ESP32, change SS_PIN_DEFAULT to GPIO13, MOSI(23), MISO(19), SCK(18)
96-
#define SS_PIN_DEFAULT 13 //SS
106+
// Use in GPIO22
107+
#warning w5100.cpp Use ESP32, change SS_PIN_DEFAULT to GPIO22, MOSI(23), MISO(19), SCK(18)
108+
#define SS_PIN_DEFAULT 22 //SS
97109
///////
98110

99111
//KH for ESP8266
100112
#elif defined(ESP8266)
101-
//pin SS already defined in ESP8266 as pin 15. Conflict => Move to pin 5 (D1)
102-
#warning w5100.cpp Use ESP8266, change SS_PIN_DEFAULT to SS(5), MOSI(13), MISO(12), SCK(14)
103-
#define SS_PIN_DEFAULT D1 // 5, SS
113+
//pin SS already defined in ESP8266 as pin 15. Conflict => Move to pin GPIO4 (D2)
114+
#warning w5100.cpp Use ESP8266, change SS_PIN_DEFAULT to SS(4), MOSI(13), MISO(12), SCK(14)
115+
#define SS_PIN_DEFAULT D2 // GPIO4, SS
104116

105117
///////
106118

@@ -167,7 +179,7 @@ uint8_t W5100Class::init(uint8_t socketNumbers, uint8_t new_ss_pin)
167179
// reset time, this can be edited or removed.
168180
delay(560);
169181

170-
W5100Class::ss_pin = new_ss_pin;
182+
//W5100Class::ss_pin = new_ss_pin;
171183

172184
#if ( W5100_DEBUG > 0 )
173185
//KH
@@ -178,7 +190,7 @@ uint8_t W5100Class::init(uint8_t socketNumbers, uint8_t new_ss_pin)
178190
Serial.print(", W5100Class::ss_pin = ");
179191
Serial.println(W5100Class::ss_pin);
180192
#endif
181-
193+
182194
SPI.begin();
183195

184196
initSS();
@@ -314,7 +326,7 @@ uint8_t W5100Class::softReset(void)
314326
{
315327
uint16_t count=0;
316328

317-
#if ( W5100_DEBUG > 0 )
329+
#if ( W5100_DEBUG > 1 )
318330
Serial.println("Wiznet soft reset");
319331
#endif
320332

LibraryPatches/Ethernet/src/utility/w5100.h

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,26 @@
66
Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases
77
Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer
88
Licensed under MIT license
9-
Version: 1.0.8
9+
Version: 1.0.9
1010
1111
Copyright 2018 Paul Stoffregen
12-
Copyright (c) 2010 by Cristian Maglie <c.maglie@bug.st>
1312
14-
This file is free software; you can redistribute it and/or modify
15-
it under the terms of either the GNU General Public License version 2
16-
or the GNU Lesser General Public License version 2.1, both as
17-
published by the Free Software Foundation.
13+
Permission is hereby granted, free of charge, to any person obtaining a copy of this
14+
software and associated documentation files (the "Software"), to deal in the Software
15+
without restriction, including without limitation the rights to use, copy, modify,
16+
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
17+
permit persons to whom the Software is furnished to do so, subject to the following
18+
conditions:
19+
20+
The above copyright notice and this permission notice shall be included in all
21+
copies or substantial portions of the Software.
22+
23+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
24+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
25+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1829
1930
Version Modified By Date Comments
2031
------- ----------- ---------- -----------
@@ -26,9 +37,10 @@
2637
1.0.5 K Hoang 24/04/2020 Add support to nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense,
2738
Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B30_ublox, etc.
2839
More Custom Ethernet libraries supported such as Ethernet2, Ethernet3, EthernetLarge
29-
1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards
40+
1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards
3041
1.0.7 K Hoang 30/04/2020 Add ENC28J60 support to ESP32/ESP8266 boards
31-
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards. Sync with ESP8266 core 2.7.1.
42+
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards.
43+
1.0.9 K Hoang 15/05/2020 Add EthernetWrapper.h for easier W5x00 support as well as more Ethernet libs in the future.
3244
*****************************************************************************************************************************/
3345

3446
// w5100.h contains private W5x00 hardware "driver" level definitions
@@ -40,25 +52,25 @@
4052
#include <Arduino.h>
4153
#include <SPI.h>
4254

43-
#ifndef USE_W5500
44-
#define USE_W5500 false
55+
#ifndef USE_W5100
56+
#define USE_W5100 false
4557
#else
46-
#define USE_W5500 true
58+
#define USE_W5100 true
4759
#endif
4860

49-
#if USE_W5500
61+
#if !USE_W5100
5062

51-
// Safe for W5200 and W5500, but too fast for W5100
52-
// Uncomment this if you know you'll never need W5100 support.
53-
// Higher SPI clock only results in faster transfer to hosts on a LAN
54-
// or with very low packet latency. With ordinary internet latency,
55-
// the TCP window size & packet loss determine your overall speed.
56-
#warning Use 30MHz clock for W5200/W5500. Not for W5100
57-
#define SPI_ETHERNET_SETTINGS SPISettings(30000000, MSBFIRST, SPI_MODE0)
63+
// Safe for W5200 and W5500, but also tested OK on W5100
64+
// Use 14MHz if you know your W5100 can't run
65+
// Higher SPI clock results in faster transfer to hosts on a LAN
66+
// or with very low packet latency. With ordinary internet latency,
67+
// the TCP window size & packet loss determine your overall speed.
68+
#warning Use 25MHz clock for W5200/W5500. Not for W5100
69+
#define SPI_ETHERNET_SETTINGS SPISettings(25000000, MSBFIRST, SPI_MODE0)
5870

5971
#else
6072

61-
// Safe for all chips
73+
// Safe for all chips but too slow
6274
#define SPI_ETHERNET_SETTINGS SPISettings(14000000, MSBFIRST, SPI_MODE0)
6375
#warning Use 14MHz clock for W5100/W5200/W5500. Slow.
6476

LibraryPatches/EthernetLarge/src/EthernetLarge.cpp

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases
77
Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer
88
Licensed under MIT license
9-
Version: 1.0.8
9+
Version: 1.0.9
1010
1111
Copyright 2018 Paul Stoffregen
1212
@@ -39,14 +39,17 @@
3939
More Custom Ethernet libraries supported such as Ethernet2, Ethernet3, EthernetLarge
4040
1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards
4141
1.0.7 K Hoang 30/04/2020 Add ENC28J60 support to ESP32/ESP8266 boards
42-
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards. Sync with ESP8266 core 2.7.1.
42+
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards.
43+
1.0.9 K Hoang 15/05/2020 Add EthernetWrapper.h for easier W5x00 support as well as more Ethernet libs in the future.
4344
*****************************************************************************************************************************/
4445

4546
#include <Arduino.h>
4647
#include "EthernetLarge.h"
4748
#include "utility/w5100.h"
4849
#include "Dhcp.h"
4950

51+
#define ETHERNET_DEBUG 1
52+
5053
IPAddress EthernetClass::_dnsServerAddress;
5154
DhcpClass* EthernetClass::_dhcp = NULL;
5255

@@ -60,10 +63,14 @@ void EthernetClass::setRstPin(uint8_t pinRST)
6063
void EthernetClass::setCsPin(uint8_t pinCS)
6164
{
6265
_pinCS = pinCS;
66+
W5100.setSS(pinCS);
67+
68+
#if ( ETHERNET_DEBUG > 0 )
6369
Serial.print("Input pinCS = ");
6470
Serial.println(pinCS);
6571
Serial.print("_pinCS = ");
6672
Serial.println(_pinCS);
73+
#endif
6774
}
6875

6976
void EthernetClass::initMaxSockNum(uint8_t maxSockNum)
@@ -92,10 +99,13 @@ int EthernetClass::begin(uint8_t *mac, unsigned long timeout, unsigned long resp
9299
static DhcpClass s_dhcp;
93100
_dhcp = &s_dhcp;
94101

102+
#if ( ETHERNET_DEBUG > 0 )
103+
Serial.print("_pinCS = ");
104+
Serial.print(_pinCS);
105+
#endif
106+
95107
// Initialise the basic info
96-
//if (W5100.init() == 0) return 0;
97-
// KH
98-
if (W5100.init(MAX_SOCK_NUM, _pinCS) == 0)
108+
if (W5100.init() == 0)
99109
return 0;
100110

101111

@@ -146,13 +156,13 @@ void EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress g
146156

147157
void EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet)
148158
{
149-
//if (W5100.init() == 0) return;
150-
// KH
151-
if (W5100.init(MAX_SOCK_NUM, _pinCS) == 0)
159+
// Initialise the basic info
160+
if (W5100.init() == 0)
161+
return;
152162

153163
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
154164
W5100.setMACAddress(mac);
155-
#ifdef ESP8266
165+
#if ( defined(ESP8266) || defined(ESP32) )
156166
W5100.setIPAddress(&ip[0]);
157167
W5100.setGatewayIp(&gateway[0]);
158168
W5100.setSubnetMask(&subnet[0]);
@@ -200,7 +210,8 @@ int EthernetClass::maintain()
200210
if (_dhcp != NULL) {
201211
// we have a pointer to dhcp, use it
202212
rc = _dhcp->checkLease();
203-
switch (rc) {
213+
switch (rc)
214+
{
204215
case DHCP_CHECK_NONE:
205216
//nothing done
206217
break;

LibraryPatches/EthernetLarge/src/EthernetLarge.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases
77
Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer
88
Licensed under MIT license
9-
Version: 1.0.8
9+
Version: 1.0.9
1010
1111
Copyright 2018 Paul Stoffregen
1212
@@ -39,7 +39,8 @@
3939
More Custom Ethernet libraries supported such as Ethernet2, Ethernet3, EthernetLarge
4040
1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards
4141
1.0.7 K Hoang 30/04/2020 Add ENC28J60 support to ESP32/ESP8266 boards
42-
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards. Sync with ESP8266 core 2.7.1.
42+
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards.
43+
1.0.9 K Hoang 15/05/2020 Add EthernetWrapper.h for easier W5x00 support as well as more Ethernet libs in the future.
4344
*****************************************************************************************************************************/
4445

4546
#ifndef ethernet_h_
@@ -123,7 +124,7 @@ class EthernetClass {
123124
EthernetLinkStatus linkStatus();
124125
EthernetHardwareStatus hardwareStatus();
125126

126-
// Manaul configuration
127+
// Manual configuration
127128
void begin(uint8_t *mac, IPAddress ip);
128129
void begin(uint8_t *mac, IPAddress ip, IPAddress dns);
129130
void begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway);

0 commit comments

Comments
 (0)