From 646034f7778a3703a38840c687f9ae3429115eff Mon Sep 17 00:00:00 2001 From: Khoi Hoang <57012152+khoih-prog@users.noreply.github.com> Date: Tue, 3 May 2022 23:03:17 -0400 Subject: [PATCH] v2.3.0 to support to custom SPI for Arduino-mbed ### Releases v2.3.0 1. Add support to custom SPI for RP2040, Nano_RP2040_Connect, Portenta_H7, etc. using [Arduino-mbed core](https://github.com/arduino/ArduinoCore-mbed) --- README.md | 184 ++++++++++++++++-- changelog.md | 6 + examples/WebClient/defines.h | 2 +- .../WebClientRepeating_RP2040_SPI1/defines.h | 78 ++++++-- examples/multiFileProject/multiFileProject.h | 3 +- .../multiFileProject/multiFileProject.ino | 4 +- library.json | 4 +- library.properties | 4 +- src/Dhcp.h | 3 +- src/Dhcp_Impl.h | 3 +- src/Dns.h | 3 +- src/Dns_Impl.h | 3 +- src/EthernetClient.h | 3 +- src/EthernetClient_Impl.h | 3 +- src/EthernetServer.h | 3 +- src/EthernetServer_Impl.h | 3 +- src/EthernetUdp.h | 3 +- src/EthernetUdp_Impl.h | 3 +- src/Ethernet_Generic.h | 9 +- src/Ethernet_Generic.hpp | 7 +- src/Ethernet_Generic_Debug.h | 3 +- src/Ethernet_Generic_Impl.h | 3 +- src/socket_Impl.h | 3 +- src/utility/w5100.h | 5 +- src/utility/w5100_Impl.h | 38 ++-- 25 files changed, 306 insertions(+), 77 deletions(-) diff --git a/README.md b/README.md index 4b088a0..087636f 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,7 @@ * [12. WebClient on MBED RASPBERRY_PI_PICO with W5100S using Ethernet_Generic Library with Large Buffer](#12-WebClient-on-MBED-RASPBERRY_PI_PICO-with-W5100S-using-Ethernet_Generic-Library-with-Large-Buffer) * [13. WebClientRepeating on NUCLEO_L552ZE_Q with W5x00 using Ethernet_Generic Library with Large Buffer](#13-WebClientRepeating-on-NUCLEO_L552ZE_Q-with-W5x00-using-Ethernet_Generic-Library-with-Large-Buffer) * [14. WebClientRepeating on NUCLEO_F767ZI with W5x00 using Ethernet_Generic Library with Large Buffer](#14-WebClientRepeating-on-NUCLEO_F767ZI-with-W5x00-using-Ethernet_Generic-Library-with-Large-Buffer) + * [15. WebClientRepeating_RP2040_SPI1 on MBED RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library with Large Buffer](#15-WebClientRepeating_RP2040_SPI1-on-MBED-RASPBERRY_PI_PICO-with-W5x00-using-Ethernet_Generic-Library-with-Large-Buffer) * [Debug](#debug) * [Troubleshooting](#troubleshooting) * [Issues](#issues) @@ -134,13 +135,13 @@ This [**Ethernet_Generic** library](https://github.com/khoih-prog/Ethernet_Gener 7. ESP32, using **SPI or SPI2** 8. ESP8266 - 9. RP2040-based boards, such as **RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, using [**Arduino-mbed RP2040** core](https://github.com/arduino/ArduinoCore-mbed) with SPI -10. RP2040-based boards, such as **RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, using [**Earle Philhower's arduino-pico** core](https://github.com/earlephilhower/arduino-pico) with SPI0 or SPI1. **New** -11. **Portenta_H7** + 9. RP2040-based boards, such as **RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, using [**Arduino-mbed RP2040** core](https://github.com/arduino/ArduinoCore-mbed) with SPI, SPI1, or custom SPI. **New** +10. RP2040-based boards, such as **RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, using [**Earle Philhower's arduino-pico** core](https://github.com/earlephilhower/arduino-pico) with SPI, SPI1 or custom SPI. **New** +11. **Portenta_H7** with SPI0, SPI1 or custom SPI. **New** 12. **Arduino UNO WiFi Rev2, AVR_NANO_EVERY, etc.** -13. **STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running W5x00 shields)** +13. **STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running W5x00 shields)** with SPI, SPI2 or custom SPI. **New** - Nucleo-144 - Nucleo-64 @@ -549,15 +550,65 @@ of comment out the following line, if exists //#define USING_SPI2 true ``` -To use SPI2 (or `SPI1` for `arduino-pico` core) +To use custom SPI (or `SPI1` for `arduino-pico` or `Arduino_mbed` core) ```cpp -#define USING_SPI2 true +#define USING_SPI2 true + +#if defined(ARDUINO_ARCH_MBED) + + // For RPI Pico using Mbed RP2040 core + #if (USING_SPI2) + #define USING_CUSTOM_SPI true + + // SCK: GPIO14, MOSI: GPIO15, MISO: GPIO12, SS/CS: GPIO13 for SPI1 + #define CUR_PIN_MISO 12 + #define CUR_PIN_MOSI 15 + #define CUR_PIN_SCK 14 + #define CUR_PIN_SS 13 + + #define SPI_NEW_INITIALIZED true + + // Don't create the instance with CUR_PIN_SS, or Ethernet not working + // To change for other boards' SPI libraries + #define SPIClass arduino::MbedSPI + + // Be careful, Mbed SPI ctor is so weird, reversing the order => MISO, MOSI, SCK + //arduino::MbedSPI::MbedSPI(int miso, int mosi, int sck) + SPIClass SPI_New(CUR_PIN_MISO, CUR_PIN_MOSI, CUR_PIN_SCK); + + #warning Using USE_THIS_SS_PIN = CUR_PIN_SS = 13 + + #if defined(USE_THIS_SS_PIN) + #undef USE_THIS_SS_PIN + #endif + #define USE_THIS_SS_PIN CUR_PIN_SS //13 + + #else + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 for SPI0 + #define USE_THIS_SS_PIN 17 + #endif + +#else + // For RPI Pico using E. Philhower RP2040 core + #if (USING_SPI2) + // SCK: GPIO14, MOSI: GPIO15, MISO: GPIO12, SS/CS: GPIO13 for SPI1 + #define USE_THIS_SS_PIN 13 + #else + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 for SPI0 + #define USE_THIS_SS_PIN 17 + #endif + +#endif ``` -Check and compare the examples [WebClient_ESP](examples/WebClient_ESP) and [WebClient_ESP_SPI2](examples/WebClient_ESP_SPI2) +Check and compare the examples + +- [WebClient_ESP](examples/WebClient_ESP) and [WebClient_ESP_SPI2](examples/WebClient_ESP_SPI2) +- [WebClientRepeating_RP2040_SPI1](examples/WebClientRepeating_RP2040_SPI1) and [WebClientRepeating](examples/WebClientRepeating) +--- #### 1.2 For STM32 boards @@ -699,7 +750,7 @@ The following are debug terminal output when running example [WebClientRepeating ``` Starting WebClientRepeating_ESP on ESP32_DEV with W5x00 using Ethernet_Generic Library on SPI -Ethernet_Generic v2.2.0 +Ethernet_Generic v2.3.0 ========================= Currently Used SPI pinout: MOSI:23 @@ -780,7 +831,7 @@ The following are debug terminal output when running example [WebClientRepeating ``` Starting WebClientRepeating_ESP_SPI2 on ESP32_DEV with W5x00 using Ethernet_Generic Library on SPI2 -Ethernet_Generic v2.2.0 +Ethernet_Generic v2.3.0 ========================= Currently Used SPI pinout: MOSI:13 @@ -862,7 +913,7 @@ The following are debug terminal output when running example [WebClientRepeating ``` Starting WebClientRepeating on AVR Mega with W5x00 using Ethernet_Generic Library -Ethernet_Generic v2.2.0 +Ethernet_Generic v2.3.0 ========================= Currently Used SPI pinout: MOSI:51 @@ -940,7 +991,7 @@ The following are debug terminal output when running example [WebClientRepeating ``` Starting WebClientRepeating on NRF52840_FEATHER with W5x00 using Ethernet_Generic Library -Ethernet_Generic v2.2.0 +Ethernet_Generic v2.3.0 ========================= Currently Used SPI pinout: MOSI:25 @@ -1020,7 +1071,7 @@ The following are debug terminal output when running example [WebClientRepeating ``` Starting WebClientRepeating on SAM DUE with W5x00 using Ethernet_Generic Library -Ethernet_Generic v2.2.0 +Ethernet_Generic v2.3.0 ========================= Currently Used SPI pinout: MOSI:75 @@ -1100,7 +1151,7 @@ The following are debug terminal output when running example [WebClientRepeating ``` Starting WebClientRepeating on ITSYBITSY_M4 with W5x00 using Ethernet_Generic Library -Ethernet_Generic v2.2.0 +Ethernet_Generic v2.3.0 ========================= Currently Used SPI pinout: MOSI:25 @@ -1180,7 +1231,7 @@ The following are debug terminal output when running example [WebClientRepeating ``` Starting WebClientRepeating on NUCLEO_F767ZI with W5x00 using Ethernet_Generic Library -Ethernet_Generic v2.2.0 +Ethernet_Generic v2.3.0 ========================= Currently Used SPI pinout: MOSI:11 @@ -1261,7 +1312,7 @@ The following are debug terminal output when running example [UdpNTPClient](exam ``` Start UdpNTPClient on AVR Mega with W5x00 using Ethernet_Generic Library -Ethernet_Generic v2.2.0 +Ethernet_Generic v2.3.0 ========================= Currently Used SPI pinout: MOSI:51 @@ -1298,7 +1349,7 @@ The following are debug terminal output when running example [WebClient](example ``` Starting WebClient on MBED RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library with Large Buffer -Ethernet_Generic v2.2.0 +Ethernet_Generic v2.3.0 ========================= Currently Used SPI pinout: MOSI:19 @@ -1382,7 +1433,7 @@ The following are debug terminal output when running example [WebClient](example ``` Starting WebClient on RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library with Large Buffer -Ethernet_Generic v2.2.0 +Ethernet_Generic v2.3.0 ========================= Currently Used SPI pinout: MOSI:19 @@ -1466,7 +1517,7 @@ The following are debug terminal output when running example [WebClientRepeating ``` Starting WebClientRepeating_RP2040_SPI1 on RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library with Large Buffer -Ethernet_Generic v2.2.0 +Ethernet_Generic v2.3.0 [ETG] Default SPI pinout: [ETG] MOSI: 15 [ETG] MISO: 12 @@ -1555,7 +1606,7 @@ The following are debug terminal output when running example [WebClient](example ``` Starting WebClient on MBED RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library with Large Buffer -Ethernet_Generic v2.2.0 +Ethernet_Generic v2.3.0 [ETG] Default SPI pinout: [ETG] MOSI: 19 [ETG] MISO: 16 @@ -1647,7 +1698,7 @@ The following are debug terminal output when running example [WebClientRepeating ``` Starting WebClientRepeating on NUCLEO_L552ZE_Q with W5x00 using Ethernet_Generic Library with Large Buffer -Ethernet_Generic v2.2.0 +Ethernet_Generic v2.3.0 [ETG] Default SPI pinout: [ETG] MOSI: 22 [ETG] MISO: 25 @@ -1734,7 +1785,7 @@ The following are debug terminal output when running example [WebClientRepeating ``` Start WebClientRepeating on NUCLEO_F767ZI with W5x00 using Ethernet_Generic Library with Large Buffer -Ethernet_Generic v2.2.0 +Ethernet_Generic v2.3.0 [ETG] Default SPI pinout: [ETG] MOSI: 22 [ETG] MISO: 25 @@ -1812,6 +1863,95 @@ alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400 ``` +--- + +#### 15. WebClientRepeating_RP2040_SPI1 on MBED RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library with Large Buffer + +The following are debug terminal output when running example [WebClientRepeating_RP2040_SPI1](examples/WebClientRepeating_RP2040_SPI1) on MBED RASPBERRY_PI_PICO with `W5500` using Ethernet_Generic Library and SPI2 + +``` +Starting WebClientRepeating_RP2040_SPI1 on MBED RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library with Large Buffer +Ethernet_Generic v2.3.0 +[ETG] Default SPI pinout: +[ETG] MOSI: 15 +[ETG] MISO: 12 +[ETG] SCK: 14 +[ETG] SS: 13 +[ETG] ========================= +[ETG] RPIPICO setCsPin: 13 +[ETG] W5100 init, using SS_PIN_DEFAULT = 13 , new ss_pin = 10 , W5100Class::ss_pin = 13 +[ETG] Chip is W5500 +[ETG] W5100::init: W5500, SSIZE = 8192 +[ETG] Currently Used SPI pinout: +[ETG] MOSI: 15 +[ETG] MISO: 12 +[ETG] SCK: 14 +[ETG] SS: 13 +[ETG] ========================= +Using mac index = 18 +Connected! IP address: 192.168.2.85 +Speed: 100 MB, Duplex: FULL DUPLEX, Link status: LINK + +Connecting... +HTTP/1.1 200 OK +Date: Wed, 04 May 2022 02:52:56 GMT +Content-Type: text/plain +Content-Length: 2263 +Connection: close +x-amz-id-2: 8vpqIozCfHQtWmljz3zKcVb5oa2m61jwYMh4PaSUwllVqFPdlotFeMd8kbtXto0B1tOusMAUwRI= +x-amz-request-id: 625R5E0MEMACW8E3 +Last-Modified: Wed, 23 Feb 2022 14:56:42 GMT +ETag: "667cf48afcc12c38c8c1637947a04224" +CF-Cache-Status: DYNAMIC +Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=PtWJxKSeTy2pn3lC8%2FpwyFTn96Mj1T%2B%2FKoMsFHN4IUM4loCow6T01wiMe%2BJzJMIHZS2np%2F8CCNhjwRu%2FwSpDwtwl%2FoD7YPSnSCxjiAChJ7n%2FZq2yn1s5yBTBQf6op8M%3D"}],"group":"cf-nel","max_age":604800} +NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800} +Server: cloudflare +CF-RAY: 705df1758fde3fde-YYZ +alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400 + + + `:;;;,` .:;;:. + .;;;;;;;;;;;` :;;;;;;;;;;: TM + `;;;;;;;;;;;;;;;` :;;;;;;;;;;;;;;; + :;;;;;;;;;;;;;;;;;; `;;;;;;;;;;;;;;;;;; + ;;;;;;;;;;;;;;;;;;;;; .;;;;;;;;;;;;;;;;;;;; + ;;;;;;;;:` `;;;;;;;;; ,;;;;;;;;.` .;;;;;;;; + .;;;;;;, :;;;;;;; .;;;;;;; ;;;;;;; + ;;;;;; ;;;;;;; ;;;;;;, ;;;;;;. + ,;;;;; ;;;;;;.;;;;;;` ;;;;;; + ;;;;;. ;;;;;;;;;;;` ``` ;;;;;` + ;;;;; ;;;;;;;;;, ;;; .;;;;; +`;;;;: `;;;;;;;; ;;; ;;;;; +,;;;;` `,,,,,,,, ;;;;;;; .,,;;;,,, ;;;;; +:;;;;` .;;;;;;;; ;;;;;, :;;;;;;;; ;;;;; +:;;;;` .;;;;;;;; `;;;;;; :;;;;;;;; ;;;;; +.;;;;. ;;;;;;;. ;;; ;;;;; + ;;;;; ;;;;;;;;; ;;; ;;;;; + ;;;;; .;;;;;;;;;; ;;; ;;;;;, + ;;;;;; `;;;;;;;;;;;; ;;;;; + `;;;;;, .;;;;;; ;;;;;;; ;;;;;; + ;;;;;;: :;;;;;;. ;;;;;;; ;;;;;; + ;;;;;;;` .;;;;;;;, ;;;;;;;; ;;;;;;;: + ;;;;;;;;;:,:;;;;;;;;;: ;;;;;;;;;;:,;;;;;;;;;; + `;;;;;;;;;;;;;;;;;;;. ;;;;;;;;;;;;;;;;;;;; + ;;;;;;;;;;;;;;;;; :;;;;;;;;;;;;;;;;: + ,;;;;;;;;;;;;;, ;;;;;;;;;;;;;; + .;;;;;;;;;` ,;;;;;;;;: + + + + + ;;; ;;;;;` ;;;;: .;; ;; ,;;;;;, ;;. `;, ;;;; + ;;; ;;:;;; ;;;;;; .;; ;; ,;;;;;: ;;; `;, ;;;:;; + ,;:; ;; ;; ;; ;; .;; ;; ,;, ;;;,`;, ;; ;; + ;; ;: ;; ;; ;; ;; .;; ;; ,;, ;;;;`;, ;; ;;. + ;: ;; ;;;;;: ;; ;; .;; ;; ,;, ;;`;;;, ;; ;;` + ,;;;;; ;;`;; ;; ;; .;; ;; ,;, ;; ;;;, ;; ;; + ;; ,;, ;; .;; ;;;;;: ;;;;;: ,;;;;;: ;; ;;, ;;;;;; + ;; ;; ;; ;;` ;;;;. `;;;: ,;;;;;, ;; ;;, ;;;; +``` + + --- --- @@ -1874,6 +2014,8 @@ Submit issues to: [Ethernet_Generic issues](https://github.com/khoih-prog/Ethern 17. Add support to WIZNet W5100S, including [**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) 18. Add support to STM32 boards using [Arduino_Core_STM32](https://github.com/stm32duino/Arduino_Core_STM32) 19. Add support to any board with core supporting custom hardware / software `SPI`, for example STM32. +20. Add support to custom SPI for RP2040, Nano_RP2040_Connect, Portenta_H7, etc. using [Arduino-mbed core](https://github.com/arduino/ArduinoCore-mbed) + --- --- diff --git a/changelog.md b/changelog.md index 1902cc6..8da6264 100644 --- a/changelog.md +++ b/changelog.md @@ -12,6 +12,7 @@ * [Changelog](#changelog) + * [Releases v2.3.0](#releases-v230) * [Releases v2.2.0](#releases-v220) * [Releases v2.1.0](#releases-v210) * [Releases v2.0.1](#releases-v201) @@ -22,6 +23,11 @@ ## Changelog +### Releases v2.3.0 + +1. Add support to custom SPI for RP2040, Nano_RP2040_Connect, Portenta_H7, etc. using [Arduino-mbed core](https://github.com/arduino/ArduinoCore-mbed) + + ### Releases v2.2.0 1. Add support to STM32 boards using [Arduino_Core_STM32](https://github.com/stm32duino/Arduino_Core_STM32) diff --git a/examples/WebClient/defines.h b/examples/WebClient/defines.h index e744049..8d01127 100644 --- a/examples/WebClient/defines.h +++ b/examples/WebClient/defines.h @@ -261,7 +261,7 @@ #if defined(ARDUINO_RASPBERRY_PI_PICO) #define BOARD_TYPE "MBED RASPBERRY_PI_PICO" #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) - #define BOARD_TYPE "MBED DAFRUIT_FEATHER_RP2040" + #define BOARD_TYPE "MBED ADAFRUIT_FEATHER_RP2040" #elif defined(ARDUINO_GENERIC_RP2040) #define BOARD_TYPE "MBED GENERIC_RP2040" #else diff --git a/examples/WebClientRepeating_RP2040_SPI1/defines.h b/examples/WebClientRepeating_RP2040_SPI1/defines.h index 3578cc9..0288163 100644 --- a/examples/WebClientRepeating_RP2040_SPI1/defines.h +++ b/examples/WebClientRepeating_RP2040_SPI1/defines.h @@ -17,31 +17,81 @@ #define USING_SPI2 true -#if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_GENERIC_RP2040) ) && \ - !defined(ARDUINO_ARCH_MBED) +#if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_GENERIC_RP2040) ) #if defined(ETHERNET_USE_RPIPICO) #undef ETHERNET_USE_RPIPICO #endif #define ETHERNET_USE_RPIPICO true #else - #error Only RP2040 and not ARDUINO_ARCH_MBED supported + #error Only RP2040 supported #endif - -// For RPI Pico using E. Philhower RP2040 core -#if (USING_SPI2) - // SCK: GPIO14, MOSI: GPIO15, MISO: GPIO12, SS/CS: GPIO13 for SPI1 - #define USE_THIS_SS_PIN 13 + +#include + +#if defined(ARDUINO_ARCH_MBED) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #else + #define BOARD_NAME "MBED Unknown RP2040" + #endif + + // For RPI Pico using Mbed RP2040 core + #if (USING_SPI2) + #define USING_CUSTOM_SPI true + + // SCK: GPIO14, MOSI: GPIO15, MISO: GPIO12, SS/CS: GPIO13 for SPI1 + #define CUR_PIN_MISO 12 + #define CUR_PIN_MOSI 15 + #define CUR_PIN_SCK 14 + #define CUR_PIN_SS 13 + + #define SPI_NEW_INITIALIZED true + + // Don't create the instance with CUR_PIN_SS, or Ethernet not working + // To change for other boards' SPI libraries + #define SPIClass arduino::MbedSPI + + // Be careful, Mbed SPI ctor is so weird, reversing the order => MISO, MOSI, SCK + //arduino::MbedSPI::MbedSPI(int miso, int mosi, int sck) + SPIClass SPI_New(CUR_PIN_MISO, CUR_PIN_MOSI, CUR_PIN_SCK); + + //#warning Using USE_THIS_SS_PIN = CUR_PIN_SS = 13 + + #if defined(USE_THIS_SS_PIN) + #undef USE_THIS_SS_PIN + #endif + #define USE_THIS_SS_PIN CUR_PIN_SS //13 + + #else + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 for SPI0 + #define USE_THIS_SS_PIN 17 + #endif + #else - // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 for SPI0 - #define USE_THIS_SS_PIN 17 + // For RPI Pico using E. Philhower RP2040 core + #if (USING_SPI2) + // SCK: GPIO14, MOSI: GPIO15, MISO: GPIO12, SS/CS: GPIO13 for SPI1 + #define USE_THIS_SS_PIN 13 + #else + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 for SPI0 + #define USE_THIS_SS_PIN 17 + #endif + #endif - + #define SS_PIN_DEFAULT USE_THIS_SS_PIN // For RPI Pico -#warning Use RPI-Pico RP2040 architecture with SPI1 - -#include +#warning Use RPI-Pico RP2040 architecture with custom SPI or SPI1 /////////////////////////////////////////////////////////// diff --git a/examples/multiFileProject/multiFileProject.h b/examples/multiFileProject/multiFileProject.h index 781eb02..8ee7ffa 100644 --- a/examples/multiFileProject/multiFileProject.h +++ b/examples/multiFileProject/multiFileProject.h @@ -10,7 +10,8 @@ #pragma once -#define _TEENSY41_ASYNC_TCP_LOGLEVEL_ 1 +// Debug Level from 0 to 4 +#define _ETG_LOGLEVEL_ 2 // Can be included as many times as necessary, without `Multiple Definitions` Linker Error #include // https://github.com/khoih-prog/Ethernet_Generic diff --git a/examples/multiFileProject/multiFileProject.ino b/examples/multiFileProject/multiFileProject.ino index fb3c8ce..ca75fd0 100644 --- a/examples/multiFileProject/multiFileProject.ino +++ b/examples/multiFileProject/multiFileProject.ino @@ -8,8 +8,8 @@ // To demo how to include files in multi-file Projects -#define ETHERNET_GENERIC_VERSION_MIN_TARGET "Ethernet_Generic v2.2.0" -#define ETHERNET_GENERIC_VERSION_MIN 2002000 +#define ETHERNET_GENERIC_VERSION_MIN_TARGET "Ethernet_Generic v2.3.0" +#define ETHERNET_GENERIC_VERSION_MIN 2003000 #include "multiFileProject.h" diff --git a/library.json b/library.json index 79564fa..05976ee 100644 --- a/library.json +++ b/library.json @@ -1,8 +1,8 @@ { "name": "Ethernet_Generic", - "version": "2.2.0", + "version": "2.3.0", "keywords": "WebServer, Ethernet, SPI2, Teensy, SAMD, STM32, SAM DUE, nRF52, ESP32, ESP8266, rpi-pico, rp2040, W5x00, W5500, LAN, Wiznet, WIZ550io, WIZ850io, USR-ES1", - "description": "Simple Ethernet library for AVR, Portenta_H7, Teensy, SAM DUE, SAMD21, SAMD51, STM32F/L/H/G/WB/MP1, nRF52 and RASPBERRY_PI_PICO boards using Ethernet shields W5100, W5200, W5500, W5100S. With this library, you can use the Arduino Ethernet (shield or board) to connect to Internet. The library provides both Client and server functionalities. The library permits you to connect to a local network also with DHCP and to resolve DNS. The h-only library now supporting SPI1/SPI2, EthernetLarge, Ethernet2 and Ethernet3 features by simply changing definitions in the sketch. RASPBERRY_PI_PICO using arduino-pico core now can use SPI1. Now STM32 can use any custom hardware / software SPI", + "description": "Simple Ethernet library for AVR, Portenta_H7, Teensy, SAM DUE, SAMD21, SAMD51, STM32F/L/H/G/WB/MP1, nRF52 and RASPBERRY_PI_PICO boards using Ethernet shields W5100, W5200, W5500, W5100S. With this library, you can use the Arduino Ethernet (shield or board) to connect to Internet. The library provides both Client and server functionalities. The library permits you to connect to a local network also with DHCP and to resolve DNS. The h-only library now supporting SPI1/SPI2, EthernetLarge, Ethernet2 and Ethernet3 features by simply changing definitions in the sketch. RASPBERRY_PI_PICO using arduino-pico core now can use SPI1. Now STM32, Arduino_mbed boards can use any custom hardware / software SPI", "authors": [ { "name": "Various", diff --git a/library.properties b/library.properties index 96fc1f0..8daf041 100644 --- a/library.properties +++ b/library.properties @@ -1,9 +1,9 @@ name=Ethernet_Generic -version=2.2.0 +version=2.3.0 author=Various (see AUTHORS file for details) maintainer=Khoi Hoang sentence=Simple Ethernet library for AVR, Portenta_H7, Teensy, SAM DUE, SAMD21, SAMD51, STM32F/L/H/G/WB/MP1, nRF52 and RASPBERRY_PI_PICO boards using Ethernet shields W5100, W5200, W5500, W5100S -paragraph=With this library, you can use the Arduino Ethernet (shield or board) to connect to Internet. The library provides both Client and server functionalities. The library permits you to connect to a local network also with DHCP and to resolve DNS. The h-only library now supporting SPI1/SPI2, EthernetLarge, Ethernet2 and Ethernet3 features by simply changing definitions in the sketch. RASPBERRY_PI_PICO using arduino-pico core now can use SPI1. Now STM32 can use any custom hardware / software SPI +paragraph=With this library, you can use the Arduino Ethernet (shield or board) to connect to Internet. The library provides both Client and server functionalities. The library permits you to connect to a local network also with DHCP and to resolve DNS. The h-only library now supporting SPI1/SPI2, EthernetLarge, Ethernet2 and Ethernet3 features by simply changing definitions in the sketch. RASPBERRY_PI_PICO using arduino-pico core now can use SPI1. Now STM32, Arduino_mbed boards can use any custom hardware / software SPI category=Communication url=https://github.com/khoih-prog/Ethernet_Generic architectures=* diff --git a/src/Dhcp.h b/src/Dhcp.h index be29396..e405327 100644 --- a/src/Dhcp.h +++ b/src/Dhcp.h @@ -13,7 +13,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer - Version: 2.2.0 + Version: 2.3.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 2.0.1 K Hoang 08/04/2022 Add support to SPI1 for RP2040 using arduino-pico core 2.1.0 K Hoang 22/04/2022 Add support to WIZNet W5100S 2.2.0 K Hoang 02/05/2022 Add support to custom SPI for any board, such as STM32 + 2.3.0 K Hoang 03/05/2022 Add support to custom SPI for RP2040, Portenta_H7, etc. using Arduino-mbed core *****************************************************************************************************************************/ // DHCP Library v0.3 - April 25, 2009 diff --git a/src/Dhcp_Impl.h b/src/Dhcp_Impl.h index bee7c98..7deb742 100644 --- a/src/Dhcp_Impl.h +++ b/src/Dhcp_Impl.h @@ -32,7 +32,7 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - Version: 2.2.0 + Version: 2.3.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -40,6 +40,7 @@ 2.0.1 K Hoang 08/04/2022 Add support to SPI1 for RP2040 using arduino-pico core 2.1.0 K Hoang 22/04/2022 Add support to WIZNet W5100S 2.2.0 K Hoang 02/05/2022 Add support to custom SPI for any board, such as STM32 + 2.3.0 K Hoang 03/05/2022 Add support to custom SPI for RP2040, Portenta_H7, etc. using Arduino-mbed core *****************************************************************************************************************************/ // DHCP Library v0.3 - April 25, 2009 diff --git a/src/Dns.h b/src/Dns.h index 6b109b7..8acc02c 100644 --- a/src/Dns.h +++ b/src/Dns.h @@ -13,7 +13,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer - Version: 2.2.0 + Version: 2.3.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 2.0.1 K Hoang 08/04/2022 Add support to SPI1 for RP2040 using arduino-pico core 2.1.0 K Hoang 22/04/2022 Add support to WIZNet W5100S 2.2.0 K Hoang 02/05/2022 Add support to custom SPI for any board, such as STM32 + 2.3.0 K Hoang 03/05/2022 Add support to custom SPI for RP2040, Portenta_H7, etc. using Arduino-mbed core *****************************************************************************************************************************/ // Arduino DNS client for WizNet5100-based Ethernet shield diff --git a/src/Dns_Impl.h b/src/Dns_Impl.h index 868c4f0..44f3311 100644 --- a/src/Dns_Impl.h +++ b/src/Dns_Impl.h @@ -32,7 +32,7 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - Version: 2.2.0 + Version: 2.3.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -40,6 +40,7 @@ 2.0.1 K Hoang 08/04/2022 Add support to SPI1 for RP2040 using arduino-pico core 2.1.0 K Hoang 22/04/2022 Add support to WIZNet W5100S 2.2.0 K Hoang 02/05/2022 Add support to custom SPI for any board, such as STM32 + 2.3.0 K Hoang 03/05/2022 Add support to custom SPI for RP2040, Portenta_H7, etc. using Arduino-mbed core *****************************************************************************************************************************/ // Arduino DNS client for WizNet5100-based Ethernet shield // (c) Copyright 2009-2010 MCQN Ltd. diff --git a/src/EthernetClient.h b/src/EthernetClient.h index 3acd267..0e08c80 100644 --- a/src/EthernetClient.h +++ b/src/EthernetClient.h @@ -13,7 +13,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer - Version: 2.2.0 + Version: 2.3.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 2.0.1 K Hoang 08/04/2022 Add support to SPI1 for RP2040 using arduino-pico core 2.1.0 K Hoang 22/04/2022 Add support to WIZNet W5100S 2.2.0 K Hoang 02/05/2022 Add support to custom SPI for any board, such as STM32 + 2.3.0 K Hoang 03/05/2022 Add support to custom SPI for RP2040, Portenta_H7, etc. using Arduino-mbed core *****************************************************************************************************************************/ // This file is in the public domain. No copyright is claimed. diff --git a/src/EthernetClient_Impl.h b/src/EthernetClient_Impl.h index 4641826..c249019 100644 --- a/src/EthernetClient_Impl.h +++ b/src/EthernetClient_Impl.h @@ -32,7 +32,7 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - Version: 2.2.0 + Version: 2.3.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -40,6 +40,7 @@ 2.0.1 K Hoang 08/04/2022 Add support to SPI1 for RP2040 using arduino-pico core 2.1.0 K Hoang 22/04/2022 Add support to WIZNet W5100S 2.2.0 K Hoang 02/05/2022 Add support to custom SPI for any board, such as STM32 + 2.3.0 K Hoang 03/05/2022 Add support to custom SPI for RP2040, Portenta_H7, etc. using Arduino-mbed core *****************************************************************************************************************************/ #pragma once diff --git a/src/EthernetServer.h b/src/EthernetServer.h index 432acb9..31b81b5 100644 --- a/src/EthernetServer.h +++ b/src/EthernetServer.h @@ -13,7 +13,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer - Version: 2.2.0 + Version: 2.3.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 2.0.1 K Hoang 08/04/2022 Add support to SPI1 for RP2040 using arduino-pico core 2.1.0 K Hoang 22/04/2022 Add support to WIZNet W5100S 2.2.0 K Hoang 02/05/2022 Add support to custom SPI for any board, such as STM32 + 2.3.0 K Hoang 03/05/2022 Add support to custom SPI for RP2040, Portenta_H7, etc. using Arduino-mbed core *****************************************************************************************************************************/ // This file is in the public domain. No copyright is claimed. diff --git a/src/EthernetServer_Impl.h b/src/EthernetServer_Impl.h index abeab4b..482be13 100644 --- a/src/EthernetServer_Impl.h +++ b/src/EthernetServer_Impl.h @@ -32,7 +32,7 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - Version: 2.2.0 + Version: 2.3.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -40,6 +40,7 @@ 2.0.1 K Hoang 08/04/2022 Add support to SPI1 for RP2040 using arduino-pico core 2.1.0 K Hoang 22/04/2022 Add support to WIZNet W5100S 2.2.0 K Hoang 02/05/2022 Add support to custom SPI for any board, such as STM32 + 2.3.0 K Hoang 03/05/2022 Add support to custom SPI for RP2040, Portenta_H7, etc. using Arduino-mbed core *****************************************************************************************************************************/ #pragma once diff --git a/src/EthernetUdp.h b/src/EthernetUdp.h index 9dfbf58..9a8ab6c 100644 --- a/src/EthernetUdp.h +++ b/src/EthernetUdp.h @@ -13,7 +13,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer - Version: 2.2.0 + Version: 2.3.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 2.0.1 K Hoang 08/04/2022 Add support to SPI1 for RP2040 using arduino-pico core 2.1.0 K Hoang 22/04/2022 Add support to WIZNet W5100S 2.2.0 K Hoang 02/05/2022 Add support to custom SPI for any board, such as STM32 + 2.3.0 K Hoang 03/05/2022 Add support to custom SPI for RP2040, Portenta_H7, etc. using Arduino-mbed core *****************************************************************************************************************************/ /* * Udp.cpp: Library to send/receive UDP packets with the Arduino ethernet shield. diff --git a/src/EthernetUdp_Impl.h b/src/EthernetUdp_Impl.h index 43551f2..6fa7973 100644 --- a/src/EthernetUdp_Impl.h +++ b/src/EthernetUdp_Impl.h @@ -13,7 +13,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer - Version: 2.2.0 + Version: 2.3.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 2.0.1 K Hoang 08/04/2022 Add support to SPI1 for RP2040 using arduino-pico core 2.1.0 K Hoang 22/04/2022 Add support to WIZNet W5100S 2.2.0 K Hoang 02/05/2022 Add support to custom SPI for any board, such as STM32 + 2.3.0 K Hoang 03/05/2022 Add support to custom SPI for RP2040, Portenta_H7, etc. using Arduino-mbed core *****************************************************************************************************************************/ /* * Udp.cpp: Library to send/receive UDP packets with the Arduino ethernet shield. diff --git a/src/Ethernet_Generic.h b/src/Ethernet_Generic.h index 42517f4..e5464de 100644 --- a/src/Ethernet_Generic.h +++ b/src/Ethernet_Generic.h @@ -32,7 +32,7 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - Version: 2.2.0 + Version: 2.3.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -40,6 +40,7 @@ 2.0.1 K Hoang 08/04/2022 Add support to SPI1 for RP2040 using arduino-pico core 2.1.0 K Hoang 22/04/2022 Add support to WIZNet W5100S 2.2.0 K Hoang 02/05/2022 Add support to custom SPI for any board, such as STM32 + 2.3.0 K Hoang 03/05/2022 Add support to custom SPI for RP2040, Portenta_H7, etc. using Arduino-mbed core *****************************************************************************************************************************/ #pragma once @@ -50,13 +51,13 @@ ///////////////////////////////////////////////////////// -#define ETHERNET_GENERIC_VERSION "Ethernet_Generic v2.2.0" +#define ETHERNET_GENERIC_VERSION "Ethernet_Generic v2.3.0" #define ETHERNET_GENERIC_VERSION_MAJOR 2 -#define ETHERNET_GENERIC_VERSION_MINOR 2 +#define ETHERNET_GENERIC_VERSION_MINOR 3 #define ETHERNET_GENERIC_VERSION_PATCH 0 -#define ETHERNET_GENERIC_VERSION_INT 2002000 +#define ETHERNET_GENERIC_VERSION_INT 2003000 ///////////////////////////////////////////////////////// diff --git a/src/Ethernet_Generic.hpp b/src/Ethernet_Generic.hpp index 77a0669..cc6dc81 100644 --- a/src/Ethernet_Generic.hpp +++ b/src/Ethernet_Generic.hpp @@ -32,7 +32,7 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - Version: 2.2.0 + Version: 2.3.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -40,6 +40,7 @@ 2.0.1 K Hoang 08/04/2022 Add support to SPI1 for RP2040 using arduino-pico core 2.1.0 K Hoang 22/04/2022 Add support to WIZNet W5100S 2.2.0 K Hoang 02/05/2022 Add support to custom SPI for any board, such as STM32 + 2.3.0 K Hoang 03/05/2022 Add support to custom SPI for RP2040, Portenta_H7, etc. using Arduino-mbed core *****************************************************************************************************************************/ #pragma once @@ -91,6 +92,10 @@ #include #include +#if defined(ARDUINO_ARCH_MBED) + #define SPIClass arduino::MbedSPI +#endif + #include "Client.h" #include "Server.h" #include "Udp.h" diff --git a/src/Ethernet_Generic_Debug.h b/src/Ethernet_Generic_Debug.h index 89379ab..f7415ae 100644 --- a/src/Ethernet_Generic_Debug.h +++ b/src/Ethernet_Generic_Debug.h @@ -13,7 +13,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer - Version: 2.2.0 + Version: 2.3.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 2.0.1 K Hoang 08/04/2022 Add support to SPI1 for RP2040 using arduino-pico core 2.1.0 K Hoang 22/04/2022 Add support to WIZNet W5100S 2.2.0 K Hoang 02/05/2022 Add support to custom SPI for any board, such as STM32 + 2.3.0 K Hoang 03/05/2022 Add support to custom SPI for RP2040, Portenta_H7, etc. using Arduino-mbed core *****************************************************************************************************************************/ #pragma once diff --git a/src/Ethernet_Generic_Impl.h b/src/Ethernet_Generic_Impl.h index 106b5a9..f565c94 100644 --- a/src/Ethernet_Generic_Impl.h +++ b/src/Ethernet_Generic_Impl.h @@ -32,7 +32,7 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - Version: 2.2.0 + Version: 2.3.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -40,6 +40,7 @@ 2.0.1 K Hoang 08/04/2022 Add support to SPI1 for RP2040 using arduino-pico core 2.1.0 K Hoang 22/04/2022 Add support to WIZNet W5100S 2.2.0 K Hoang 02/05/2022 Add support to custom SPI for any board, such as STM32 + 2.3.0 K Hoang 03/05/2022 Add support to custom SPI for RP2040, Portenta_H7, etc. using Arduino-mbed core *****************************************************************************************************************************/ #pragma once diff --git a/src/socket_Impl.h b/src/socket_Impl.h index 9f2ec44..2c2feaf 100644 --- a/src/socket_Impl.h +++ b/src/socket_Impl.h @@ -32,7 +32,7 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - Version: 2.2.0 + Version: 2.3.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -40,6 +40,7 @@ 2.0.1 K Hoang 08/04/2022 Add support to SPI1 for RP2040 using arduino-pico core 2.1.0 K Hoang 22/04/2022 Add support to WIZNet W5100S 2.2.0 K Hoang 02/05/2022 Add support to custom SPI for any board, such as STM32 + 2.3.0 K Hoang 03/05/2022 Add support to custom SPI for RP2040, Portenta_H7, etc. using Arduino-mbed core *****************************************************************************************************************************/ #pragma once diff --git a/src/utility/w5100.h b/src/utility/w5100.h index e6f7f60..bec3617 100644 --- a/src/utility/w5100.h +++ b/src/utility/w5100.h @@ -13,7 +13,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer - Version: 2.2.0 + Version: 2.3.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 2.0.1 K Hoang 08/04/2022 Add support to SPI1 for RP2040 using arduino-pico core 2.1.0 K Hoang 22/04/2022 Add support to WIZNet W5100S 2.2.0 K Hoang 02/05/2022 Add support to custom SPI for any board, such as STM32 + 2.3.0 K Hoang 03/05/2022 Add support to custom SPI for RP2040, Portenta_H7, etc. using Arduino-mbed core *****************************************************************************************************************************/ // w5100.h contains private W5x00 hardware "driver" level definitions @@ -28,7 +29,7 @@ #pragma once -#ifndef W5100_H_INCLUDED +#ifndef W5100_H_INCLUDED #define W5100_H_INCLUDED #include diff --git a/src/utility/w5100_Impl.h b/src/utility/w5100_Impl.h index f1397ee..544fa1c 100644 --- a/src/utility/w5100_Impl.h +++ b/src/utility/w5100_Impl.h @@ -13,7 +13,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer - Version: 2.2.0 + Version: 2.3.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 2.0.1 K Hoang 08/04/2022 Add support to SPI1 for RP2040 using arduino-pico core 2.1.0 K Hoang 22/04/2022 Add support to WIZNet W5100S 2.2.0 K Hoang 02/05/2022 Add support to custom SPI for any board, such as STM32 + 2.3.0 K Hoang 03/05/2022 Add support to custom SPI for RP2040, Portenta_H7, etc. using Arduino-mbed core *****************************************************************************************************************************/ #pragma once @@ -54,7 +55,7 @@ #endif #if (_ETG_LOGLEVEL_ > 3) - #warning w5100.cpp Use PIN_SPI_SS_ETHERNET_LIB defined, change SS_PIN_DEFAULT to PIN_SPI_SS_ETHERNET_LIB + #warning w5100_Impl.h : Use PIN_SPI_SS_ETHERNET_LIB defined, change SS_PIN_DEFAULT to PIN_SPI_SS_ETHERNET_LIB #endif /////////////////////////// @@ -68,7 +69,7 @@ #endif #if (_ETG_LOGLEVEL_ > 3) - #warning w5100.cpp Use MKR, change SS_PIN_DEFAULT to 5 + #warning w5100_Impl.h : Use MKR, change SS_PIN_DEFAULT to 5 #endif /////////////////////////// @@ -84,7 +85,7 @@ #endif #if (_ETG_LOGLEVEL_ > 3) - #warning w5100.cpp Use __AVR__, change SS_PIN_DEFAULT to 10 + #warning w5100_Impl.h : Use __AVR__, change SS_PIN_DEFAULT to 10 #endif /////////////////////////// @@ -97,7 +98,7 @@ #if (_ETG_LOGLEVEL_ > 3) //10 - 2 (6 conflict) all not OK for Nano 33 IoT !!! SPI corrupted??? - #warning w5100.cpp Use __SAMD21G18A__, change SS_PIN_DEFAULT to 10 + #warning w5100_Impl.h : Use __SAMD21G18A__, change SS_PIN_DEFAULT to 10 #endif #if !defined(SS_PIN_DEFAULT) @@ -111,7 +112,7 @@ #endif #if (_ETG_LOGLEVEL_ > 3) - #warning w5100.cpp Use PIN_SPI_SS defined, change SS_PIN_DEFAULT to PIN_SPI_SS + #warning w5100_Impl.h : Use PIN_SPI_SS defined, change SS_PIN_DEFAULT to PIN_SPI_SS #endif #endif @@ -125,7 +126,7 @@ #endif #if (_ETG_LOGLEVEL_ > 3) - #warning w5100.cpp Use CORE_SS0_PIN defined, change SS_PIN_DEFAULT to CORE_SS0_PIN + #warning w5100_Impl.h : Use CORE_SS0_PIN defined, change SS_PIN_DEFAULT to CORE_SS0_PIN #endif /////////////////////////// @@ -136,7 +137,7 @@ #if (_ETG_LOGLEVEL_ > 3) //pin SS already defined in ESP32 as pin 5, don't use this as conflict with SPIFFS, EEPROM, etc. // Use in GPIO22 - #warning w5100.cpp Use ESP32, change SS_PIN_DEFAULT to GPIO22, MOSI(23), MISO(19), SCK(18) + #warning w5100_Impl.h : Use ESP32, change SS_PIN_DEFAULT to GPIO22, MOSI(23), MISO(19), SCK(18) #endif #if !defined(SS_PIN_DEFAULT) @@ -150,7 +151,7 @@ #if (_ETG_LOGLEVEL_ > 3) //pin SS already defined in ESP8266 as pin 15. Conflict => Move to pin GPIO4 (D2) - #warning w5100.cpp Use ESP8266, change SS_PIN_DEFAULT to SS(4), MOSI(13), MISO(12), SCK(14) + #warning w5100_Impl.h : Use ESP8266, change SS_PIN_DEFAULT to SS(4), MOSI(13), MISO(12), SCK(14) #endif #if !defined(SS_PIN_DEFAULT) @@ -168,7 +169,7 @@ #if (_ETG_LOGLEVEL_ > 3) //KH - #warning w5100.cpp Use fallback, change SS_PIN_DEFAULT to 10 + #warning w5100_Impl.h : Use fallback, change SS_PIN_DEFAULT to 10 #endif #endif @@ -214,8 +215,9 @@ W5100Class W5100; #define CUR_PIN_MOSI PIN_SPI1_MOSI #define CUR_PIN_SCK PIN_SPI1_SCK #define CUR_PIN_SS PIN_SPI1_SS - + #elif (USING_CUSTOM_SPI) + #if ( defined(CUR_PIN_MOSI) && defined(CUR_PIN_MISO) && defined(CUR_PIN_SCK) && defined(CUR_PIN_SS) ) #if (SPI_NEW_INITIALIZED) #if(_ETG_LOGLEVEL_> 2) @@ -226,11 +228,19 @@ W5100Class W5100; #warning ETHERNET_GENERIC_USING_SPI2 without SPI_NEW_INITIALIZED in w5100_Impl.h #endif - // Don't create the instance with CUR_PIN_SS, or Ethernet not working - SPIClass SPI_New(CUR_PIN_MOSI, CUR_PIN_MISO, CUR_PIN_SCK); + #if defined(ARDUINO_ARCH_MBED) + // Don't create the instance with CUR_PIN_SS, or Ethernet not working + // Be careful, Mbed SPI ctor is so weird, reversing the order => MISO, MOSI, SCK + //arduino::MbedSPI::MbedSPI(int miso, int mosi, int sck) + SPIClass SPI_New(CUR_PIN_MISO, CUR_PIN_MOSI, CUR_PIN_SCK); + #else + // Don't create the instance with CUR_PIN_SS, or Ethernet not working + SPIClass SPI_New(CUR_PIN_MOSI, CUR_PIN_MISO, CUR_PIN_SCK); + #endif #endif SPIClass* pCUR_SPI = (SPIClass*) &SPI_New; + #else #error You must define CUR_PIN_MOSI, CUR_PIN_MISO, CUR_PIN_SCK and CUR_PIN_SS #endif @@ -273,7 +283,7 @@ W5100Class W5100; uint32_t W5100Class::ss_pin_mask; #if (_ETG_LOGLEVEL_ > 3) - #warning w5100.cpp Use __SAMD21G18A__ + #warning w5100_Impl.h : Use __SAMD21G18A__ #endif #endif