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

Commit e866bf5

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 45a57ba commit e866bf5

File tree

24 files changed

+636
-426
lines changed

24 files changed

+636
-426
lines changed

examples/AWS_IoT/AWS_IoT.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void callback(char* topic, byte* payload, unsigned int length)
6868
Serial.print(topic);
6969
Serial.print("] ");
7070

71-
for (int i = 0; i < length; i++)
71+
for (unsigned int i = 0; i < length; i++)
7272
{
7373
Serial.print((char)payload[i]);
7474
}

examples/AWS_IoT/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/AdvancedWebServer/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/AdvancedWebServer_RP2040_SPI1/defines.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,17 @@
8080

8181
#else
8282
// SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 for SPI0
83-
#define USE_THIS_SS_PIN 17
83+
#define USE_THIS_SS_PIN PIN_SPI_SS //17
8484
#endif
8585

8686
#else
8787
// For RPI Pico using E. Philhower RP2040 core
8888
#if (USING_SPI2)
8989
// SCK: GPIO14, MOSI: GPIO15, MISO: GPIO12, SS/CS: GPIO13 for SPI1
90-
#define USE_THIS_SS_PIN 13
90+
#define USE_THIS_SS_PIN PIN_SPI1_SS //13
9191
#else
9292
// SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 for SPI0
93-
#define USE_THIS_SS_PIN 17
93+
#define USE_THIS_SS_PIN PIN_SPI0_SS //17
9494
#endif
9595

9696
#endif

examples/HelloServer/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)