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

Commit 9837e03

Browse files
authored
v1.9.1 to auto-select SPI(s) SS/CS pins
### Releases v1.9.1 1. Auto-select SPI(s) `SS/CS` pins according to board package if available 2. Update `Packages' Patches`
1 parent e866bf5 commit 9837e03

File tree

12 files changed

+363
-243
lines changed

12 files changed

+363
-243
lines changed

examples/HTTPClient/BasicAuthGet/defines.h

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
/****************************************************************************************************************************
22
defines.h
3-
EthernetWebServer_SSL is a library for the Ethernet shields to run WebServer and Client with/without SSL
4-
5-
Use SSLClient Library code from https://github.com/OPEnSLab-OSU/SSLClient
3+
EthernetWebServer is a library for the Ethernet shields to run WebServer
64
7-
Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer_SSL
5+
Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases
6+
Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer
7+
Licensed under MIT license
88
***************************************************************************************************************************************/
99

10-
#pragma once
11-
1210
#ifndef defines_h
1311
#define defines_h
1412

1513
#define DEBUG_ETHERNET_WEBSERVER_PORT Serial
1614

1715
// Debug Level from 0 to 4
18-
#define _ETHERNET_WEBSERVER_LOGLEVEL_ 2
16+
#define _ETHERNET_WEBSERVER_LOGLEVEL_ 3
1917

2018
#define USING_SPI2 false //true
2119

@@ -74,8 +72,13 @@
7472

7573
#if defined(ETHERNET_USE_SAMD)
7674
// For SAMD
77-
// Default pin 10 to SS/CS
78-
#define USE_THIS_SS_PIN 10
75+
// Default pin SS/CS,if no SS pin, use pin 10
76+
#if defined(PIN_SPI_MOSI)
77+
#warning Using SS pin
78+
#define USE_THIS_SS_PIN SS
79+
#else
80+
#define USE_THIS_SS_PIN 10
81+
#endif
7982

8083
#if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) )
8184
#define BOARD_TYPE "SAMD Zero"
@@ -182,13 +185,20 @@
182185
#endif
183186

184187
#elif (ETHERNET_USE_SAM_DUE)
188+
185189
// Default pin 10 to SS/CS
186190
#define USE_THIS_SS_PIN 10
187191
#define BOARD_TYPE "SAM DUE"
188192

189193
#elif (ETHERNET_USE_NRF528XX)
190-
// Default pin 10 to SS/CS
191-
#define USE_THIS_SS_PIN 10
194+
// For Adafruit nRF52
195+
// Default pin SS/CS,if no SS pin, use pin 10
196+
#if defined(PIN_SPI_MOSI)
197+
#warning Using SS pin
198+
#define USE_THIS_SS_PIN SS
199+
#else
200+
#define USE_THIS_SS_PIN 10
201+
#endif
192202

193203
#if defined(NRF52840_FEATHER)
194204
#define BOARD_TYPE "NRF52840_FEATHER"
@@ -221,7 +231,7 @@
221231

222232
#elif ( defined(CORE_TEENSY) )
223233
// Default pin 10 to SS/CS
224-
#define USE_THIS_SS_PIN 10
234+
#define USE_THIS_SS_PIN SS //10
225235

226236
#if defined(__IMXRT1062__)
227237
// For Teensy 4.1/4.0
@@ -270,12 +280,12 @@
270280

271281
#elif ETHERNET_USE_RPIPICO
272282

273-
// Default pin 5 (in Mbed) or 17 to SS/CS
283+
// Default pin 17 to SS/CS
274284
#if defined(ARDUINO_ARCH_MBED)
275-
// For RPI Pico using Arduino Mbed RP2040 core
276-
// SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5
285+
// For RPI Pico using newer Arduino Mbed RP2040 core
286+
// SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17
277287

278-
#define USE_THIS_SS_PIN 17
288+
#define USE_THIS_SS_PIN PIN_SPI_SS //17
279289

280290
#if defined(BOARD_NAME)
281291
#undef BOARD_NAME
@@ -284,7 +294,7 @@
284294
#if defined(ARDUINO_RASPBERRY_PI_PICO)
285295
#define BOARD_TYPE "MBED RASPBERRY_PI_PICO"
286296
#elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040)
287-
#define BOARD_TYPE "MBED DAFRUIT_FEATHER_RP2040"
297+
#define BOARD_TYPE "MBED ADAFRUIT_FEATHER_RP2040"
288298
#elif defined(ARDUINO_GENERIC_RP2040)
289299
#define BOARD_TYPE "MBED GENERIC_RP2040"
290300
#else
@@ -295,10 +305,10 @@
295305
// For RPI Pico using E. Philhower RP2040 core
296306
#if (USING_SPI2)
297307
// SCK: GPIO14, MOSI: GPIO15, MISO: GPIO12, SS/CS: GPIO13 for SPI1
298-
#define USE_THIS_SS_PIN 13
308+
#define USE_THIS_SS_PIN PIN_SPI1_SS //13
299309
#else
300310
// SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 for SPI0
301-
#define USE_THIS_SS_PIN 17
311+
#define USE_THIS_SS_PIN PIN_SPI0_SS //17
302312
#endif
303313

304314
#endif
@@ -309,8 +319,8 @@
309319
#warning Use RPI-Pico RP2040 architecture
310320

311321
#else
312-
// For Mega
313-
// Default pin 10 to SS/CS
322+
// For Mega, etc.
323+
// Default pin SS/CS,if no SS pin, use pin 10
314324
#define USE_THIS_SS_PIN 10
315325

316326
// Reduce size for Mega

examples/HTTPClient/CustomHeader/defines.h

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
/****************************************************************************************************************************
22
defines.h
3-
EthernetWebServer_SSL is a library for the Ethernet shields to run WebServer and Client with/without SSL
4-
5-
Use SSLClient Library code from https://github.com/OPEnSLab-OSU/SSLClient
3+
EthernetWebServer is a library for the Ethernet shields to run WebServer
64
7-
Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer_SSL
5+
Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases
6+
Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer
7+
Licensed under MIT license
88
***************************************************************************************************************************************/
99

10-
#pragma once
11-
1210
#ifndef defines_h
1311
#define defines_h
1412

@@ -74,8 +72,13 @@
7472

7573
#if defined(ETHERNET_USE_SAMD)
7674
// For SAMD
77-
// Default pin 10 to SS/CS
78-
#define USE_THIS_SS_PIN 10
75+
// Default pin SS/CS,if no SS pin, use pin 10
76+
#if defined(PIN_SPI_MOSI)
77+
#warning Using SS pin
78+
#define USE_THIS_SS_PIN SS
79+
#else
80+
#define USE_THIS_SS_PIN 10
81+
#endif
7982

8083
#if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) )
8184
#define BOARD_TYPE "SAMD Zero"
@@ -182,13 +185,20 @@
182185
#endif
183186

184187
#elif (ETHERNET_USE_SAM_DUE)
188+
185189
// Default pin 10 to SS/CS
186190
#define USE_THIS_SS_PIN 10
187191
#define BOARD_TYPE "SAM DUE"
188192

189193
#elif (ETHERNET_USE_NRF528XX)
190-
// Default pin 10 to SS/CS
191-
#define USE_THIS_SS_PIN 10
194+
// For Adafruit nRF52
195+
// Default pin SS/CS,if no SS pin, use pin 10
196+
#if defined(PIN_SPI_MOSI)
197+
#warning Using SS pin
198+
#define USE_THIS_SS_PIN SS
199+
#else
200+
#define USE_THIS_SS_PIN 10
201+
#endif
192202

193203
#if defined(NRF52840_FEATHER)
194204
#define BOARD_TYPE "NRF52840_FEATHER"
@@ -221,7 +231,7 @@
221231

222232
#elif ( defined(CORE_TEENSY) )
223233
// Default pin 10 to SS/CS
224-
#define USE_THIS_SS_PIN 10
234+
#define USE_THIS_SS_PIN SS //10
225235

226236
#if defined(__IMXRT1062__)
227237
// For Teensy 4.1/4.0
@@ -270,12 +280,12 @@
270280

271281
#elif ETHERNET_USE_RPIPICO
272282

273-
// Default pin 5 (in Mbed) or 17 to SS/CS
283+
// Default pin 17 to SS/CS
274284
#if defined(ARDUINO_ARCH_MBED)
275-
// For RPI Pico using Arduino Mbed RP2040 core
276-
// SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5
285+
// For RPI Pico using newer Arduino Mbed RP2040 core
286+
// SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17
277287

278-
#define USE_THIS_SS_PIN 17
288+
#define USE_THIS_SS_PIN PIN_SPI_SS //17
279289

280290
#if defined(BOARD_NAME)
281291
#undef BOARD_NAME
@@ -284,7 +294,7 @@
284294
#if defined(ARDUINO_RASPBERRY_PI_PICO)
285295
#define BOARD_TYPE "MBED RASPBERRY_PI_PICO"
286296
#elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040)
287-
#define BOARD_TYPE "MBED DAFRUIT_FEATHER_RP2040"
297+
#define BOARD_TYPE "MBED ADAFRUIT_FEATHER_RP2040"
288298
#elif defined(ARDUINO_GENERIC_RP2040)
289299
#define BOARD_TYPE "MBED GENERIC_RP2040"
290300
#else
@@ -295,10 +305,10 @@
295305
// For RPI Pico using E. Philhower RP2040 core
296306
#if (USING_SPI2)
297307
// SCK: GPIO14, MOSI: GPIO15, MISO: GPIO12, SS/CS: GPIO13 for SPI1
298-
#define USE_THIS_SS_PIN 13
308+
#define USE_THIS_SS_PIN PIN_SPI1_SS //13
299309
#else
300310
// SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 for SPI0
301-
#define USE_THIS_SS_PIN 17
311+
#define USE_THIS_SS_PIN PIN_SPI0_SS //17
302312
#endif
303313

304314
#endif
@@ -309,8 +319,8 @@
309319
#warning Use RPI-Pico RP2040 architecture
310320

311321
#else
312-
// For Mega
313-
// Default pin 10 to SS/CS
322+
// For Mega, etc.
323+
// Default pin SS/CS,if no SS pin, use pin 10
314324
#define USE_THIS_SS_PIN 10
315325

316326
// Reduce size for Mega

examples/HTTPClient/DweetGet/defines.h

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
/****************************************************************************************************************************
22
defines.h
3-
EthernetWebServer_SSL is a library for the Ethernet shields to run WebServer and Client with/without SSL
4-
5-
Use SSLClient Library code from https://github.com/OPEnSLab-OSU/SSLClient
3+
EthernetWebServer is a library for the Ethernet shields to run WebServer
64
7-
Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer_SSL
5+
Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases
6+
Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer
7+
Licensed under MIT license
88
***************************************************************************************************************************************/
99

10-
#pragma once
11-
1210
#ifndef defines_h
1311
#define defines_h
1412

@@ -74,8 +72,13 @@
7472

7573
#if defined(ETHERNET_USE_SAMD)
7674
// For SAMD
77-
// Default pin 10 to SS/CS
78-
#define USE_THIS_SS_PIN 10
75+
// Default pin SS/CS,if no SS pin, use pin 10
76+
#if defined(PIN_SPI_MOSI)
77+
#warning Using SS pin
78+
#define USE_THIS_SS_PIN SS
79+
#else
80+
#define USE_THIS_SS_PIN 10
81+
#endif
7982

8083
#if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) )
8184
#define BOARD_TYPE "SAMD Zero"
@@ -182,13 +185,20 @@
182185
#endif
183186

184187
#elif (ETHERNET_USE_SAM_DUE)
188+
185189
// Default pin 10 to SS/CS
186190
#define USE_THIS_SS_PIN 10
187191
#define BOARD_TYPE "SAM DUE"
188192

189193
#elif (ETHERNET_USE_NRF528XX)
190-
// Default pin 10 to SS/CS
191-
#define USE_THIS_SS_PIN 10
194+
// For Adafruit nRF52
195+
// Default pin SS/CS,if no SS pin, use pin 10
196+
#if defined(PIN_SPI_MOSI)
197+
#warning Using SS pin
198+
#define USE_THIS_SS_PIN SS
199+
#else
200+
#define USE_THIS_SS_PIN 10
201+
#endif
192202

193203
#if defined(NRF52840_FEATHER)
194204
#define BOARD_TYPE "NRF52840_FEATHER"
@@ -221,7 +231,7 @@
221231

222232
#elif ( defined(CORE_TEENSY) )
223233
// Default pin 10 to SS/CS
224-
#define USE_THIS_SS_PIN 10
234+
#define USE_THIS_SS_PIN SS //10
225235

226236
#if defined(__IMXRT1062__)
227237
// For Teensy 4.1/4.0
@@ -270,12 +280,12 @@
270280

271281
#elif ETHERNET_USE_RPIPICO
272282

273-
// Default pin 5 (in Mbed) or 17 to SS/CS
283+
// Default pin 17 to SS/CS
274284
#if defined(ARDUINO_ARCH_MBED)
275-
// For RPI Pico using Arduino Mbed RP2040 core
276-
// SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5
285+
// For RPI Pico using newer Arduino Mbed RP2040 core
286+
// SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17
277287

278-
#define USE_THIS_SS_PIN 17
288+
#define USE_THIS_SS_PIN PIN_SPI_SS //17
279289

280290
#if defined(BOARD_NAME)
281291
#undef BOARD_NAME
@@ -284,7 +294,7 @@
284294
#if defined(ARDUINO_RASPBERRY_PI_PICO)
285295
#define BOARD_TYPE "MBED RASPBERRY_PI_PICO"
286296
#elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040)
287-
#define BOARD_TYPE "MBED DAFRUIT_FEATHER_RP2040"
297+
#define BOARD_TYPE "MBED ADAFRUIT_FEATHER_RP2040"
288298
#elif defined(ARDUINO_GENERIC_RP2040)
289299
#define BOARD_TYPE "MBED GENERIC_RP2040"
290300
#else
@@ -295,10 +305,10 @@
295305
// For RPI Pico using E. Philhower RP2040 core
296306
#if (USING_SPI2)
297307
// SCK: GPIO14, MOSI: GPIO15, MISO: GPIO12, SS/CS: GPIO13 for SPI1
298-
#define USE_THIS_SS_PIN 13
308+
#define USE_THIS_SS_PIN PIN_SPI1_SS //13
299309
#else
300310
// SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 for SPI0
301-
#define USE_THIS_SS_PIN 17
311+
#define USE_THIS_SS_PIN PIN_SPI0_SS //17
302312
#endif
303313

304314
#endif
@@ -309,8 +319,8 @@
309319
#warning Use RPI-Pico RP2040 architecture
310320

311321
#else
312-
// For Mega
313-
// Default pin 10 to SS/CS
322+
// For Mega, etc.
323+
// Default pin SS/CS,if no SS pin, use pin 10
314324
#define USE_THIS_SS_PIN 10
315325

316326
// Reduce size for Mega

0 commit comments

Comments
 (0)