@@ -37,25 +37,7 @@ void setup()
3737 Serial.println (" with " + String (SHIELD_TYPE));
3838 Serial.println (ETHERNET_WEBSERVER_STM32_VERSION);
3939
40- #if USE_ETHERNET_WRAPPER
41-
42- EthernetInit ();
43-
44- #else
45-
46- #if USE_ETHERNET
47- ET_LOGWARN (F (" =========== USE_ETHERNET ===========" ));
48- #elif USE_ETHERNET2
49- ET_LOGWARN (F (" =========== USE_ETHERNET2 ===========" ));
50- #elif USE_ETHERNET3
51- ET_LOGWARN (F (" =========== USE_ETHERNET3 ===========" ));
52- #elif USE_ETHERNET_LARGE
53- ET_LOGWARN (F (" =========== USE_ETHERNET_LARGE ===========" ));
54- #elif USE_ETHERNET_ESP8266
55- ET_LOGWARN (F (" =========== USE_ETHERNET_ESP8266 ===========" ));
56- #else
57- ET_LOGWARN (F (" =========================" ));
58- #endif
40+ ET_LOGWARN3 (F (" Board :" ), BOARD_NAME, F (" , setCsPin:" ), USE_THIS_SS_PIN);
5941
6042 ET_LOGWARN (F (" Default SPI pinout:" ));
6143 ET_LOGWARN1 (F (" MOSI:" ), MOSI);
@@ -64,149 +46,26 @@ void setup()
6446 ET_LOGWARN1 (F (" SS:" ), SS);
6547 ET_LOGWARN (F (" =========================" ));
6648
67- #if defined(ESP8266)
68- // For ESP8266, change for other boards if necessary
69- #ifndef USE_THIS_SS_PIN
70- #define USE_THIS_SS_PIN D2 // For ESP8266
71- #endif
72-
73- ET_LOGWARN1 (F (" ESP8266 setCsPin:" ), USE_THIS_SS_PIN);
74-
75- #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC )
76- // For ESP8266
77- // Pin D0(GPIO16) D1(GPIO5) D2(GPIO4) D3(GPIO0) D4(GPIO2) D8
78- // Ethernet 0 X X X X 0
79- // Ethernet2 X X X X X 0
80- // Ethernet3 X X X X X 0
81- // EthernetLarge X X X X X 0
82- // Ethernet_ESP8266 0 0 0 0 0 0
83- // D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs
84- // Must use library patch for Ethernet, EthernetLarge libraries
85- Ethernet.init (USE_THIS_SS_PIN);
86-
87- #elif USE_ETHERNET3
88- // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer
89- #ifndef ETHERNET3_MAX_SOCK_NUM
90- #define ETHERNET3_MAX_SOCK_NUM 4
91- #endif
92-
93- Ethernet.setCsPin (USE_THIS_SS_PIN);
94- Ethernet.init (ETHERNET3_MAX_SOCK_NUM);
95-
96- #elif USE_CUSTOM_ETHERNET
97-
98- // You have to add initialization for your Custom Ethernet here
99- // This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough
100- Ethernet.init (USE_THIS_SS_PIN);
101-
102- #endif // ( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE )
103-
104- #elif defined(ESP32)
105-
106- // You can use Ethernet.init(pin) to configure the CS pin
107- // Ethernet.init(10); // Most Arduino shields
108- // Ethernet.init(5); // MKR ETH shield
109- // Ethernet.init(0); // Teensy 2.0
110- // Ethernet.init(20); // Teensy++ 2.0
111- // Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet
112- // Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet
113-
114- #ifndef USE_THIS_SS_PIN
115- #define USE_THIS_SS_PIN 22 // For ESP32
116- #endif
117-
118- ET_LOGWARN1 (F (" ESP32 setCsPin:" ), USE_THIS_SS_PIN);
119-
120- // For other boards, to change if necessary
121- #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC )
122- // Must use library patch for Ethernet, EthernetLarge libraries
123- // ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge
124- // ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3
125-
126- // Ethernet.setCsPin (USE_THIS_SS_PIN);
127- Ethernet.init (USE_THIS_SS_PIN);
128-
129- #elif USE_ETHERNET3
130- // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer
131- #ifndef ETHERNET3_MAX_SOCK_NUM
132- #define ETHERNET3_MAX_SOCK_NUM 4
133- #endif
134-
135- Ethernet.setCsPin (USE_THIS_SS_PIN);
136- Ethernet.init (ETHERNET3_MAX_SOCK_NUM);
137-
138- #elif USE_CUSTOM_ETHERNET
139-
140- // You have to add initialization for your Custom Ethernet here
141- // This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough
142- Ethernet.init (USE_THIS_SS_PIN);
143-
144- #endif // ( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE )
145-
146- #else // defined(ESP8266)
147- // unknown board, do nothing, use default SS = 10
148- #ifndef USE_THIS_SS_PIN
149- #define USE_THIS_SS_PIN 10 // For other boards
150- #endif
151-
152- ET_LOGWARN3 (F (" Board :" ), BOARD_NAME, F (" , setCsPin:" ), USE_THIS_SS_PIN);
153-
154- // For other boards, to change if necessary
155- #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC )
156- // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries
157-
158- Ethernet.init (USE_THIS_SS_PIN);
159-
160- #elif USE_ETHERNET3
161- // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer
162- #ifndef ETHERNET3_MAX_SOCK_NUM
163- #define ETHERNET3_MAX_SOCK_NUM 4
164- #endif
165-
166- Ethernet.setCsPin (USE_THIS_SS_PIN);
167- Ethernet.init (ETHERNET3_MAX_SOCK_NUM);
168-
169- #elif USE_CUSTOM_ETHERNET
170-
171- // You have to add initialization for your Custom Ethernet here
172- // This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough
173- Ethernet.init (USE_THIS_SS_PIN);
174-
175- #endif // ( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE )
176-
177- #endif // defined(ESP8266)
178-
179-
180- #endif // USE_ETHERNET_WRAPPER
181-
182-
49+ #if !(USE_BUILTIN_ETHERNET || USE_UIP_ETHERNET)
50+ // For other boards, to change if necessary
51+ #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC )
52+ Ethernet.init (USE_THIS_SS_PIN);
53+
54+ #elif USE_CUSTOM_ETHERNET
55+ // You have to add initialization for your Custom Ethernet here
56+ // This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough
57+ // Ethernet.init(USE_THIS_SS_PIN);
58+
59+ #endif // ( ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC )
60+ #endif
61+
18362 // start the ethernet connection and the server:
18463 // Use DHCP dynamic IP and random mac
18564 uint16_t index = millis () % NUMBER_OF_MAC;
18665 // Use Static IP
18766 // Ethernet.begin(mac[index], ip);
18867 Ethernet.begin (mac[index]);
189-
190- // Just info to know how to connect correctly
191- Serial.println (" =========================" );
192- Serial.println (" Currently Used SPI pinout:" );
193- Serial.print (" MOSI:" );
194- Serial.println (MOSI);
195- Serial.print (" MISO:" );
196- Serial.println (MISO);
197- Serial.print (" SCK:" );
198- Serial.println (SCK);
199- Serial.print (" SS:" );
200- Serial.println (SS);
201- #if USE_ETHERNET3
202- Serial.print (" SPI_CS:" );
203- Serial.println (SPI_CS);
204- #endif
205- Serial.println (F (" =========================" ));
206-
207- Serial.print (F (" Using mac index = " ));
208- Serial.println (index);
209-
68+
21069 Serial.print (F (" Connected! IP address: " ));
21170 Serial.println (Ethernet.localIP ());
21271}
0 commit comments