diff --git a/CHANGELOG.md b/CHANGELOG.md index aaa2e3bb7..b39956120 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file. ### Added - Internal support for persistent JSON settings using single file - Command ``SetOption158`` to publish or suppress ModbusReceived MQTT messages (#20678) +- ESP32 Core3 support for SPI ethernet on DM9051, W5500 and KSZ8851 ### Breaking Changed - ESP32 LVGL library from v8.3.11 to v9.0.0, some small breaking changes in C, none in HASPmota (#20659) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index a10bf4647..134474a39 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -136,6 +136,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - ESP32 MI BLE support for Xiaomi LYWSD02MMC [#20381](https://github.com/arendst/Tasmota/issues/20381) - ESP32 support for Shelly Plus Add-On using DS18x20 or DHT11/AM2301/DHT21/DHT22/AM2302/AM2321/SI7021 on GPIO0/1 [#20580](https://github.com/arendst/Tasmota/issues/20580) - ESP32 MI32 Legacy initial support for sensors using BTHOME packet format [#20625](https://github.com/arendst/Tasmota/issues/20625) +- ESP32 Core3 support for SPI ethernet on DM9051, W5500 and KSZ8851 - ESP32-C3 support for GPIO11 [#18350](https://github.com/arendst/Tasmota/issues/18350) - Berry GPIO viewer initial version using async webserver [#20416](https://github.com/arendst/Tasmota/issues/20416) - Berry `introspect.set()` for class attributes [#20339](https://github.com/arendst/Tasmota/issues/20339) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_82_esp32_ethernet.ino b/tasmota/tasmota_xdrv_driver/xdrv_82_esp32_ethernet.ino index 63e1d7d51..9ea0e8f89 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_82_esp32_ethernet.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_82_esp32_ethernet.ino @@ -71,8 +71,11 @@ #endif #ifndef ETH_TYPE -#define ETH_TYPE ETH_PHY_LAN8720 // ETH.h eth_phy_type_t: 0 = ETH_PHY_LAN8720, 1 = ETH_PHY_TLK110/ETH_PHY_IP101, 2 = ETH_PHY_RTL8201, 3 = ETH_PHY_DP83848, 4 = ETH_PHY_DM9051, 5 = ETH_PHY_KSZ8081 - +#if ESP_IDF_VERSION_MAJOR >= 5 +#define ETH_TYPE ETH_PHY_LAN8720 // ETH.h eth_phy_type_t: 0 = ETH_PHY_LAN8720, 1 = ETH_PHY_TLK110/ETH_PHY_IP101, 2 = ETH_PHY_RTL8201, 3 = ETH_PHY_JL1101, 4 = ETH_PHY_DP83848, 5 = ETH_PHY_KSZ8041, 6 = ETH_PHY_KSZ8081, 7 = ETH_PHY_DM9051, 8 = ETH_PHY_W5500, 9 = ETH_PHY_KSZ8851 +#else +#define ETH_TYPE ETH_PHY_LAN8720 // ETH.h eth_phy_type_t: 0 = ETH_PHY_LAN8720, 1 = ETH_PHY_TLK110/ETH_PHY_IP101, 2 = ETH_PHY_RTL8201, 3 = ETH_PHY_DP83848, 4 = ETH_PHY_DM9051, 5 = ETH_PHY_KSZ8041, 6 = ETH_PHY_KSZ8081, 7 = ETH_PHY_JL1101 +#endif #endif #ifndef ETH_CLKMODE @@ -104,11 +107,11 @@ void EthernetEvent(arduino_event_t *event) { while (esp_netif_create_ip6_linklocal(get_esp_interface_netif(ESP_IF_ETH)) != ESP_OK) { delay(1); if (i-- == 0) { - AddLog(LOG_LEVEL_INFO, ">>>> HELP"); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ETH ">>>> HELP")); break; } } - AddLog(LOG_LEVEL_INFO, ">>>> ESP_IF_ETH i=%i", i); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ETH "ESP_IF_ETH i=%i"), i); } #endif // USE_IPV6 @@ -183,12 +186,6 @@ void EthernetSetIp(void) { void EthernetInit(void) { if (!Settings->flag4.network_ethernet) { return; } - if (!PinUsed(GPIO_ETH_PHY_MDC) && !PinUsed(GPIO_ETH_PHY_MDIO)) { - AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ETH "No ETH MDC and/or ETH MDIO GPIO defined")); - return; - } - - eth_config_change = 0; if (WT32_ETH01 == TasmotaGlobal.module_type) { Settings->eth_address = 1; // EthAddress @@ -196,45 +193,43 @@ void EthernetInit(void) { Settings->eth_clk_mode = ETH_CLOCK_GPIO0_IN; // EthClockMode } -// snprintf_P(Eth.hostname, sizeof(Eth.hostname), PSTR("%s-eth"), TasmotaGlobal.hostname); + if (!PinUsed(GPIO_ETH_PHY_MDC) && !PinUsed(GPIO_ETH_PHY_MDIO)) { + if (Settings->eth_type < 7) { + // CONFIG_ETH_USE_ESP32_EMAC + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ETH "No ETH MDC and ETH MDIO GPIO defined")); + } else { + // CONFIG_ETH_SPI_ETHERNET + if (!PinUsed(GPIO_ETH_PHY_POWER)) { + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ETH "No ETH MDC (SPI CS), ETH MDIO (SPI IRQ) and ETH POWER (SPI RST) GPIO defined")); + } + } + return; + } + + eth_config_change = 0; + strlcpy(eth_hostname, TasmotaGlobal.hostname, sizeof(eth_hostname) -5); // Make sure there is room for "-eth" strcat(eth_hostname, "-eth"); WiFi.onEvent(EthernetEvent); - int eth_power = Pin(GPIO_ETH_PHY_POWER); - int eth_mdc = Pin(GPIO_ETH_PHY_MDC); - int eth_mdio = Pin(GPIO_ETH_PHY_MDIO); -//#if CONFIG_IDF_TARGET_ESP32 - // fix an disconnection issue after rebooting Olimex POE - this forces a clean state for all GPIO involved in RMII -// gpio_reset_pin((gpio_num_t)GPIO_ETH_PHY_POWER); -// gpio_reset_pin((gpio_num_t)GPIO_ETH_PHY_MDC); -// gpio_reset_pin((gpio_num_t)GPIO_ETH_PHY_MDIO); -// gpio_reset_pin(GPIO_NUM_19); // EMAC_TXD0 - hardcoded -// gpio_reset_pin(GPIO_NUM_21); // EMAC_TX_EN - hardcoded -// gpio_reset_pin(GPIO_NUM_22); // EMAC_TXD1 - hardcoded -// gpio_reset_pin(GPIO_NUM_25); // EMAC_RXD0 - hardcoded -// gpio_reset_pin(GPIO_NUM_26); // EMAC_RXD1 - hardcoded -// gpio_reset_pin(GPIO_NUM_27); // EMAC_RX_CRS_DV - hardcoded -// switch (Settings->eth_clk_mode) { -// case 0: // ETH_CLOCK_GPIO0_IN -// case 1: // ETH_CLOCK_GPIO0_OUT -// gpio_reset_pin(GPIO_NUM_0); -// break; -// case 2: // ETH_CLOCK_GPIO16_OUT -// gpio_reset_pin(GPIO_NUM_16); -// break; -// case 3: // ETH_CLOCK_GPIO17_OUT -// gpio_reset_pin(GPIO_NUM_17); -// break; -// } -// delay(1); -//#endif // CONFIG_IDF_TARGET_ESP32 + int eth_mdc = Pin(GPIO_ETH_PHY_MDC); // Ethernet SPI CS (chip select) + int eth_mdio = Pin(GPIO_ETH_PHY_MDIO); // Ethernet SPI IRQ + int eth_power = Pin(GPIO_ETH_PHY_POWER); // Ethernet SPI RST + + bool init_ok = false; #if ESP_IDF_VERSION_MAJOR >= 5 - if (!ETH.begin( (eth_phy_type_t)Settings->eth_type, Settings->eth_address, eth_mdc, eth_mdio, eth_power, (eth_clock_mode_t)Settings->eth_clk_mode)) { + if (Settings->eth_type < 7) { + // CONFIG_ETH_USE_ESP32_EMAC + init_ok = (ETH.begin((eth_phy_type_t)Settings->eth_type, Settings->eth_address, eth_mdc, eth_mdio, eth_power, (eth_clock_mode_t)Settings->eth_clk_mode)); + } else { + // CONFIG_ETH_SPI_ETHERNET + init_ok = (ETH.begin((eth_phy_type_t)Settings->eth_type, Settings->eth_address, eth_mdc, eth_mdio, eth_power, SPI, ETH_PHY_SPI_FREQ_MHZ)); + } #else - if (!ETH.begin(Settings->eth_address, eth_power, eth_mdc, eth_mdio, (eth_phy_type_t)Settings->eth_type, (eth_clock_mode_t)Settings->eth_clk_mode)) { + init_ok = (ETH.begin(Settings->eth_address, eth_power, eth_mdc, eth_mdio, (eth_phy_type_t)Settings->eth_type, (eth_clock_mode_t)Settings->eth_clk_mode)); #endif + if (!init_ok) { AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ETH "Bad PHY type or init error")); return; };