From aa5b97c77f91cf5a3446921530d6815a7edeed73 Mon Sep 17 00:00:00 2001 From: Khoi Hoang <57012152+khoih-prog@users.noreply.github.com> Date: Mon, 25 Apr 2022 01:23:39 -0400 Subject: [PATCH] v1.1.0 to use `Ethernet_Generic` library ### Releases v1.1.0 1. Use new [Ethernet_Generic library](https://github.com/khoih-prog/Ethernet_Generic) as default for W5x00. 2. Add support to `SPI1` for `RP2040` using [`Earle Philhower's arduino-pico` core](https://github.com/earlephilhower/arduino-pico) 3. Add support to WIZNet W5100S, such as [**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) --- CONTRIBUTING.md | 10 +- README.md | 312 +++++++++--------- changelog.md | 7 + .../RP2040_RTC_Alarm/RP2040_RTC_Alarm.ino | 2 +- .../RP2040_RTC_Alarm_Ethernet.ino | 182 +++------- .../Alarm/RP2040_RTC_Alarm_Ethernet/defines.h | 55 ++- .../RP2040_RTC_Alarm_WiFiNINA.ino | 2 +- .../Time/RP2040_RTC_Time/RP2040_RTC_Time.ino | 2 +- .../RP2040_RTC_Time_Ethernet.ino | 183 +++------- .../Time/RP2040_RTC_Time_Ethernet/defines.h | 55 ++- .../RP2040_RTC_Time_WiFiNINA.ino | 2 +- library.json | 22 +- library.properties | 3 +- platformio/platformio.ini | 11 + 14 files changed, 339 insertions(+), 509 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e7a1486..3f1dca1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,8 +14,8 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p Please ensure to specify the following: -* Arduino IDE version (e.g. 1.8.16) or Platform.io version -* `RP2040` Core Version (e.g. Arduino-mbed RP2040 v2.5.2 or arduino-pico core v1.9.5) +* Arduino IDE version (e.g. 1.8.19) or Platform.io version +* `RP2040` Core Version (e.g. Arduino-mbed RP2040 v3.0.1 or arduino-pico core v1.13.3) * `RP2040` Board type (e.g. NANO_RP2040_CONNECT, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040, GENERIC_RP2040, etc.) * Contextual information (e.g. what you were trying to achieve) * Simplest possible steps to reproduce @@ -27,11 +27,11 @@ Please ensure to specify the following: ### Example ``` -Arduino IDE version: 1.8.16 -Arduino-mbed RP2040 v2.5.2 +Arduino IDE version: 1.8.19 +Arduino-mbed RP2040 v3.0.1 NANO_RP2040_CONNECT Module OS: Ubuntu 20.04 LTS -Linux xy-Inspiron-3593 5.4.0-96-generic #109-Ubuntu SMP Wed Jan 12 16:49:16 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux +Linux xy-Inspiron-3593 5.13.0-40-generic #45~20.04.1-Ubuntu SMP Mon Apr 4 09:38:31 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux Context: I encountered a crash while using TimerInterrupt. diff --git a/README.md b/README.md index 1875174..cda627a 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ * [Features](#features) * [Why using ISR-based Alarm is better](#why-using-isr-based-alarm-is-better) * [Currently supported Boards](#currently-supported-boards) - * [Important Notes about ISR](#important-notes-about-isr) + * [Currently supported Ethernet shields/modules](#currently-supported-ethernet-shieldsmodules) * [Changelog](changelog.md) * [Prerequisites](#prerequisites) * [Installation](#installation) @@ -51,13 +51,13 @@ * [ 1. File RP2040_RTC_Time_WiFiNINA.ino](#1-file-rp2040_rtc_time_wifininaino) * [ 2. File defines.h](#2-file-definesh) * [Debug Terminal Output Samples](#debug-terminal-output-samples) - * [1. RP2040_RTC_Time_Ethernet on RASPBERRY_PI_PICO with W5x00 using EthernetLarge Library](#1-rp2040_rtc_time_ethernet-on-raspberry_pi_pico-with-w5x00-using-ethernetlarge-library) - * [2. RP2040_RTC_Time_Ethernet on MBED RASPBERRY_PI_PICO with W5x00 using EthernetLarge Library](#2-rp2040_rtc_time_ethernet-on-mbed-raspberry_pi_pico-with-w5x00-using-ethernetlarge-library) + * [1. RP2040_RTC_Time_Ethernet on RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library](#1-rp2040_rtc_time_ethernet-on-raspberry_pi_pico-with-w5x00-using-Ethernet_Generic-library) + * [2. RP2040_RTC_Time_Ethernet on MBED RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library](#2-rp2040_rtc_time_ethernet-on-mbed-raspberry_pi_pico-with-w5x00-using-Ethernet_Generic-library) * [3. RP2040_RTC_Time_WiFiNINA on MBED NANO_RP2040_CONNECT with WiFiNINA using WiFiNINA_Generic Library](#3-rp2040_rtc_time_wifinina-on-mbed-nano_rp2040_connect-with-wifinina-using-wifinina_generic-library) - * [4. RP2040_RTC_Alarm_Ethernet on RASPBERRY_PI_PICO with W5x00 using EthernetLarge Library](#4-rp2040_rtc_alarm_ethernet-on-raspberry_pi_pico-with-w5x00-using-ethernetlarge-library) + * [4. RP2040_RTC_Alarm_Ethernet on RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library](#4-rp2040_rtc_alarm_ethernet-on-raspberry_pi_pico-with-w5x00-using-Ethernet_Generic-library) * [4.1 Repeatitive Alarm](#41-repeatitive-alarm) * [4.2 One-shot Alarm](#42-one-shot-alarm) - * [5. RP2040_RTC_Alarm_Ethernet on MBED RASPBERRY_PI_PICO with W5x00 using EthernetLarge Library](#5-rp2040_rtc_alarm_ethernet-on-mbed-on-raspberry_pi_pico-with-w5x00-using-ethernetlarge-library) + * [5. RP2040_RTC_Alarm_Ethernet on MBED RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library](#5-rp2040_rtc_alarm_ethernet-on-mbed-raspberry_pi_pico-with-w5x00-using-Ethernet_Generic-library) * [5.1 Repeatitive Alarm](#51-repeatitive-alarm) * [5.2 One-shot Alarm](#52-one-shot-alarm) * [6. RP2040_RTC_Alarm_WiFiNINA on MBED NANO_RP2040_CONNECT with WiFiNINA using WiFiNINA_Generic Library](#6-rp2040_rtc_alarm_wifinina-on-mbed-nano_rp2040_connect-with-wifinina-using-wifinina_generic-library) @@ -113,17 +113,13 @@ The catch is **your function is now part of an ISR (Interrupt Service Routine), ### Currently supported Boards -1. RP2040-based boards such as **NANO_RP2040_CONNECT, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, etc. +1. RP2040-based boards, such as **NANO_RP2040_CONNECT, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, using [**Arduino-mbed RP2040** core](https://github.com/arduino/ArduinoCore-mbed) or [**Earle Philhower's arduino-pico** core](https://github.com/earlephilhower/arduino-pico). ---- - -### Important Notes about ISR - -1. Inside the attached function, **delay() won’t work and the value returned by millis() will not increment.** Serial data received while in the function may be lost. You should declare as **volatile any variables that you modify within the attached function.** +#### Currently supported Ethernet shields/modules -2. Typically global variables are used to pass data between an ISR and the main program. To make sure variables shared between an ISR and the main program are updated correctly, declare them as volatile. +1. W5x00 using [`Ethernet_Generic`](https://github.com/khoih-prog/Ethernet_Generic) library +2. W5100S shield /module, using [`Ethernet_Generic`](https://github.com/khoih-prog/Ethernet_Generic) library, such as [**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) -3. Don't use Serial.print(ln) function inside ISR or system will hang up. --- --- @@ -132,17 +128,14 @@ The catch is **your function is now part of an ISR (Interrupt Service Routine), ## Prerequisites 1. [`Arduino IDE 1.8.19+` for Arduino](https://github.com/arduino/Arduino). [![GitHub release](https://img.shields.io/github/release/arduino/Arduino.svg)](https://github.com/arduino/Arduino/releases/latest) -2. [`Arduino mbed_rp2040 core 2.7.2+`](https://github.com/arduino/ArduinoCore-mbed) for Arduino RP2040-based boards, such as **Arduino Nano RP2040 Connect, RASPBERRY_PI_PICO, etc.**. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-mbed.svg)](https://github.com/arduino/ArduinoCore-mbed/releases/latest) -3. [`Earle Philhower's arduino-pico core v1.10.0+`](https://github.com/earlephilhower/arduino-pico) for RP2040-based boards such as **RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, etc. [![GitHub release](https://img.shields.io/github/release/earlephilhower/arduino-pico.svg)](https://github.com/earlephilhower/arduino-pico/releases/latest) +2. [`Arduino mbed_rp2040 core 3.0.1+`](https://github.com/arduino/ArduinoCore-mbed) for Arduino RP2040-based boards, such as **Arduino Nano RP2040 Connect, RASPBERRY_PI_PICO, etc.**. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-mbed.svg)](https://github.com/arduino/ArduinoCore-mbed/releases/latest) +3. [`Earle Philhower's arduino-pico core v1.13.3+`](https://github.com/earlephilhower/arduino-pico) for RP2040-based boards such as **RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, etc. [![GitHub release](https://img.shields.io/github/release/earlephilhower/arduino-pico.svg)](https://github.com/earlephilhower/arduino-pico/releases/latest) -4. [`Timezone_Generic library v1.9.1+`](https://github.com/khoih-prog/Timezone_Generic) to use examples using Timezone. To install, check [![arduino-library-badge](https://www.ardu-badge.com/badge/Timezone_Generic.svg?)](https://www.ardu-badge.com/Timezone_Generic) +4. [`Timezone_Generic library v1.10.0+`](https://github.com/khoih-prog/Timezone_Generic) to use examples using Timezone. To install, check [![arduino-library-badge](https://www.ardu-badge.com/badge/Timezone_Generic.svg?)](https://www.ardu-badge.com/Timezone_Generic) 5. [`WiFiNINA_Generic library v1.8.14-3+`](https://github.com/khoih-prog/WiFiNINA_Generic) to use WiFiNINA modules/shields. To install. check [![arduino-library-badge](https://www.ardu-badge.com/badge/WiFiNINA_Generic.svg?)](https://www.ardu-badge.com/WiFiNINA_Generic) if using `WiFiNINA_Generic` library for Nano-RP2040-Connect boards. 6. Depending on which Ethernet card/module/shield you're using: - - [`Ethernet library v2.0.0+`](https://github.com/arduino-libraries/Ethernet) for W5100, W5200 and W5500. [![GitHub release](https://img.shields.io/github/release/arduino-libraries/Ethernet.svg)](https://github.com/arduino-libraries/Ethernet/releases/latest) - - [`EthernetLarge library v2.0.0+`](https://github.com/OPEnSLab-OSU/EthernetLarge) for W5100, W5200 and W5500. - - [`Ethernet2 library v1.0.4+`](https://github.com/khoih-prog/Ethernet2) for W5500. [![GitHub release](https://img.shields.io/github/release/adafruit/Ethernet2.svg)](https://github.com/adafruit/Ethernet2/releases/latest) - - [`Ethernet3 library v1.5.5+`](https://github.com/sstaub/Ethernet3) for W5500/WIZ550io/WIZ850io/USR-ES1 with Wiznet W5500 chip. [![GitHub release](https://img.shields.io/github/release/sstaub/Ethernet3.svg)](https://github.com/sstaub/Ethernet3/releases/latest) + - [`Ethernet_Generic library v2.1.0+`](https://github.com/khoih-prog/Ethernet_Generic) for W5100, W5200 and W5500/WIZ550io/WIZ850io/USR-ES1 with Wiznet W5500 chip. [![GitHub release](https://img.shields.io/github/release/khoih-prog/Ethernet_Generic.svg)](https://github.com/khoih-prog/Ethernet_Generic/releases/latest) - [`EthernetENC library v2.0.2+`](https://github.com/jandrassy/EthernetENC) for ENC28J60. [![GitHub release](https://img.shields.io/github/release/jandrassy/EthernetENC.svg)](https://github.com/jandrassy/EthernetENC/releases/latest). **New and Better** --- @@ -168,7 +161,7 @@ Another way to install is to: 1. Install [VS Code](https://code.visualstudio.com/) 2. Install [PlatformIO](https://platformio.org/platformio-ide) -3. Install [**RP2040_RTC** library](https://platformio.org/lib/show/12433/RP2040_RTC) or [**RP2040_RTC** library](https://platformio.org/lib/show/12433/RP2040_RTC) by using [Library Manager](https://platformio.org/lib/show/12433/RP2040_RTC/installation). Search for **RP2040_RTC** in [Platform.io Author's Libraries](https://platformio.org/lib/search?query=author:%22Khoi%20Hoang%22) +3. Install [**RP2040_RTC** library](https://registry.platformio.org/libraries/khoih-prog/RP2040_RTC) or [**RP2040_RTC** library](https://registry.platformio.org/libraries/khoih-prog/RP2040_RTC) by using [Library Manager](https://platformio.org/lib/show/12433/RP2040_RTC/installation). Search for **RP2040_RTC** in [Platform.io Author's Libraries](https://platformio.org/lib/search?query=author:%22Khoi%20Hoang%22) 4. Please visit documentation for the other options and examples at [Project Configuration File](https://docs.platformio.org/page/projectconf.html) @@ -773,25 +766,22 @@ char pass[] = "12345678"; // your network password ### Debug Terminal Output Samples -#### 1. RP2040_RTC_Time_Ethernet on RASPBERRY_PI_PICO with W5x00 using EthernetLarge Library +#### 1. RP2040_RTC_Time_Ethernet on RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library -The following is the sample terminal output when running example [RP2040_RTC_Time_Ethernet](examples/Time/RP2040_RTC_Time_Ethernet) on RASPBERRY_PI_PICO with W5x00 using EthernetLarge Library +The following is the sample terminal output when running example [RP2040_RTC_Time_Ethernet](examples/Time/RP2040_RTC_Time_Ethernet) on RASPBERRY_PI_PICO with W5100S using Ethernet_Generic Library ``` -Start RP2040_RTC_Time_Ethernet on RASPBERRY_PI_PICO with W5x00 using EthernetLarge Library -RP2040_RTC v1.0.8 -Timezone_Generic v1.9.0 -[EWS] =========== USE_ETHERNET_LARGE =========== +Start RP2040_RTC_Time_Ethernet on RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library +RP2040_RTC v1.1.0 +Timezone_Generic v1.10.0 +[EWS] =========== USE_ETHERNET_GENERIC =========== [EWS] Default SPI pinout: [EWS] MOSI: 19 [EWS] MISO: 16 [EWS] SCK: 18 [EWS] SS: 17 [EWS] ========================= -[EWS] Board : RASPBERRY_PI_PICO , setCsPin: 17 -_pinCS = 0 -W5100 init, using SS_PIN_DEFAULT = 10, new ss_pin = 10, W5100Class::ss_pin = 17 -W5100::init: W5500, SSIZE =8192 +[EWS] RPIPICO setCsPin: 17 ========================= Currently Used SPI pinout: MOSI:19 @@ -800,54 +790,57 @@ SCK:18 SS:17 ========================= Using mac index = 10 -You're connected to the network, IP = 192.168.2.94 +You're connected to the network, IP = 192.168.2.95 Packet received -Seconds since Jan 1 1900 = 3851712307 -Unix time = 1642723507 -The UTC time is 0:05:07 +Seconds since Jan 1 1900 = 3859851978 +Unix time = 1650863178 +The UTC time is 5:06:18 ============================ -00:05:08 Fri 21 Jan 2022 UTC -19:05:08 Thu 20 Jan 2022 EST +05:06:19 Mon 25 Apr 2022 UTC +01:06:19 Mon 25 Apr 2022 EDT ``` --- -#### 2. RP2040_RTC_Time_Ethernet on MBED RASPBERRY_PI_PICO with W5x00 using EthernetLarge Library +#### 2. RP2040_RTC_Time_Ethernet on MBED RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library -The following is the sample terminal output when running example [RP2040_RTC_Time_Ethernet](examples/Time/RP2040_RTC_Time_Ethernet) on MBED RASPBERRY_PI_PICO with W5x00 using EthernetLarge Library +The following is the sample terminal output when running example [RP2040_RTC_Time_Ethernet](examples/Time/RP2040_RTC_Time_Ethernet) on MBED RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library ``` -Start RP2040_RTC_Time_Ethernet on RASPBERRY_PI_PICO with W5x00 using EthernetLarge Library -RP2040_RTC v1.0.8 -Timezone_Generic v1.9.0 -[EWS] =========== USE_ETHERNET_LARGE =========== +Start RP2040_RTC_Time_Ethernet on MBED RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library +RP2040_RTC v1.1.0 +Timezone_Generic v1.10.0 +[EWS] =========== USE_ETHERNET_GENERIC =========== [EWS] Default SPI pinout: -[EWS] MOSI: 3 -[EWS] MISO: 4 -[EWS] SCK: 2 -[EWS] SS: 5 +[EWS] MOSI: 19 +[EWS] MISO: 16 +[EWS] SCK: 18 +[EWS] SS: 17 [EWS] ========================= -[EWS] Board : MBED RASPBERRY_PI_PICO , setCsPin: 5 -_pinCS = 0 -W5100 init, using SS_PIN_DEFAULT = 5, new ss_pin = 10, W5100Class::ss_pin = 5 -W5100::init: W5500, SSIZE =8192 +[EWS] RPIPICO setCsPin: 17 ========================= Currently Used SPI pinout: -MOSI:3 -MISO:4 -SCK:2 -SS:5 +MOSI:19 +MISO:16 +SCK:18 +SS:17 ========================= -Using mac index = 19 -You're connected to the network, IP = 192.168.2.104 +Using mac index = 1 +You're connected to the network, IP = 192.168.2.102 Packet received -Seconds since Jan 1 1900 = 3851712307 -Unix time = 1642723507 -The UTC time is 0:05:07 +Seconds since Jan 1 1900 = 3859851547 +Unix time = 1650862747 +The UTC time is 4:59:07 ============================ -00:05:08 Fri 21 Jan 2022 UTC -19:05:08 Thu 20 Jan 2022 EST +04:59:08 Mon 25 Apr 2022 UTC +00:59:08 Mon 25 Apr 2022 EDT +============================ +05:00:08 Mon 25 Apr 2022 UTC +01:00:08 Mon 25 Apr 2022 EDT +============================ +05:01:08 Mon 25 Apr 2022 UTC +01:01:08 Mon 25 Apr 2022 EDT ``` --- @@ -858,42 +851,39 @@ The following is the sample terminal output when running example [RP2040_RTC_Tim ``` Start RP2040_RTC_Time_WiFiNINA on MBED NANO_RP2040_CONNECT with WiFiNINA using WiFiNINA_Generic Library -RP2040_RTC v1.0.8 -Timezone_Generic v1.9.0 +RP2040_RTC v1.1.0 +Timezone_Generic v1.10.0 Connecting to WPA SSID: HueNet1 You're connected to the network, IP = 192.168.2.153 Packet received -Seconds since Jan 1 1900 = 3851712307 -Unix time = 1642723507 -The UTC time is 0:05:07 +Seconds since Jan 1 1900 = 3859851547 +Unix time = 1650862747 +The UTC time is 4:59:07 ============================ -00:05:08 Fri 21 Jan 2022 UTC -19:05:08 Thu 20 Jan 2022 EST +04:59:08 Mon 25 Apr 2022 UTC +00:59:08 Mon 25 Apr 2022 EDT ``` --- -#### 4. RP2040_RTC_Alarm_Ethernet on RASPBERRY_PI_PICO with W5x00 using EthernetLarge Library +#### 4. RP2040_RTC_Alarm_Ethernet on RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library -The following is the sample terminal output when running example [RP2040_RTC_Alarm_Ethernet](examples/Alarm/RP2040_RTC_Alarm_Ethernet) on RASPBERRY_PI_PICO with W5x00 using EthernetLarge Library +The following is the sample terminal output when running example [RP2040_RTC_Alarm_Ethernet](examples/Alarm/RP2040_RTC_Alarm_Ethernet) on RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library #### 4.1. Repeatitive Alarm ``` -Start RP2040_RTC_Alarm_Ethernet on RASPBERRY_PI_PICO with W5x00 using EthernetLarge Library -RP2040_RTC v1.0.8 -Timezone_Generic v1.9.0 -[EWS] =========== USE_ETHERNET_LARGE =========== +Start RP2040_RTC_Alarm_Ethernet on RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library +RP2040_RTC v1.1.0 +Timezone_Generic v1.10.0 +[EWS] =========== USE_ETHERNET_GENERIC =========== [EWS] Default SPI pinout: [EWS] MOSI: 19 [EWS] MISO: 16 [EWS] SCK: 18 [EWS] SS: 17 [EWS] ========================= -[EWS] Board : RASPBERRY_PI_PICO , setCsPin: 17 -_pinCS = 0 -W5100 init, using SS_PIN_DEFAULT = 10, new ss_pin = 10, W5100Class::ss_pin = 17 -W5100::init: W5500, SSIZE =8192 +[EWS] RPIPICO setCsPin: 17 ========================= Currently Used SPI pinout: MOSI:19 @@ -901,32 +891,32 @@ MISO:16 SCK:18 SS:17 ========================= -Using mac index = 2 -You're connected to the network, IP = 192.168.2.107 +Using mac index = 12 +You're connected to the network, IP = 192.168.2.99 Packet received -Seconds since Jan 1 1900 = 3851712307 -Unix time = 1642723507 -The UTC time is 0:05:07 +Seconds since Jan 1 1900 = 3859852325 +Unix time = 1650863525 +The UTC time is 5:12:05 ============================ -00:05:08 Fri 21 Jan 2022 UTC -19:05:08 Thu 20 Jan 2022 EST +05:12:06 Mon 25 Apr 2022 UTC +01:12:06 Mon 25 Apr 2022 EDT Set Repeatitive Alarm @ alarmSeconds = 5 ============================ Alarm @ -00:06:05 Fri 21 Jan 2022 UTC -19:06:05 Thu 20 Jan 2022 EST +05:13:05 Mon 25 Apr 2022 UTC +01:13:05 Mon 25 Apr 2022 EDT ============================ -00:06:08 Fri 21 Jan 2022 UTC -19:06:08 Thu 20 Jan 2022 EST +05:13:06 Mon 25 Apr 2022 UTC +01:13:06 Mon 25 Apr 2022 EDT ``` #### 4.2. One-shot Alarm ``` -Start RP2040_RTC_Alarm_Ethernet on RASPBERRY_PI_PICO with W5x00 using EthernetLarge Library -RP2040_RTC v1.0.8 -Timezone_Generic v1.9.0 -[EWS] =========== USE_ETHERNET_LARGE =========== +Start RP2040_RTC_Alarm_Ethernet on RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library +RP2040_RTC v1.1.0 +Timezone_Generic v1.10.0 +[EWS] =========== USE_ETHERNET_GENERIC =========== [EWS] Default SPI pinout: [EWS] MOSI: 19 [EWS] MISO: 16 @@ -947,75 +937,72 @@ SS:17 Using mac index = 17 You're connected to the network, IP = 192.168.2.101 Packet received -Seconds since Jan 1 1900 = 3851712462 -Unix time = 1642723662 -The UTC time is 0:07:42 +Seconds since Jan 1 1900 = 3859852325 +Unix time = 1650863525 +The UTC time is 5:12:05 ============================ -00:07:43 Fri 21 Jan 2022 UTC -19:07:43 Thu 20 Jan 2022 EST +05:12:06 Mon 25 Apr 2022 UTC +01:12:06 Mon 25 Apr 2022 EDT Set One-time Alarm @ alarmSeconds = 5 ============================ Alarm @ -00:08:05 Fri 21 Jan 2022 UTC -19:08:05 Thu 20 Jan 2022 EST +05:13:05 Mon 25 Apr 2022 UTC +01:13:05 Mon 25 Apr 2022 EDT ``` --- -#### 5. RP2040_RTC_Alarm_Ethernet on MBED on RASPBERRY_PI_PICO with W5x00 using EthernetLarge Library +#### 5. RP2040_RTC_Alarm_Ethernet on MBED RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library -The following is the sample terminal output when running example [RP2040_RTC_Alarm_Ethernet](examples/Alarm/RP2040_RTC_Alarm_Ethernet) on MBED RASPBERRY_PI_PICO with W5x00 using EthernetLarge Library +The following is the sample terminal output when running example [RP2040_RTC_Alarm_Ethernet](examples/Alarm/RP2040_RTC_Alarm_Ethernet) on MBED RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library #### 5.1. Repeatitive Alarm ``` -Start RP2040_RTC_Alarm_Ethernet on MBED RASPBERRY_PI_PICO with W5x00 using EthernetLarge Library -RP2040_RTC v1.0.8 -Timezone_Generic v1.9.0 -[EWS] =========== USE_ETHERNET_LARGE =========== +Start RP2040_RTC_Alarm_Ethernet on MBED RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library +RP2040_RTC v1.1.0 +Timezone_Generic v1.10.0 +[EWS] =========== USE_ETHERNET_GENERIC =========== [EWS] Default SPI pinout: -[EWS] MOSI: 3 -[EWS] MISO: 4 -[EWS] SCK: 2 -[EWS] SS: 5 +[EWS] MOSI: 19 +[EWS] MISO: 16 +[EWS] SCK: 18 +[EWS] SS: 17 [EWS] ========================= -[EWS] Board : MBED RASPBERRY_PI_PICO , setCsPin: 5 -_pinCS = 0 -W5100 init, using SS_PIN_DEFAULT = 5, new ss_pin = 10, W5100Class::ss_pin = 5 -W5100::init: W5500, SSIZE =8192 +[EWS] RPIPICO setCsPin: 17 ========================= Currently Used SPI pinout: -MOSI:3 -MISO:4 -SCK:2 -SS:5 +MOSI:19 +MISO:16 +SCK:18 +SS:17 ========================= -Using mac index = 3 -You're connected to the network, IP = 192.168.2.119 +Using mac index = 19 +You're connected to the network, IP = 192.168.2.104 Packet received -Seconds since Jan 1 1900 = 3851712307 -Unix time = 1642723507 -The UTC time is 0:05:07 +Seconds since Jan 1 1900 = 3859852627 +Unix time = 1650863827 +The UTC time is 5:17:07 ============================ -00:05:08 Fri 21 Jan 2022 UTC -19:05:08 Thu 20 Jan 2022 EST +05:17:08 Mon 25 Apr 2022 UTC +01:17:08 Mon 25 Apr 2022 EDT Set Repeatitive Alarm @ alarmSeconds = 5 ============================ Alarm @ -00:06:05 Fri 21 Jan 2022 UTC -19:06:05 Thu 20 Jan 2022 EST +05:18:05 Mon 25 Apr 2022 UTC +01:18:05 Mon 25 Apr 2022 EDT ============================ -00:06:08 Fri 21 Jan 2022 UTC -19:06:08 Thu 20 Jan 2022 EST +05:18:08 Mon 25 Apr 2022 UTC +01:18:08 Mon 25 Apr 2022 EDT ``` #### 5.2. One-shot Alarm ``` -Start RP2040_RTC_Alarm_Ethernet on RASPBERRY_PI_PICO with W5x00 using EthernetLarge Library -RP2040_RTC v1.0.8 -Timezone_Generic v1.9.0 -[EWS] =========== USE_ETHERNET_LARGE =========== +Start RP2040_RTC_Alarm_Ethernet on RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library +RP2040_RTC v1.1.0 +Timezone_Generic v1.10.0 +[EWS] =========== USE_ETHERNET_GENERIC =========== [EWS] Default SPI pinout: [EWS] MOSI: 19 [EWS] MISO: 16 @@ -1036,17 +1023,17 @@ SS:17 Using mac index = 17 You're connected to the network, IP = 192.168.2.101 Packet received -Seconds since Jan 1 1900 = 3851712462 -Unix time = 1642723662 -The UTC time is 0:07:42 +Seconds since Jan 1 1900 = 3859852627 +Unix time = 1650863827 +The UTC time is 5:17:07 ============================ -00:07:43 Fri 21 Jan 2022 UTC -19:07:43 Thu 20 Jan 2022 EST +05:17:08 Mon 25 Apr 2022 UTC +01:17:08 Mon 25 Apr 2022 EDT Set One-time Alarm @ alarmSeconds = 5 ============================ Alarm @ -00:08:05 Fri 21 Jan 2022 UTC -19:08:05 Thu 20 Jan 2022 EST +05:18:05 Mon 25 Apr 2022 UTC +01:18:05 Mon 25 Apr 2022 EDT ``` --- @@ -1059,25 +1046,25 @@ The following is the sample terminal output when running example [RP2040_RTC_Ala ``` Start RP2040_RTC_Alarm_WiFiNINA on MBED NANO_RP2040_CONNECT with WiFiNINA using WiFiNINA_Generic Library -RP2040_RTC v1.0.8 -Timezone_Generic v1.9.0 +RP2040_RTC v1.1.0 +Timezone_Generic v1.10.0 Connecting to WPA SSID: HueNet1 You're connected to the network, IP = 192.168.2.125 Packet received -Seconds since Jan 1 1900 = 3851712307 -Unix time = 1642723507 -The UTC time is 0:05:07 +Seconds since Jan 1 1900 = 3859852627 +Unix time = 1650863827 +The UTC time is 5:17:07 ============================ -00:05:08 Fri 21 Jan 2022 UTC -19:05:08 Thu 20 Jan 2022 EST +05:17:08 Mon 25 Apr 2022 UTC +01:17:08 Mon 25 Apr 2022 EDT Set Repeatitive Alarm @ alarmSeconds = 5 ============================ Alarm @ -00:06:05 Fri 21 Jan 2022 UTC -19:06:05 Thu 20 Jan 2022 EST +05:18:05 Mon 25 Apr 2022 UTC +01:18:05 Mon 25 Apr 2022 EDT ============================ -00:06:08 Fri 21 Jan 2022 UTC -19:06:08 Thu 20 Jan 2022 EST +05:18:08 Mon 25 Apr 2022 UTC +01:18:08 Mon 25 Apr 2022 EDT ``` #### 6.2. One-shot Alarm @@ -1085,22 +1072,22 @@ Alarm @ ``` Start RP2040_RTC_Alarm_WiFiNINA on MBED NANO_RP2040_CONNECT with WiFiNINA using WiFiNINA_Generic Library -RP2040_RTC v1.0.8 -Timezone_Generic v1.9.0 +RP2040_RTC v1.1.0 +Timezone_Generic v1.10.0 Connecting to WPA SSID: HueNet1 You're connected to the network, IP = 192.168.2.125 Packet received -Seconds since Jan 1 1900 = 3851712462 -Unix time = 1642723662 -The UTC time is 0:07:42 +Seconds since Jan 1 1900 = 3859852627 +Unix time = 1650863827 +The UTC time is 5:17:07 ============================ -00:07:43 Fri 21 Jan 2022 UTC -19:07:43 Thu 20 Jan 2022 EST +05:17:08 Mon 25 Apr 2022 UTC +01:17:08 Mon 25 Apr 2022 EDT Set One-time Alarm @ alarmSeconds = 5 ============================ Alarm @ -00:08:05 Fri 21 Jan 2022 UTC -19:08:05 Thu 20 Jan 2022 EST +05:18:05 Mon 25 Apr 2022 UTC +01:18:05 Mon 25 Apr 2022 EDT ``` --- @@ -1136,6 +1123,9 @@ Submit issues to: [RP2040_RTC issues](https://github.com/khoih-prog/RP2040_RTC/i 2. Add Version String 3. Add Table of Contents 4. Add simple examples with manual time input +5. Use new [Ethernet_Generic library](https://github.com/khoih-prog/Ethernet_Generic) as default for W5x00. +6. Add support to `SPI1` for `RP2040` using [`Earle Philhower's arduino-pico` core](https://github.com/earlephilhower/arduino-pico) +7. Add support to WIZNet W5100S, such as [**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) --- --- diff --git a/changelog.md b/changelog.md index c84623b..412a933 100644 --- a/changelog.md +++ b/changelog.md @@ -12,6 +12,7 @@ ## Table of Contents * [Changelog](#changelog) + * [Releases v1.1.0](#releases-v110) * [Releases v1.0.8](#releases-v108) * [Releases v1.0.7](#releases-v107) * [Releases v1.0.6](#releases-v106) @@ -27,6 +28,12 @@ ## Changelog +### Releases v1.1.0 + +1. Use new [Ethernet_Generic library](https://github.com/khoih-prog/Ethernet_Generic) as default for W5x00. +2. Add support to `SPI1` for `RP2040` using [`Earle Philhower's arduino-pico` core](https://github.com/earlephilhower/arduino-pico) +3. Add support to WIZNet W5100S, such as [**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) + ### Releases v1.0.8 1. Update dependency on [Timezone_Generic Library](https://github.com/khoih-prog/Timezone_Generic) diff --git a/examples/Alarm/RP2040_RTC_Alarm/RP2040_RTC_Alarm.ino b/examples/Alarm/RP2040_RTC_Alarm/RP2040_RTC_Alarm.ino index b2f00be..e4dff41 100644 --- a/examples/Alarm/RP2040_RTC_Alarm/RP2040_RTC_Alarm.ino +++ b/examples/Alarm/RP2040_RTC_Alarm/RP2040_RTC_Alarm.ino @@ -109,7 +109,7 @@ void printDateTime(time_t t, const char *tz) void setup() { Serial.begin(115200); - while (!Serial); + while (!Serial && millis() < 5000); delay(200); diff --git a/examples/Alarm/RP2040_RTC_Alarm_Ethernet/RP2040_RTC_Alarm_Ethernet.ino b/examples/Alarm/RP2040_RTC_Alarm_Ethernet/RP2040_RTC_Alarm_Ethernet.ino index 8064c41..8cdc194 100644 --- a/examples/Alarm/RP2040_RTC_Alarm_Ethernet/RP2040_RTC_Alarm_Ethernet.ino +++ b/examples/Alarm/RP2040_RTC_Alarm_Ethernet/RP2040_RTC_Alarm_Ethernet.ino @@ -238,32 +238,10 @@ void printDateTime(time_t t, const char *tz) ////////////////////////////////////////// -void setup() +void initEthernet() { - Serial.begin(115200); - while (!Serial); - - delay(200); - - Serial.print(F("\nStart RP2040_RTC_Alarm_Ethernet on ")); Serial.print(BOARD_NAME); - Serial.print(F(" with ")); Serial.println(SHIELD_TYPE); - Serial.println(RP2040_RTC_VERSION); - Serial.println(TIMEZONE_GENERIC_VERSION); - -#if USE_ETHERNET_WRAPPER - - EthernetInit(); - -#else - -#if USE_ETHERNET - ET_LOGWARN(F("=========== USE_ETHERNET ===========")); -#elif USE_ETHERNET2 - ET_LOGWARN(F("=========== USE_ETHERNET2 ===========")); -#elif USE_ETHERNET3 - ET_LOGWARN(F("=========== USE_ETHERNET3 ===========")); -#elif USE_ETHERNET_LARGE - ET_LOGWARN(F("=========== USE_ETHERNET_LARGE ===========")); +#if USE_ETHERNET_GENERIC + ET_LOGWARN(F("=========== USE_ETHERNET_GENERIC ===========")); #elif USE_ETHERNET_ESP8266 ET_LOGWARN(F("=========== USE_ETHERNET_ESP8266 ===========")); #else @@ -277,122 +255,37 @@ void setup() ET_LOGWARN1(F("SS:"), SS); ET_LOGWARN(F("=========================")); -#if defined(ESP8266) - // For ESP8266, change for other boards if necessary -#ifndef USE_THIS_SS_PIN -#define USE_THIS_SS_PIN D2 // For ESP8266 -#endif - - ET_LOGWARN1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN); - -#if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) - // For ESP8266 - // Pin D0(GPIO16) D1(GPIO5) D2(GPIO4) D3(GPIO0) D4(GPIO2) D8 - // Ethernet 0 X X X X 0 - // Ethernet2 X X X X X 0 - // Ethernet3 X X X X X 0 - // EthernetLarge X X X X X 0 - // Ethernet_ESP8266 0 0 0 0 0 0 - // D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs - // Must use library patch for Ethernet, EthernetLarge libraries - Ethernet.init (USE_THIS_SS_PIN); - -#elif USE_ETHERNET3 - // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer -#ifndef ETHERNET3_MAX_SOCK_NUM -#define ETHERNET3_MAX_SOCK_NUM 4 -#endif - - Ethernet.setCsPin (USE_THIS_SS_PIN); - Ethernet.init (ETHERNET3_MAX_SOCK_NUM); - -#elif USE_CUSTOM_ETHERNET - - // You have to add initialization for your Custom Ethernet here - // This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough - Ethernet.init(USE_THIS_SS_PIN); - -#endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE ) - -#elif defined(ESP32) - - // You can use Ethernet.init(pin) to configure the CS pin - //Ethernet.init(10); // Most Arduino shields - //Ethernet.init(5); // MKR ETH shield - //Ethernet.init(0); // Teensy 2.0 - //Ethernet.init(20); // Teensy++ 2.0 - //Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet - //Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet - -#ifndef USE_THIS_SS_PIN -#define USE_THIS_SS_PIN 22 // For ESP32 -#endif - - ET_LOGWARN1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN); - - // For other boards, to change if necessary -#if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) - // Must use library patch for Ethernet, EthernetLarge libraries - // ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge - // ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3 - - //Ethernet.setCsPin (USE_THIS_SS_PIN); - Ethernet.init (USE_THIS_SS_PIN); - -#elif USE_ETHERNET3 - // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer -#ifndef ETHERNET3_MAX_SOCK_NUM -#define ETHERNET3_MAX_SOCK_NUM 4 -#endif - - Ethernet.setCsPin (USE_THIS_SS_PIN); - Ethernet.init (ETHERNET3_MAX_SOCK_NUM); +#if ETHERNET_USE_RPIPICO -#elif USE_CUSTOM_ETHERNET - - // You have to add initialization for your Custom Ethernet here - // This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough - Ethernet.init(USE_THIS_SS_PIN); - -#endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE ) - -#else //defined(ESP8266) - // unknown board, do nothing, use default SS = 10 -#ifndef USE_THIS_SS_PIN -#define USE_THIS_SS_PIN 10 // For other boards -#endif + pinMode(USE_THIS_SS_PIN, OUTPUT); + digitalWrite(USE_THIS_SS_PIN, HIGH); + + // ETHERNET_USE_RPIPICO, use default SS = 5 or 17 + #ifndef USE_THIS_SS_PIN + #if defined(ARDUINO_ARCH_MBED) + #define USE_THIS_SS_PIN 5 // For Arduino Mbed core + #else + #define USE_THIS_SS_PIN 17 // For E.Philhower core + #endif + #endif - ET_LOGWARN3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN); + ET_LOGWARN1(F("RPIPICO setCsPin:"), USE_THIS_SS_PIN); // For other boards, to change if necessary -#if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) - // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries - - Ethernet.init (USE_THIS_SS_PIN); + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + // For RPI Pico using E. Philhower RP2040 core + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 + // Default pin 5/17 to SS/CS + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) -#elif USE_ETHERNET3 - // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer -#ifndef ETHERNET3_MAX_SOCK_NUM -#define ETHERNET3_MAX_SOCK_NUM 4 #endif - Ethernet.setCsPin (USE_THIS_SS_PIN); - Ethernet.init (ETHERNET3_MAX_SOCK_NUM); - -#elif USE_CUSTOM_ETHERNET - - // You have to add initialization for your Custom Ethernet here - // This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough - Ethernet.init(USE_THIS_SS_PIN); - -#endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE ) - -#endif //defined(ESP8266) - - -#endif //USE_ETHERNET_WRAPPER - - // start the ethernet connection and the server: // Use DHCP dynamic IP and random mac uint16_t index = millis() % NUMBER_OF_MAC; @@ -407,16 +300,29 @@ void setup() Serial.print(F("MISO:")); Serial.println(MISO); Serial.print(F("SCK:")); Serial.println(SCK); Serial.print(F("SS:")); Serial.println(SS); -#if USE_ETHERNET3 - Serial.print(F("SPI_CS:")); Serial.println(SPI_CS); -#endif Serial.println(F("=========================")); - Serial.print(F("Using mac index = ")); Serial.println(index); + Serial.print(F("Using mac index = ")); + Serial.println(index); // you're connected now, so print out the data Serial.print(F("You're connected to the network, IP = ")); Serial.println(Ethernet.localIP()); +} + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); + + delay(200); + + Serial.print(F("\nStart RP2040_RTC_Alarm_Ethernet on ")); Serial.print(BOARD_NAME); + Serial.print(F(" with ")); Serial.println(SHIELD_TYPE); + Serial.println(RP2040_RTC_VERSION); + Serial.println(TIMEZONE_GENERIC_VERSION); + + initEthernet(); myTZ = new Timezone(myDST, mySTD); diff --git a/examples/Alarm/RP2040_RTC_Alarm_Ethernet/defines.h b/examples/Alarm/RP2040_RTC_Alarm_Ethernet/defines.h index 2a4446d..2df7f83 100644 --- a/examples/Alarm/RP2040_RTC_Alarm_Ethernet/defines.h +++ b/examples/Alarm/RP2040_RTC_Alarm_Ethernet/defines.h @@ -21,19 +21,17 @@ #undef ETHERNET_USE_RP2040 #endif #define ETHERNET_USE_RP2040 true + #define ETHERNET_USE_RPIPICO true #endif -#if ETHERNET_USE_RP2040 +#if ETHERNET_USE_RP2040 || ETHERNET_USE_RPIPICO // Default pin 5 (in Mbed) or 17 to SS/CS #if defined(ARDUINO_ARCH_MBED) // For RPI Pico using Arduino Mbed RP2040 core // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 - // SDA: 6, SCL: 7 - // For Nano_RP2040_Connect using Arduino Mbed RP2040 core - // SDA: 14 = A4, SCL: 19 = A5 - #define USE_THIS_SS_PIN 5 + #define USE_THIS_SS_PIN 17 //5 #if defined(BOARD_NAME) #undef BOARD_NAME @@ -51,8 +49,7 @@ #else // For RPI Pico using E. Philhower RP2040 core - // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 - // SDA: 4, SCL: 5 + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 #define USE_THIS_SS_PIN 17 #endif @@ -91,35 +88,28 @@ // Check @ defined(SEEED_XIAO_M0) //#define USE_THIS_SS_PIN 22 //21 //5 //4 //2 //15 - // Only one of the following to be true - #define USE_ETHERNET false - #define USE_ETHERNET2 false - #define USE_ETHERNET3 false - #define USE_ETHERNET_LARGE true - #define USE_ETHERNET_ESP8266 false + // Only one if the following to be true + #define USE_ETHERNET_GENERIC true + #define USE_ETHERNET_ESP8266 false #define USE_ETHERNET_ENC false #define USE_CUSTOM_ETHERNET false - - #if ( USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE || USE_ETHERNET_ESP8266 || USE_ETHERNET_ENC ) + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ESP8266 || USE_ETHERNET_ENC ) #ifdef USE_CUSTOM_ETHERNET #undef USE_CUSTOM_ETHERNET #endif #define USE_CUSTOM_ETHERNET false //true #endif - #if USE_ETHERNET3 - #include "Ethernet3.h" - #warning Using Ethernet3 lib - #define SHIELD_TYPE "W5x00 using Ethernet3 Library" - #elif USE_ETHERNET2 - #include "Ethernet2.h" - #warning Using Ethernet2 lib - #define SHIELD_TYPE "W5x00 using Ethernet2 Library" - #elif USE_ETHERNET_LARGE - #include "EthernetLarge.h" - #warning Using EthernetLarge lib - #define SHIELD_TYPE "W5x00 using EthernetLarge Library" + #if USE_ETHERNET_GENERIC + #define ETHERNET_LARGE_BUFFERS + + #define _ETG_LOGLEVEL_ 1 + + #include "Ethernet_Generic.h" + + #warning Using Ethernet_Generic lib + #define SHIELD_TYPE "W5x00 using Ethernet_Generic Library" #elif USE_ETHERNET_ESP8266 #include "Ethernet_ESP8266.h" #warning Using Ethernet_ESP8266 lib @@ -134,10 +124,13 @@ #warning Using Custom Ethernet library. You must include a library and initialize. #define SHIELD_TYPE "Custom Ethernet using Ethernet_XYZ Library" #else - #define USE_ETHERNET true - #include "Ethernet.h" - #warning Using Ethernet lib - #define SHIELD_TYPE "W5x00 using Ethernet Library" + #ifdef USE_ETHERNET_GENERIC + #undef USE_ETHERNET_GENERIC + #endif + #define USE_ETHERNET_GENERIC true + #include "Ethernet_Generic.h" + #warning Using default Ethernet_Generic lib + #define SHIELD_TYPE "W5x00 using default Ethernet_Generic Library" #endif // Ethernet_Shield_W5200, EtherCard, EtherSia not supported diff --git a/examples/Alarm/RP2040_RTC_Alarm_WiFiNINA/RP2040_RTC_Alarm_WiFiNINA.ino b/examples/Alarm/RP2040_RTC_Alarm_WiFiNINA/RP2040_RTC_Alarm_WiFiNINA.ino index 7a8e56e..35b7631 100644 --- a/examples/Alarm/RP2040_RTC_Alarm_WiFiNINA/RP2040_RTC_Alarm_WiFiNINA.ino +++ b/examples/Alarm/RP2040_RTC_Alarm_WiFiNINA/RP2040_RTC_Alarm_WiFiNINA.ino @@ -241,7 +241,7 @@ void printDateTime(time_t t, const char *tz) void setup() { Serial.begin(115200); - while (!Serial); + while (!Serial && millis() < 5000); delay(200); diff --git a/examples/Time/RP2040_RTC_Time/RP2040_RTC_Time.ino b/examples/Time/RP2040_RTC_Time/RP2040_RTC_Time.ino index 381639e..f7a4176 100644 --- a/examples/Time/RP2040_RTC_Time/RP2040_RTC_Time.ino +++ b/examples/Time/RP2040_RTC_Time/RP2040_RTC_Time.ino @@ -60,7 +60,7 @@ void printDateTime(time_t t, const char *tz) void setup() { Serial.begin(115200); - while (!Serial); + while (!Serial && millis() < 5000); delay(200); diff --git a/examples/Time/RP2040_RTC_Time_Ethernet/RP2040_RTC_Time_Ethernet.ino b/examples/Time/RP2040_RTC_Time_Ethernet/RP2040_RTC_Time_Ethernet.ino index 513ed98..ab7a5b6 100644 --- a/examples/Time/RP2040_RTC_Time_Ethernet/RP2040_RTC_Time_Ethernet.ino +++ b/examples/Time/RP2040_RTC_Time_Ethernet/RP2040_RTC_Time_Ethernet.ino @@ -187,32 +187,12 @@ void printDateTime(time_t t, const char *tz) Serial.println(buf); } -void setup() -{ - Serial.begin(115200); - while (!Serial); - - delay(200); - - Serial.print(F("\nStart RP2040_RTC_Time_Ethernet on ")); Serial.print(BOARD_NAME); - Serial.print(F(" with ")); Serial.println(SHIELD_TYPE); - Serial.println(RP2040_RTC_VERSION); - Serial.println(TIMEZONE_GENERIC_VERSION); - -#if USE_ETHERNET_WRAPPER - - EthernetInit(); - -#else +////////////////////////////////////////// -#if USE_ETHERNET - ET_LOGWARN(F("=========== USE_ETHERNET ===========")); -#elif USE_ETHERNET2 - ET_LOGWARN(F("=========== USE_ETHERNET2 ===========")); -#elif USE_ETHERNET3 - ET_LOGWARN(F("=========== USE_ETHERNET3 ===========")); -#elif USE_ETHERNET_LARGE - ET_LOGWARN(F("=========== USE_ETHERNET_LARGE ===========")); +void initEthernet() +{ +#if USE_ETHERNET_GENERIC + ET_LOGWARN(F("=========== USE_ETHERNET_GENERIC ===========")); #elif USE_ETHERNET_ESP8266 ET_LOGWARN(F("=========== USE_ETHERNET_ESP8266 ===========")); #else @@ -226,122 +206,37 @@ void setup() ET_LOGWARN1(F("SS:"), SS); ET_LOGWARN(F("=========================")); -#if defined(ESP8266) - // For ESP8266, change for other boards if necessary -#ifndef USE_THIS_SS_PIN -#define USE_THIS_SS_PIN D2 // For ESP8266 -#endif - - ET_LOGWARN1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN); - -#if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) - // For ESP8266 - // Pin D0(GPIO16) D1(GPIO5) D2(GPIO4) D3(GPIO0) D4(GPIO2) D8 - // Ethernet 0 X X X X 0 - // Ethernet2 X X X X X 0 - // Ethernet3 X X X X X 0 - // EthernetLarge X X X X X 0 - // Ethernet_ESP8266 0 0 0 0 0 0 - // D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs - // Must use library patch for Ethernet, EthernetLarge libraries - Ethernet.init (USE_THIS_SS_PIN); - -#elif USE_ETHERNET3 - // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer -#ifndef ETHERNET3_MAX_SOCK_NUM -#define ETHERNET3_MAX_SOCK_NUM 4 -#endif - - Ethernet.setCsPin (USE_THIS_SS_PIN); - Ethernet.init (ETHERNET3_MAX_SOCK_NUM); +#if ETHERNET_USE_RPIPICO -#elif USE_CUSTOM_ETHERNET + pinMode(USE_THIS_SS_PIN, OUTPUT); + digitalWrite(USE_THIS_SS_PIN, HIGH); + + // ETHERNET_USE_RPIPICO, use default SS = 5 or 17 + #ifndef USE_THIS_SS_PIN + #if defined(ARDUINO_ARCH_MBED) + #define USE_THIS_SS_PIN 5 // For Arduino Mbed core + #else + #define USE_THIS_SS_PIN 17 // For E.Philhower core + #endif + #endif - // You have to add initialization for your Custom Ethernet here - // This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough - Ethernet.init(USE_THIS_SS_PIN); - -#endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE ) - -#elif defined(ESP32) - - // You can use Ethernet.init(pin) to configure the CS pin - //Ethernet.init(10); // Most Arduino shields - //Ethernet.init(5); // MKR ETH shield - //Ethernet.init(0); // Teensy 2.0 - //Ethernet.init(20); // Teensy++ 2.0 - //Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet - //Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet - -#ifndef USE_THIS_SS_PIN -#define USE_THIS_SS_PIN 22 // For ESP32 -#endif - - ET_LOGWARN1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN); + ET_LOGWARN1(F("RPIPICO setCsPin:"), USE_THIS_SS_PIN); // For other boards, to change if necessary -#if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) - // Must use library patch for Ethernet, EthernetLarge libraries - // ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge - // ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3 - - //Ethernet.setCsPin (USE_THIS_SS_PIN); - Ethernet.init (USE_THIS_SS_PIN); - -#elif USE_ETHERNET3 - // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer -#ifndef ETHERNET3_MAX_SOCK_NUM -#define ETHERNET3_MAX_SOCK_NUM 4 -#endif - - Ethernet.setCsPin (USE_THIS_SS_PIN); - Ethernet.init (ETHERNET3_MAX_SOCK_NUM); - -#elif USE_CUSTOM_ETHERNET - - // You have to add initialization for your Custom Ethernet here - // This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough - Ethernet.init(USE_THIS_SS_PIN); - -#endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE ) + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) + // Must use library patch for Ethernet, EthernetLarge libraries + // For RPI Pico using Arduino Mbed RP2040 core + // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 + // For RPI Pico using E. Philhower RP2040 core + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 + // Default pin 5/17 to SS/CS + + //Ethernet.setCsPin (USE_THIS_SS_PIN); + Ethernet.init (USE_THIS_SS_PIN); + #endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) -#else //defined(ESP8266) - // unknown board, do nothing, use default SS = 10 -#ifndef USE_THIS_SS_PIN -#define USE_THIS_SS_PIN 10 // For other boards #endif - ET_LOGWARN3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN); - - // For other boards, to change if necessary -#if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC ) - // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries - - Ethernet.init (USE_THIS_SS_PIN); - -#elif USE_ETHERNET3 - // Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer -#ifndef ETHERNET3_MAX_SOCK_NUM -#define ETHERNET3_MAX_SOCK_NUM 4 -#endif - - Ethernet.setCsPin (USE_THIS_SS_PIN); - Ethernet.init (ETHERNET3_MAX_SOCK_NUM); - -#elif USE_CUSTOM_ETHERNET - - // You have to add initialization for your Custom Ethernet here - // This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough - Ethernet.init(USE_THIS_SS_PIN); - -#endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE ) - -#endif //defined(ESP8266) - - -#endif //USE_ETHERNET_WRAPPER - - // start the ethernet connection and the server: // Use DHCP dynamic IP and random mac uint16_t index = millis() % NUMBER_OF_MAC; @@ -356,9 +251,6 @@ void setup() Serial.print(F("MISO:")); Serial.println(MISO); Serial.print(F("SCK:")); Serial.println(SCK); Serial.print(F("SS:")); Serial.println(SS); -#if USE_ETHERNET3 - Serial.print(F("SPI_CS:")); Serial.println(SPI_CS); -#endif Serial.println(F("=========================")); Serial.print(F("Using mac index = ")); @@ -367,6 +259,23 @@ void setup() // you're connected now, so print out the data Serial.print(F("You're connected to the network, IP = ")); Serial.println(Ethernet.localIP()); +} + +////////////////////////////////////////// + +void setup() +{ + Serial.begin(115200); + while (!Serial && millis() < 5000); + + delay(200); + + Serial.print(F("\nStart RP2040_RTC_Time_Ethernet on ")); Serial.print(BOARD_NAME); + Serial.print(F(" with ")); Serial.println(SHIELD_TYPE); + Serial.println(RP2040_RTC_VERSION); + Serial.println(TIMEZONE_GENERIC_VERSION); + + initEthernet(); myTZ = new Timezone(myDST, mySTD); diff --git a/examples/Time/RP2040_RTC_Time_Ethernet/defines.h b/examples/Time/RP2040_RTC_Time_Ethernet/defines.h index 2a4446d..2df7f83 100644 --- a/examples/Time/RP2040_RTC_Time_Ethernet/defines.h +++ b/examples/Time/RP2040_RTC_Time_Ethernet/defines.h @@ -21,19 +21,17 @@ #undef ETHERNET_USE_RP2040 #endif #define ETHERNET_USE_RP2040 true + #define ETHERNET_USE_RPIPICO true #endif -#if ETHERNET_USE_RP2040 +#if ETHERNET_USE_RP2040 || ETHERNET_USE_RPIPICO // Default pin 5 (in Mbed) or 17 to SS/CS #if defined(ARDUINO_ARCH_MBED) // For RPI Pico using Arduino Mbed RP2040 core // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 - // SDA: 6, SCL: 7 - // For Nano_RP2040_Connect using Arduino Mbed RP2040 core - // SDA: 14 = A4, SCL: 19 = A5 - #define USE_THIS_SS_PIN 5 + #define USE_THIS_SS_PIN 17 //5 #if defined(BOARD_NAME) #undef BOARD_NAME @@ -51,8 +49,7 @@ #else // For RPI Pico using E. Philhower RP2040 core - // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 - // SDA: 4, SCL: 5 + // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 #define USE_THIS_SS_PIN 17 #endif @@ -91,35 +88,28 @@ // Check @ defined(SEEED_XIAO_M0) //#define USE_THIS_SS_PIN 22 //21 //5 //4 //2 //15 - // Only one of the following to be true - #define USE_ETHERNET false - #define USE_ETHERNET2 false - #define USE_ETHERNET3 false - #define USE_ETHERNET_LARGE true - #define USE_ETHERNET_ESP8266 false + // Only one if the following to be true + #define USE_ETHERNET_GENERIC true + #define USE_ETHERNET_ESP8266 false #define USE_ETHERNET_ENC false #define USE_CUSTOM_ETHERNET false - - #if ( USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE || USE_ETHERNET_ESP8266 || USE_ETHERNET_ENC ) + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ESP8266 || USE_ETHERNET_ENC ) #ifdef USE_CUSTOM_ETHERNET #undef USE_CUSTOM_ETHERNET #endif #define USE_CUSTOM_ETHERNET false //true #endif - #if USE_ETHERNET3 - #include "Ethernet3.h" - #warning Using Ethernet3 lib - #define SHIELD_TYPE "W5x00 using Ethernet3 Library" - #elif USE_ETHERNET2 - #include "Ethernet2.h" - #warning Using Ethernet2 lib - #define SHIELD_TYPE "W5x00 using Ethernet2 Library" - #elif USE_ETHERNET_LARGE - #include "EthernetLarge.h" - #warning Using EthernetLarge lib - #define SHIELD_TYPE "W5x00 using EthernetLarge Library" + #if USE_ETHERNET_GENERIC + #define ETHERNET_LARGE_BUFFERS + + #define _ETG_LOGLEVEL_ 1 + + #include "Ethernet_Generic.h" + + #warning Using Ethernet_Generic lib + #define SHIELD_TYPE "W5x00 using Ethernet_Generic Library" #elif USE_ETHERNET_ESP8266 #include "Ethernet_ESP8266.h" #warning Using Ethernet_ESP8266 lib @@ -134,10 +124,13 @@ #warning Using Custom Ethernet library. You must include a library and initialize. #define SHIELD_TYPE "Custom Ethernet using Ethernet_XYZ Library" #else - #define USE_ETHERNET true - #include "Ethernet.h" - #warning Using Ethernet lib - #define SHIELD_TYPE "W5x00 using Ethernet Library" + #ifdef USE_ETHERNET_GENERIC + #undef USE_ETHERNET_GENERIC + #endif + #define USE_ETHERNET_GENERIC true + #include "Ethernet_Generic.h" + #warning Using default Ethernet_Generic lib + #define SHIELD_TYPE "W5x00 using default Ethernet_Generic Library" #endif // Ethernet_Shield_W5200, EtherCard, EtherSia not supported diff --git a/examples/Time/RP2040_RTC_Time_WiFiNINA/RP2040_RTC_Time_WiFiNINA.ino b/examples/Time/RP2040_RTC_Time_WiFiNINA/RP2040_RTC_Time_WiFiNINA.ino index 90f7245..a02f6d0 100644 --- a/examples/Time/RP2040_RTC_Time_WiFiNINA/RP2040_RTC_Time_WiFiNINA.ino +++ b/examples/Time/RP2040_RTC_Time_WiFiNINA/RP2040_RTC_Time_WiFiNINA.ino @@ -192,7 +192,7 @@ void printDateTime(time_t t, const char *tz) void setup() { Serial.begin(115200); - while (!Serial); + while (!Serial && millis() < 5000); delay(200); diff --git a/library.json b/library.json index 9afdbae..c583ad0 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "RP2040_RTC", - "version": "1.0.8", + "version": "1.1.0", "keywords": "timing, device, rtc, control, timer, interrupt, alarm, utc, ntp, isr, isr-based, hardware-timer, mission-critical, accuracy, precise, non-blocking, mbed, rpi-pico, rp2040, nano-rp2040-connect", "description": "This library enables you to use RTC from RP2040-based boards such as Nano_RP2040_Connect, RASPBERRY_PI_PICO. This RP204-based RTC, using Interrupt, has no battery backup. Time will be lost when powered down. To need NTP-client to update RTC every start-up.", "authors": @@ -22,6 +22,26 @@ "tests" ] }, + "dependencies": + [ + { + "owner": "khoih-prog", + "name": "Timezone_Generic", + "version": ">=1.10.0", + "platforms": ["*"] + }, + { + "owner": "khoih-prog", + "name": "WiFiNINA_Generic", + "version": ">=1.8.14-3", + "platforms": ["*"] + }, + { + "owner": "khoih-prog", + "name": "Ethernet_Generic", + "version": "^2.1.0" + } + ], "license": "MIT", "frameworks": "*", "platforms": ["raspberrypi"], diff --git a/library.properties b/library.properties index a9c6de2..c64c074 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=RP2040_RTC -version=1.0.8 +version=1.1.0 author=Khoi Hoang maintainer=Khoi Hoang sentence=This library enables you to use RTC from RP2040-based boards such as Nano_RP2040_Connect, RASPBERRY_PI_PICO @@ -9,4 +9,5 @@ url=https://github.com/khoih-prog/RP2040_RTC architectures=rp2040, mbed_rp2040, mbed_nano repository=https://github.com/khoih-prog/RP2040_RTC license=MIT +depends=WiFiNINA_Generic, Ethernet_Generic, Timezone_Generic includes=RP2040_RTC.h diff --git a/platformio/platformio.ini b/platformio/platformio.ini index 4c919d5..6fc6c00 100644 --- a/platformio/platformio.ini +++ b/platformio/platformio.ini @@ -39,8 +39,19 @@ upload_speed = 921600 ; Checks for the compatibility with frameworks and dev/platforms lib_compat_mode = strict +lib_ldf_mode = chain+ +;lib_ldf_mode = deep+ lib_deps = +; PlatformIO 4.x + WiFiNINA_Generic@>=1.8.14-3 + Timezone_Generic@>=1.10.0 + Ethernet_Generic@>=2.1.0 + +; PlatformIO 5.x +; khoih-prog/WiFiNINA_Generic@>=1.8.14-1 +; khoih-prog/Timezone_Generic@>=1.10.0 +; Ethernet_Generic@>=2.1.0 build_flags =