@@ -64,26 +64,26 @@ void heartBeatPrint()
64
64
65
65
localEthernetIP = Ethernet.localIP ();
66
66
67
- #if (USE_ETHERNET2 || USE_ETHERNET3 )
67
+ #if (USE_ETHERNET_GENERIC )
68
68
// To modify Ethernet2 library
69
69
linkStatus = Ethernet.link ();
70
- ET_LOGINFO3 (F (" localEthernetIP = " ), localEthernetIP, F (" , linkStatus = " ), (linkStatus == 1 ) ? F (" LinkON" ) : F (" LinkOFF" ) );
70
+ ETM_LOGINFO3 (F (" localEthernetIP = " ), localEthernetIP, F (" , linkStatus = " ), (linkStatus == 1 ) ? F (" LinkON" ) : F (" LinkOFF" ) );
71
71
72
72
if ( ( linkStatus == 1 ) && ((uint32_t ) localEthernetIP != 0 ) )
73
73
#else
74
74
75
75
// The linkStatus() is not working with W5100. Just using IP != 0.0.0.0
76
76
// Better to use ping for W5100
77
77
linkStatus = (int ) Ethernet.linkStatus ();
78
- ET_LOGINFO3 (F (" localEthernetIP = " ), localEthernetIP, F (" , linkStatus = " ), (linkStatus == LinkON) ? F (" LinkON" ) : F (" LinkOFF" ) );
78
+ ETM_LOGINFO3 (F (" localEthernetIP = " ), localEthernetIP, F (" , linkStatus = " ), (linkStatus == LinkON) ? F (" LinkON" ) : F (" LinkOFF" ) );
79
79
80
80
if ( ( (linkStatus == LinkON) || !isW5500 ) && ((uint32_t ) localEthernetIP != 0 ) )
81
81
#endif
82
82
{
83
83
Serial.print (F (" H" ));
84
84
}
85
85
else
86
- Serial.print (F (" F" ));
86
+ Serial.print (F (" F" ));
87
87
88
88
if (num == 80 )
89
89
{
@@ -118,112 +118,100 @@ void check_status()
118
118
}
119
119
}
120
120
121
- #if USING_CUSTOMS_STYLE
122
- const char NewCustomsStyle[] /* PROGMEM*/ = " <style>div,input{padding:5px;font-size:1em;}input{width:95%;}body{text-align: center;}\
123
- button{background-color:blue;color:white;line-height:2.4rem;font-size:1.2rem;width:100%;}fieldset{border-radius:0.3rem;margin:0px;}</style>" ;
124
- #endif
125
-
126
- void setup ()
121
+ void initEthernet ()
127
122
{
128
- // Debug console
129
- Serial.begin (115200 );
130
- while (!Serial);
131
-
132
- Serial.print (F (" \n Start AM2315_Ethernet_STM32 on " ));
133
- Serial.println (BOARD_NAME);
134
- Serial.print (F (" Ethernet Shield type : " ));
135
- Serial.println (SHIELD_TYPE);
136
- Serial.println (ETHERNET_MANAGER_STM32_VERSION);
137
- Serial.println (DOUBLERESETDETECTOR_GENERIC_VERSION);
138
-
139
123
#if ( defined(USE_BUILTIN_ETHERNET) && USE_BUILTIN_ETHERNET )
140
- ET_LOGWARN (F (" ======== USE_BUILTIN_ETHERNET ========" ));
124
+ ETM_LOGWARN (F (" ======== USE_BUILTIN_ETHERNET ========" ));
141
125
#elif ( defined(USE_UIP_ETHERNET) && USE_UIP_ETHERNET )
142
- ET_LOGWARN (F (" ======== USE_UIP_ETHERNET ========" ));
143
- #elif USE_NATIVE_ETHERNET
144
- ET_LOGWARN (F (" ======== USE_NATIVE_ETHERNET ========" ));
145
- #elif USE_ETHERNET
146
- ET_LOGWARN (F (" =========== USE_ETHERNET ===========" ));
147
- #elif USE_ETHERNET2
148
- ET_LOGWARN (F (" =========== USE_ETHERNET2 ===========" ));
149
- #elif USE_ETHERNET3
150
- ET_LOGWARN (F (" =========== USE_ETHERNET3 ===========" ));
151
- #elif USE_ETHERNET_LARGE
152
- ET_LOGWARN (F (" =========== USE_ETHERNET_LARGE ===========" ));
126
+ ETM_LOGWARN (F (" ======== USE_UIP_ETHERNET ========" ));
127
+ #elif USE_ETHERNET_GENERIC
128
+ ETM_LOGWARN (F (" =========== USE_ETHERNET_GENERIC ===========" ));
153
129
#elif USE_ETHERNET_ENC
154
- ET_LOGWARN (F (" =========== USE_ETHERNET_ENC ===========" ));
130
+ ETM_LOGWARN (F (" =========== USE_ETHERNET_ENC ===========" ));
155
131
#else
156
- ET_LOGWARN (F (" =========================" ));
132
+ ETM_LOGWARN (F (" =========================" ));
157
133
#endif
158
-
159
- ET_LOGWARN (F (" Default SPI pinout:" ));
160
- ET_LOGWARN1 (F (" MOSI:" ), MOSI);
161
- ET_LOGWARN1 (F (" MISO:" ), MISO);
162
- ET_LOGWARN1 (F (" SCK:" ), SCK);
163
- ET_LOGWARN1 (F (" SS:" ), SS);
164
- ET_LOGWARN (F (" =========================" ));
134
+
135
+ #if !(USE_BUILTIN_ETHERNET )
136
+ ETM_LOGWARN (F (" Default SPI pinout:" ));
137
+ ETM_LOGWARN1 (F (" MOSI:" ), MOSI);
138
+ ETM_LOGWARN1 (F (" MISO:" ), MISO);
139
+ ETM_LOGWARN1 (F (" SCK:" ), SCK);
140
+ ETM_LOGWARN1 (F (" SS:" ), SS);
141
+ ETM_LOGWARN (F (" =========================" ));
165
142
166
143
// unknown board, do nothing, use default SS = 10
167
144
#ifndef USE_THIS_SS_PIN
168
145
#define USE_THIS_SS_PIN 10 // For other boards
169
146
#endif
170
147
171
148
#if defined(BOARD_NAME)
172
- ET_LOGWARN3 (F (" Board :" ), BOARD_NAME, F (" , setCsPin:" ), USE_THIS_SS_PIN);
149
+ ETM_LOGWARN3 (F (" Board :" ), BOARD_NAME, F (" , setCsPin:" ), USE_THIS_SS_PIN);
173
150
#else
174
- ET_LOGWARN1 (F (" Unknown board setCsPin:" ), USE_THIS_SS_PIN);
151
+ ETM_LOGWARN1 (F (" Unknown board setCsPin:" ), USE_THIS_SS_PIN);
175
152
#endif
153
+ #endif
176
154
177
155
#if !(USE_BUILTIN_ETHERNET || USE_UIP_ETHERNET)
178
- pinMode (SDCARD_CS, OUTPUT);
179
- digitalWrite (SDCARD_CS, HIGH); // Deselect the SD card
180
-
181
- #if USE_ETHERNET_WRAPPER
156
+ # if (defined(ETHERNET_WITH_SD_CARD) && ETHERNET_WITH_SD_CARD)
157
+ pinMode (SDCARD_CS, OUTPUT);
158
+ digitalWrite (SDCARD_CS, HIGH); // Deselect the SD card
159
+ #endif
182
160
183
- EthernetInit ();
161
+ // For other boards, to change if necessary
162
+ #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC )
163
+ // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries
184
164
185
- #else
165
+ Ethernet.init (USE_THIS_SS_PIN);
166
+
167
+ #elif USE_CUSTOM_ETHERNET
186
168
187
- // For other boards, to change if necessary
188
- #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC )
189
- // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries
190
-
191
- Ethernet.init (USE_THIS_SS_PIN);
192
-
193
- #elif USE_ETHERNET3
194
- // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer
195
- #ifndef ETHERNET3_MAX_SOCK_NUM
196
- #define ETHERNET3_MAX_SOCK_NUM 4
197
- #endif
198
-
199
- Ethernet.setCsPin (USE_THIS_SS_PIN);
200
- Ethernet.init (ETHERNET3_MAX_SOCK_NUM);
201
-
202
- #elif USE_CUSTOM_ETHERNET
203
-
204
- // You have to add initialization for your Custom Ethernet here
205
- // This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough
206
- Ethernet.init (USE_THIS_SS_PIN);
207
-
208
- #endif // ( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE )
169
+ // You have to add initialization for your Custom Ethernet here
170
+ // This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough
171
+ Ethernet.init (USE_THIS_SS_PIN);
209
172
210
- #endif // USE_ETHERNET_WRAPPER
173
+ #endif // ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC )
211
174
212
175
#endif
213
176
177
+ #if !(USE_BUILTIN_ETHERNET )
214
178
// Just info to know how to connect correctly
215
- ET_LOGWARN (F (" =========================" ));
216
- ET_LOGWARN (F (" Currently Used SPI pinout:" ));
217
- ET_LOGWARN1 (F (" MOSI:" ), MOSI);
218
- ET_LOGWARN1 (F (" MISO:" ), MISO);
219
- ET_LOGWARN1 (F (" SCK:" ), SCK);
220
- ET_LOGWARN1 (F (" SS:" ), SS);
179
+ #if defined(CUR_PIN_MISO)
180
+ ETM_LOGWARN (F (" Currently Used SPI pinout:" ));
181
+ ETM_LOGWARN1 (F (" MOSI:" ), CUR_PIN_MOSI);
182
+ ETM_LOGWARN1 (F (" MISO:" ), CUR_PIN_MISO);
183
+ ETM_LOGWARN1 (F (" SCK:" ), CUR_PIN_SCK);
184
+ ETM_LOGWARN1 (F (" SS:" ), CUR_PIN_SS);
185
+ #else
186
+ ETM_LOGWARN (F (" Currently Used SPI pinout:" ));
187
+ ETM_LOGWARN1 (F (" MOSI:" ), MOSI);
188
+ ETM_LOGWARN1 (F (" MISO:" ), MISO);
189
+ ETM_LOGWARN1 (F (" SCK:" ), SCK);
190
+ ETM_LOGWARN1 (F (" SS:" ), SS);
191
+ #endif
221
192
222
- #if USE_ETHERNET3
223
- ET_LOGWARN1 (F (" SPI_CS:" ), SPI_CS);
193
+ ETM_LOGWARN (F (" =========================" ));
224
194
#endif
225
- ET_LOGWARN (F (" =========================" ));
226
-
195
+ }
196
+
197
+ #if USING_CUSTOMS_STYLE
198
+ const char NewCustomsStyle[] /* PROGMEM*/ = " <style>div,input{padding:5px;font-size:1em;}input{width:95%;}body{text-align: center;}\
199
+ button{background-color:blue;color:white;line-height:2.4rem;font-size:1.2rem;width:100%;}fieldset{border-radius:0.3rem;margin:0px;}</style>" ;
200
+ #endif
201
+
202
+ void setup ()
203
+ {
204
+ // Debug console
205
+ Serial.begin (115200 );
206
+ while (!Serial);
207
+
208
+ Serial.print (F (" \n Start AM2315_Ethernet_STM32 on " )); Serial.println (BOARD_NAME);
209
+ Serial.print (F (" Ethernet Shield type : " )); Serial.println (SHIELD_TYPE);
210
+ Serial.println (ETHERNET_MANAGER_STM32_VERSION);
211
+ Serial.println (DOUBLERESETDETECTOR_GENERIC_VERSION);
212
+
213
+ initEthernet ();
214
+
227
215
// ////////////////////////////////////////////
228
216
229
217
#if USING_CUSTOMS_STYLE
@@ -244,12 +232,7 @@ void setup()
244
232
245
233
localEthernetIP = Ethernet.localIP ();
246
234
247
- #if (USE_ETHERNET2 || USE_ETHERNET3)
248
- // To modify Ethernet2 library
249
235
if ( (uint32_t ) localEthernetIP != 0 )
250
- #else
251
- if ( (uint32_t ) localEthernetIP != 0 )
252
- #endif
253
236
{
254
237
Serial.print (F (" Connected! IP address: " ));
255
238
Serial.println (localEthernetIP);
@@ -260,7 +243,7 @@ void setup()
260
243
}
261
244
262
245
// Detect W5100 only in Ethernet and EthernetLarge libraries
263
- #if ( USE_ETHERNET || USE_ETHERNET_LARGE )
246
+ #if (USE_ETHERNET_GENERIC )
264
247
isW5500 = (Ethernet.hardwareStatus () == EthernetW5500);
265
248
Serial.print (F (" Ethernet type is " ));
266
249
Serial.println (isW5500 ? F (" W5500" ) : F (" W5100" ));
0 commit comments