From a1c4211e5b9da6c923e57e9772148d7bb094d59e Mon Sep 17 00:00:00 2001 From: Darek7D Date: Thu, 30 Dec 2021 18:43:27 +0100 Subject: [PATCH 1/3] Add KSZ8041 support --- libraries/Ethernet/src/ETH.cpp | 7 +++++++ libraries/Ethernet/src/ETH.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libraries/Ethernet/src/ETH.cpp b/libraries/Ethernet/src/ETH.cpp index 851eb846170..6cf4daa72de 100644 --- a/libraries/Ethernet/src/ETH.cpp +++ b/libraries/Ethernet/src/ETH.cpp @@ -288,6 +288,13 @@ bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_typ log_e("unsupported ethernet type 'ETH_PHY_KSZ8081'"); #endif break; + case ETH_PHY_KSZ8041: +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4,4,0) + eth_phy = esp_eth_phy_new_ksz8041(&phy_config); +#else + log_e("unsupported ethernet type 'ETH_PHY_KSZ8041'"); +#endif + break; default: break; } diff --git a/libraries/Ethernet/src/ETH.h b/libraries/Ethernet/src/ETH.h index 918cd357d94..4b4ffe8fa85 100644 --- a/libraries/Ethernet/src/ETH.h +++ b/libraries/Ethernet/src/ETH.h @@ -53,7 +53,7 @@ typedef enum { ETH_CLOCK_GPIO0_IN, ETH_CLOCK_GPIO0_OUT, ETH_CLOCK_GPIO16_OUT, ETH_CLOCK_GPIO17_OUT } eth_clock_mode_t; #endif -typedef enum { ETH_PHY_LAN8720, ETH_PHY_TLK110, ETH_PHY_RTL8201, ETH_PHY_DP83848, ETH_PHY_DM9051, ETH_PHY_KSZ8081, ETH_PHY_MAX } eth_phy_type_t; +typedef enum { ETH_PHY_LAN8720, ETH_PHY_TLK110, ETH_PHY_RTL8201, ETH_PHY_DP83848, ETH_PHY_DM9051, ETH_PHY_KSZ8081, ETH_PHY_KSZ8041, ETH_PHY_MAX } eth_phy_type_t; #define ETH_PHY_IP101 ETH_PHY_TLK110 class ETHClass { From f2bcb08a07b8e37649ef93ab0ccc0d95c3a46e0a Mon Sep 17 00:00:00 2001 From: Darek7D Date: Fri, 31 Dec 2021 12:39:10 +0100 Subject: [PATCH 2/3] Changed case order --- libraries/Ethernet/src/ETH.cpp | 12 ++++++------ libraries/Ethernet/src/ETH.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libraries/Ethernet/src/ETH.cpp b/libraries/Ethernet/src/ETH.cpp index 6cf4daa72de..2a8c012cc6b 100644 --- a/libraries/Ethernet/src/ETH.cpp +++ b/libraries/Ethernet/src/ETH.cpp @@ -281,18 +281,18 @@ bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_typ eth_phy = esp_eth_phy_new_dm9051(&phy_config); break; #endif - case ETH_PHY_KSZ8081: + case ETH_PHY_KSZ8041: #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4,4,0) - eth_phy = esp_eth_phy_new_ksz8081(&phy_config); + eth_phy = esp_eth_phy_new_ksz8041(&phy_config); #else - log_e("unsupported ethernet type 'ETH_PHY_KSZ8081'"); + log_e("unsupported ethernet type 'ETH_PHY_KSZ8041'"); #endif break; - case ETH_PHY_KSZ8041: + case ETH_PHY_KSZ8081: #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4,4,0) - eth_phy = esp_eth_phy_new_ksz8041(&phy_config); + eth_phy = esp_eth_phy_new_ksz8081(&phy_config); #else - log_e("unsupported ethernet type 'ETH_PHY_KSZ8041'"); + log_e("unsupported ethernet type 'ETH_PHY_KSZ8081'"); #endif break; default: diff --git a/libraries/Ethernet/src/ETH.h b/libraries/Ethernet/src/ETH.h index 4b4ffe8fa85..8b87d4758d5 100644 --- a/libraries/Ethernet/src/ETH.h +++ b/libraries/Ethernet/src/ETH.h @@ -53,7 +53,7 @@ typedef enum { ETH_CLOCK_GPIO0_IN, ETH_CLOCK_GPIO0_OUT, ETH_CLOCK_GPIO16_OUT, ETH_CLOCK_GPIO17_OUT } eth_clock_mode_t; #endif -typedef enum { ETH_PHY_LAN8720, ETH_PHY_TLK110, ETH_PHY_RTL8201, ETH_PHY_DP83848, ETH_PHY_DM9051, ETH_PHY_KSZ8081, ETH_PHY_KSZ8041, ETH_PHY_MAX } eth_phy_type_t; +typedef enum { ETH_PHY_LAN8720, ETH_PHY_TLK110, ETH_PHY_RTL8201, ETH_PHY_DP83848, ETH_PHY_DM9051, ETH_PHY_KSZ8041, ETH_PHY_KSZ8081, ETH_PHY_MAX } eth_phy_type_t; #define ETH_PHY_IP101 ETH_PHY_TLK110 class ETHClass { From afdd64f31486b69447264c304be816f4ac635797 Mon Sep 17 00:00:00 2001 From: Darek7D Date: Fri, 31 Dec 2021 14:58:41 +0100 Subject: [PATCH 3/3] Unnecessary spaces --- libraries/Ethernet/src/ETH.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Ethernet/src/ETH.cpp b/libraries/Ethernet/src/ETH.cpp index 2a8c012cc6b..a08cc3340d8 100644 --- a/libraries/Ethernet/src/ETH.cpp +++ b/libraries/Ethernet/src/ETH.cpp @@ -294,7 +294,7 @@ bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_typ #else log_e("unsupported ethernet type 'ETH_PHY_KSZ8081'"); #endif - break; + break; default: break; }