Giter VIP home page Giter VIP logo

Comments (7)

mathieucarbou avatar mathieucarbou commented on September 26, 2024

I did further research and found some examples using the new framework with the W5500 adapter which is used in the Lilygo: https://github.com/espressif/arduino-esp32/tree/master/libraries/Ethernet/examples

I tested both the version with the Arduino API (SPI.h) and the ISP-IDF and they both work fine.

from lilygo-t-eth-series.

mathieucarbou avatar mathieucarbou commented on September 26, 2024

I was able to find a solution, that is implemented in my MycilaESPConnect library (Network manager). I need to support several ETH cards including WT32-ETH1, Lilygo, etc.

Here is what I have in my header:

#if defined(ESPCONNECT_ETH_SUPPORT)
  #if defined(ETH_PHY_SPI_SCK) && defined(ETH_PHY_SPI_MISO) && defined(ETH_PHY_SPI_MOSI) &&     defined(ETH_PHY_CS) && defined(ETH_PHY_IRQ) && defined(ETH_PHY_RST)
    #define ESPCONNECT_ETH_SPI_SUPPORT 1
    #if ESP_IDF_VERSION_MAJOR >= 5
      #include <ETH.h>
      #include <SPI.h>
    #else
    #include <ETHClass.h>
    #endif
  #else
    #include <ETH.h>
  #endif
#endif
#ifdef ESPCONNECT_ETH_SUPPORT
void ESPConnectClass::_startEthernet() {
  _setState(ESPConnectState::NETWORK_CONNECTING);

#if defined(ETH_PHY_POWER) && ETH_PHY_POWER > -1
  pinMode(ETH_PHY_POWER, OUTPUT);
#ifdef ESPCONNECT_ETH_RESET_ON_START
  ESP_LOGD(TAG, "Resetting ETH_PHY_POWER Pin %d", ETH_PHY_POWER);
  digitalWrite(ETH_PHY_POWER, LOW);
  delay(350);
#endif
  ESP_LOGD(TAG, "Activating ETH_PHY_POWER Pin %d", ETH_PHY_POWER);
  digitalWrite(ETH_PHY_POWER, HIGH);
#endif

  ESP_LOGI(TAG, "Starting Ethernet...");
#if defined(ESPCONNECT_ETH_SPI_SUPPORT)
#if ESP_IDF_VERSION_MAJOR >= 5
  // https://github.com/espressif/arduino-esp32/tree/master/libraries/Ethernet/examples
  SPI.begin(ETH_PHY_SPI_SCK, ETH_PHY_SPI_MISO, ETH_PHY_SPI_MOSI);
  if (!ETH.begin(ETH_PHY_TYPE, ETH_PHY_ADDR, ETH_PHY_CS, ETH_PHY_IRQ, ETH_PHY_RST, SPI)) {
    ESP_LOGE(TAG, "ETH failed to start!");
  }
#else
  if (!ETH.beginSPI(ETH_PHY_SPI_MISO, ETH_PHY_SPI_MOSI, ETH_PHY_SPI_SCK, ETH_PHY_CS, ETH_PHY_RST, ETH_PHY_IRQ)) {
    ESP_LOGE(TAG, "ETH failed to start!");
  }
#endif
#else
  if (!ETH.begin()) {
    ESP_LOGE(TAG, "ETH failed to start!");
  }
#endif

  _lastTime = esp_timer_get_time();

  ESP_LOGD(TAG, "ETH started.");
}
#endif

Flags for wt32-eth01:

  -D ESPCONNECT_ETH_SUPPORT
  -D ETH_PHY_ADDR=1
  -D ETH_PHY_POWER=16

Flags for T-ETH-Lite ESP32 S3:

  -D ESPCONNECT_ETH_SUPPORT
  -D ETH_PHY_ADDR=1
  -D ETH_PHY_CS=9
  -D ETH_PHY_IRQ=13
  -D ETH_PHY_RST=14
  -D ETH_PHY_SPI_MISO=11
  -D ETH_PHY_SPI_MOSI=12
  -D ETH_PHY_SPI_SCK=10
  ; can only be activated with ESP-IDF >= 5
  ; -D ETH_PHY_TYPE=ETH_PHY_W5500

from lilygo-t-eth-series.

mathieucarbou avatar mathieucarbou commented on September 26, 2024

Oh! And I had to add this hack into ETHClass in order to avoid it to be part of the compilation:

#include "esp_system.h"
#if defined(ETH_PHY_SPI_SCK) && defined(ETH_PHY_SPI_MISO) && defined(ETH_PHY_SPI_MOSI) && defined(ETH_PHY_CS) && defined(ETH_PHY_IRQ) && defined(ETH_PHY_RST) && ESP_IDF_VERSION_MAJOR < 5

from lilygo-t-eth-series.

lewisxhe avatar lewisxhe commented on September 26, 2024

Currently, the latest platformio is still 4.4.x. I will not update it for the time being. I will do a comprehensive update after platformio is synchronized to 5.x.

from lilygo-t-eth-series.

mathieucarbou avatar mathieucarbou commented on September 26, 2024

Yes makes sense.
I was in the process of preparing my librairies to be compatible.

And like described in this issue it works.

Someone in a normal project won't have to go over all the cases like I had to.

from lilygo-t-eth-series.

github-actions avatar github-actions commented on September 26, 2024

This issue is stale because it has been open for 30 days with no activity.

from lilygo-t-eth-series.

mathieucarbou avatar mathieucarbou commented on September 26, 2024

I am closing since it is fixed

from lilygo-t-eth-series.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.