Skip to content
This repository was archived by the owner on Jan 29, 2023. It is now read-only.

Commit aa5b97c

Browse files
authored
v1.1.0 to use Ethernet_Generic library
### Releases v1.1.0 1. Use new [Ethernet_Generic library](https://github.com/khoih-prog/Ethernet_Generic) as default for W5x00. 2. Add support to `SPI1` for `RP2040` using [`Earle Philhower's arduino-pico` core](https://github.com/earlephilhower/arduino-pico) 3. Add support to WIZNet W5100S, such as [**WIZnet Ethernet HAT**](https://docs.wiznet.io/Product/Open-Source-Hardware/wiznet_ethernet_hat) and [**W5100S-EVB-Pico**](https://docs.wiznet.io/Product/iEthernet/W5100S/w5100s-evb-pico)
1 parent 715df9e commit aa5b97c

File tree

14 files changed

+339
-509
lines changed

14 files changed

+339
-509
lines changed

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p
1414

1515
Please ensure to specify the following:
1616

17-
* Arduino IDE version (e.g. 1.8.16) or Platform.io version
18-
* `RP2040` Core Version (e.g. Arduino-mbed RP2040 v2.5.2 or arduino-pico core v1.9.5)
17+
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
18+
* `RP2040` Core Version (e.g. Arduino-mbed RP2040 v3.0.1 or arduino-pico core v1.13.3)
1919
* `RP2040` Board type (e.g. NANO_RP2040_CONNECT, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040, GENERIC_RP2040, etc.)
2020
* Contextual information (e.g. what you were trying to achieve)
2121
* Simplest possible steps to reproduce
@@ -27,11 +27,11 @@ Please ensure to specify the following:
2727
### Example
2828

2929
```
30-
Arduino IDE version: 1.8.16
31-
Arduino-mbed RP2040 v2.5.2
30+
Arduino IDE version: 1.8.19
31+
Arduino-mbed RP2040 v3.0.1
3232
NANO_RP2040_CONNECT Module
3333
OS: Ubuntu 20.04 LTS
34-
Linux xy-Inspiron-3593 5.4.0-96-generic #109-Ubuntu SMP Wed Jan 12 16:49:16 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
34+
Linux xy-Inspiron-3593 5.13.0-40-generic #45~20.04.1-Ubuntu SMP Mon Apr 4 09:38:31 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
3535
3636
Context:
3737
I encountered a crash while using TimerInterrupt.

README.md

Lines changed: 151 additions & 161 deletions
Large diffs are not rendered by default.

changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
## Table of Contents
1313

1414
* [Changelog](#changelog)
15+
* [Releases v1.1.0](#releases-v110)
1516
* [Releases v1.0.8](#releases-v108)
1617
* [Releases v1.0.7](#releases-v107)
1718
* [Releases v1.0.6](#releases-v106)
@@ -27,6 +28,12 @@
2728

2829
## Changelog
2930

31+
### Releases v1.1.0
32+
33+
1. Use new [Ethernet_Generic library](https://github.com/khoih-prog/Ethernet_Generic) as default for W5x00.
34+
2. Add support to `SPI1` for `RP2040` using [`Earle Philhower's arduino-pico` core](https://github.com/earlephilhower/arduino-pico)
35+
3. Add support to WIZNet W5100S, such as [**WIZnet Ethernet HAT**](https://docs.wiznet.io/Product/Open-Source-Hardware/wiznet_ethernet_hat) and [**W5100S-EVB-Pico**](https://docs.wiznet.io/Product/iEthernet/W5100S/w5100s-evb-pico)
36+
3037
### Releases v1.0.8
3138

3239
1. Update dependency on [Timezone_Generic Library](https://github.com/khoih-prog/Timezone_Generic)

examples/Alarm/RP2040_RTC_Alarm/RP2040_RTC_Alarm.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void printDateTime(time_t t, const char *tz)
109109
void setup()
110110
{
111111
Serial.begin(115200);
112-
while (!Serial);
112+
while (!Serial && millis() < 5000);
113113

114114
delay(200);
115115

examples/Alarm/RP2040_RTC_Alarm_Ethernet/RP2040_RTC_Alarm_Ethernet.ino

Lines changed: 44 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -238,32 +238,10 @@ void printDateTime(time_t t, const char *tz)
238238

239239
//////////////////////////////////////////
240240

241-
void setup()
241+
void initEthernet()
242242
{
243-
Serial.begin(115200);
244-
while (!Serial);
245-
246-
delay(200);
247-
248-
Serial.print(F("\nStart RP2040_RTC_Alarm_Ethernet on ")); Serial.print(BOARD_NAME);
249-
Serial.print(F(" with ")); Serial.println(SHIELD_TYPE);
250-
Serial.println(RP2040_RTC_VERSION);
251-
Serial.println(TIMEZONE_GENERIC_VERSION);
252-
253-
#if USE_ETHERNET_WRAPPER
254-
255-
EthernetInit();
256-
257-
#else
258-
259-
#if USE_ETHERNET
260-
ET_LOGWARN(F("=========== USE_ETHERNET ==========="));
261-
#elif USE_ETHERNET2
262-
ET_LOGWARN(F("=========== USE_ETHERNET2 ==========="));
263-
#elif USE_ETHERNET3
264-
ET_LOGWARN(F("=========== USE_ETHERNET3 ==========="));
265-
#elif USE_ETHERNET_LARGE
266-
ET_LOGWARN(F("=========== USE_ETHERNET_LARGE ==========="));
243+
#if USE_ETHERNET_GENERIC
244+
ET_LOGWARN(F("=========== USE_ETHERNET_GENERIC ==========="));
267245
#elif USE_ETHERNET_ESP8266
268246
ET_LOGWARN(F("=========== USE_ETHERNET_ESP8266 ==========="));
269247
#else
@@ -277,122 +255,37 @@ void setup()
277255
ET_LOGWARN1(F("SS:"), SS);
278256
ET_LOGWARN(F("========================="));
279257

280-
#if defined(ESP8266)
281-
// For ESP8266, change for other boards if necessary
282-
#ifndef USE_THIS_SS_PIN
283-
#define USE_THIS_SS_PIN D2 // For ESP8266
284-
#endif
285-
286-
ET_LOGWARN1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN);
287-
288-
#if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC )
289-
// For ESP8266
290-
// Pin D0(GPIO16) D1(GPIO5) D2(GPIO4) D3(GPIO0) D4(GPIO2) D8
291-
// Ethernet 0 X X X X 0
292-
// Ethernet2 X X X X X 0
293-
// Ethernet3 X X X X X 0
294-
// EthernetLarge X X X X X 0
295-
// Ethernet_ESP8266 0 0 0 0 0 0
296-
// D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs
297-
// Must use library patch for Ethernet, EthernetLarge libraries
298-
Ethernet.init (USE_THIS_SS_PIN);
299-
300-
#elif USE_ETHERNET3
301-
// Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer
302-
#ifndef ETHERNET3_MAX_SOCK_NUM
303-
#define ETHERNET3_MAX_SOCK_NUM 4
304-
#endif
305-
306-
Ethernet.setCsPin (USE_THIS_SS_PIN);
307-
Ethernet.init (ETHERNET3_MAX_SOCK_NUM);
308-
309-
#elif USE_CUSTOM_ETHERNET
310-
311-
// You have to add initialization for your Custom Ethernet here
312-
// This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough
313-
Ethernet.init(USE_THIS_SS_PIN);
314-
315-
#endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE )
316-
317-
#elif defined(ESP32)
318-
319-
// You can use Ethernet.init(pin) to configure the CS pin
320-
//Ethernet.init(10); // Most Arduino shields
321-
//Ethernet.init(5); // MKR ETH shield
322-
//Ethernet.init(0); // Teensy 2.0
323-
//Ethernet.init(20); // Teensy++ 2.0
324-
//Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet
325-
//Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet
326-
327-
#ifndef USE_THIS_SS_PIN
328-
#define USE_THIS_SS_PIN 22 // For ESP32
329-
#endif
330-
331-
ET_LOGWARN1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN);
332-
333-
// For other boards, to change if necessary
334-
#if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC )
335-
// Must use library patch for Ethernet, EthernetLarge libraries
336-
// ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge
337-
// ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3
338-
339-
//Ethernet.setCsPin (USE_THIS_SS_PIN);
340-
Ethernet.init (USE_THIS_SS_PIN);
341-
342-
#elif USE_ETHERNET3
343-
// Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer
344-
#ifndef ETHERNET3_MAX_SOCK_NUM
345-
#define ETHERNET3_MAX_SOCK_NUM 4
346-
#endif
347-
348-
Ethernet.setCsPin (USE_THIS_SS_PIN);
349-
Ethernet.init (ETHERNET3_MAX_SOCK_NUM);
258+
#if ETHERNET_USE_RPIPICO
350259

351-
#elif USE_CUSTOM_ETHERNET
352-
353-
// You have to add initialization for your Custom Ethernet here
354-
// This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough
355-
Ethernet.init(USE_THIS_SS_PIN);
356-
357-
#endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE )
358-
359-
#else //defined(ESP8266)
360-
// unknown board, do nothing, use default SS = 10
361-
#ifndef USE_THIS_SS_PIN
362-
#define USE_THIS_SS_PIN 10 // For other boards
363-
#endif
260+
pinMode(USE_THIS_SS_PIN, OUTPUT);
261+
digitalWrite(USE_THIS_SS_PIN, HIGH);
262+
263+
// ETHERNET_USE_RPIPICO, use default SS = 5 or 17
264+
#ifndef USE_THIS_SS_PIN
265+
#if defined(ARDUINO_ARCH_MBED)
266+
#define USE_THIS_SS_PIN 5 // For Arduino Mbed core
267+
#else
268+
#define USE_THIS_SS_PIN 17 // For E.Philhower core
269+
#endif
270+
#endif
364271

365-
ET_LOGWARN3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN);
272+
ET_LOGWARN1(F("RPIPICO setCsPin:"), USE_THIS_SS_PIN);
366273

367274
// For other boards, to change if necessary
368-
#if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC )
369-
// Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries
370-
371-
Ethernet.init (USE_THIS_SS_PIN);
275+
#if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC )
276+
// Must use library patch for Ethernet, EthernetLarge libraries
277+
// For RPI Pico using Arduino Mbed RP2040 core
278+
// SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5
279+
// For RPI Pico using E. Philhower RP2040 core
280+
// SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17
281+
// Default pin 5/17 to SS/CS
282+
283+
//Ethernet.setCsPin (USE_THIS_SS_PIN);
284+
Ethernet.init (USE_THIS_SS_PIN);
285+
#endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC )
372286

373-
#elif USE_ETHERNET3
374-
// Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer
375-
#ifndef ETHERNET3_MAX_SOCK_NUM
376-
#define ETHERNET3_MAX_SOCK_NUM 4
377287
#endif
378288

379-
Ethernet.setCsPin (USE_THIS_SS_PIN);
380-
Ethernet.init (ETHERNET3_MAX_SOCK_NUM);
381-
382-
#elif USE_CUSTOM_ETHERNET
383-
384-
// You have to add initialization for your Custom Ethernet here
385-
// This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough
386-
Ethernet.init(USE_THIS_SS_PIN);
387-
388-
#endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE )
389-
390-
#endif //defined(ESP8266)
391-
392-
393-
#endif //USE_ETHERNET_WRAPPER
394-
395-
396289
// start the ethernet connection and the server:
397290
// Use DHCP dynamic IP and random mac
398291
uint16_t index = millis() % NUMBER_OF_MAC;
@@ -407,16 +300,29 @@ void setup()
407300
Serial.print(F("MISO:")); Serial.println(MISO);
408301
Serial.print(F("SCK:")); Serial.println(SCK);
409302
Serial.print(F("SS:")); Serial.println(SS);
410-
#if USE_ETHERNET3
411-
Serial.print(F("SPI_CS:")); Serial.println(SPI_CS);
412-
#endif
413303
Serial.println(F("========================="));
414304

415-
Serial.print(F("Using mac index = ")); Serial.println(index);
305+
Serial.print(F("Using mac index = "));
306+
Serial.println(index);
416307

417308
// you're connected now, so print out the data
418309
Serial.print(F("You're connected to the network, IP = "));
419310
Serial.println(Ethernet.localIP());
311+
}
312+
313+
void setup()
314+
{
315+
Serial.begin(115200);
316+
while (!Serial && millis() < 5000);
317+
318+
delay(200);
319+
320+
Serial.print(F("\nStart RP2040_RTC_Alarm_Ethernet on ")); Serial.print(BOARD_NAME);
321+
Serial.print(F(" with ")); Serial.println(SHIELD_TYPE);
322+
Serial.println(RP2040_RTC_VERSION);
323+
Serial.println(TIMEZONE_GENERIC_VERSION);
324+
325+
initEthernet();
420326

421327
myTZ = new Timezone(myDST, mySTD);
422328

examples/Alarm/RP2040_RTC_Alarm_Ethernet/defines.h

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,17 @@
2121
#undef ETHERNET_USE_RP2040
2222
#endif
2323
#define ETHERNET_USE_RP2040 true
24+
#define ETHERNET_USE_RPIPICO true
2425
#endif
2526

26-
#if ETHERNET_USE_RP2040
27+
#if ETHERNET_USE_RP2040 || ETHERNET_USE_RPIPICO
2728

2829
// Default pin 5 (in Mbed) or 17 to SS/CS
2930
#if defined(ARDUINO_ARCH_MBED)
3031
// For RPI Pico using Arduino Mbed RP2040 core
3132
// SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5
32-
// SDA: 6, SCL: 7
33-
// For Nano_RP2040_Connect using Arduino Mbed RP2040 core
34-
// SDA: 14 = A4, SCL: 19 = A5
3533

36-
#define USE_THIS_SS_PIN 5
34+
#define USE_THIS_SS_PIN 17 //5
3735

3836
#if defined(BOARD_NAME)
3937
#undef BOARD_NAME
@@ -51,8 +49,7 @@
5149

5250
#else
5351
// For RPI Pico using E. Philhower RP2040 core
54-
// SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17
55-
// SDA: 4, SCL: 5
52+
// SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17
5653
#define USE_THIS_SS_PIN 17
5754

5855
#endif
@@ -91,35 +88,28 @@
9188
// Check @ defined(SEEED_XIAO_M0)
9289
//#define USE_THIS_SS_PIN 22 //21 //5 //4 //2 //15
9390

94-
// Only one of the following to be true
95-
#define USE_ETHERNET false
96-
#define USE_ETHERNET2 false
97-
#define USE_ETHERNET3 false
98-
#define USE_ETHERNET_LARGE true
99-
#define USE_ETHERNET_ESP8266 false
91+
// Only one if the following to be true
92+
#define USE_ETHERNET_GENERIC true
93+
#define USE_ETHERNET_ESP8266 false
10094
#define USE_ETHERNET_ENC false
10195
#define USE_CUSTOM_ETHERNET false
10296

103-
104-
#if ( USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE || USE_ETHERNET_ESP8266 || USE_ETHERNET_ENC )
97+
#if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ESP8266 || USE_ETHERNET_ENC )
10598
#ifdef USE_CUSTOM_ETHERNET
10699
#undef USE_CUSTOM_ETHERNET
107100
#endif
108101
#define USE_CUSTOM_ETHERNET false //true
109102
#endif
110103

111-
#if USE_ETHERNET3
112-
#include "Ethernet3.h"
113-
#warning Using Ethernet3 lib
114-
#define SHIELD_TYPE "W5x00 using Ethernet3 Library"
115-
#elif USE_ETHERNET2
116-
#include "Ethernet2.h"
117-
#warning Using Ethernet2 lib
118-
#define SHIELD_TYPE "W5x00 using Ethernet2 Library"
119-
#elif USE_ETHERNET_LARGE
120-
#include "EthernetLarge.h"
121-
#warning Using EthernetLarge lib
122-
#define SHIELD_TYPE "W5x00 using EthernetLarge Library"
104+
#if USE_ETHERNET_GENERIC
105+
#define ETHERNET_LARGE_BUFFERS
106+
107+
#define _ETG_LOGLEVEL_ 1
108+
109+
#include "Ethernet_Generic.h"
110+
111+
#warning Using Ethernet_Generic lib
112+
#define SHIELD_TYPE "W5x00 using Ethernet_Generic Library"
123113
#elif USE_ETHERNET_ESP8266
124114
#include "Ethernet_ESP8266.h"
125115
#warning Using Ethernet_ESP8266 lib
@@ -134,10 +124,13 @@
134124
#warning Using Custom Ethernet library. You must include a library and initialize.
135125
#define SHIELD_TYPE "Custom Ethernet using Ethernet_XYZ Library"
136126
#else
137-
#define USE_ETHERNET true
138-
#include "Ethernet.h"
139-
#warning Using Ethernet lib
140-
#define SHIELD_TYPE "W5x00 using Ethernet Library"
127+
#ifdef USE_ETHERNET_GENERIC
128+
#undef USE_ETHERNET_GENERIC
129+
#endif
130+
#define USE_ETHERNET_GENERIC true
131+
#include "Ethernet_Generic.h"
132+
#warning Using default Ethernet_Generic lib
133+
#define SHIELD_TYPE "W5x00 using default Ethernet_Generic Library"
141134
#endif
142135

143136
// Ethernet_Shield_W5200, EtherCard, EtherSia not supported

examples/Alarm/RP2040_RTC_Alarm_WiFiNINA/RP2040_RTC_Alarm_WiFiNINA.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ void printDateTime(time_t t, const char *tz)
241241
void setup()
242242
{
243243
Serial.begin(115200);
244-
while (!Serial);
244+
while (!Serial && millis() < 5000);
245245

246246
delay(200);
247247

examples/Time/RP2040_RTC_Time/RP2040_RTC_Time.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void printDateTime(time_t t, const char *tz)
6060
void setup()
6161
{
6262
Serial.begin(115200);
63-
while (!Serial);
63+
while (!Serial && millis() < 5000);
6464

6565
delay(200);
6666

0 commit comments

Comments
 (0)