From db08d00e4b77420932ea66dfa5c4f15491a789b2 Mon Sep 17 00:00:00 2001 From: TD-er Date: Sat, 3 Feb 2024 17:37:04 +0100 Subject: [PATCH] [SPI Ethernet] Allow selecting RMII pins for SPI Ethernet As is required when using the M5Stack W5500 module on M5 Stack Core2 --- src/src/DataStructs_templ/SettingsStruct.cpp | 3 +++ src/src/Helpers/StringGenerator_GPIO.cpp | 27 +++++++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/src/DataStructs_templ/SettingsStruct.cpp b/src/src/DataStructs_templ/SettingsStruct.cpp index 195929f912..02b234d7e7 100644 --- a/src/src/DataStructs_templ/SettingsStruct.cpp +++ b/src/src/DataStructs_templ/SettingsStruct.cpp @@ -955,6 +955,9 @@ template bool SettingsStruct_tmpl::isEthernetPin(int8_t pin) const { #if FEATURE_ETHERNET if (pin < 0) return false; + if (isSPI_EthernetType(ETH_Phy_Type)) { + return false; + } if (NetworkMedium == NetworkMedium_t::Ethernet) { if (19 == pin) return true; // ETH TXD0 if (21 == pin) return true; // ETH TX EN diff --git a/src/src/Helpers/StringGenerator_GPIO.cpp b/src/src/Helpers/StringGenerator_GPIO.cpp index 6ae416bf88..dd5198f81e 100644 --- a/src/src/Helpers/StringGenerator_GPIO.cpp +++ b/src/src/Helpers/StringGenerator_GPIO.cpp @@ -287,21 +287,30 @@ const __FlashStringHelper* getConflictingUse(int gpio, PinSelectPurpose purpose) #if FEATURE_ETHERNET + if (isSPI_EthernetType(Settings.ETH_Phy_Type)) { + if (includeEthernet && Settings.isEthernetPinOptional(gpio)) { + if (Settings.ETH_Pin_mdc_cs == gpio) { return F("Eth SPI CS"); } - if (Settings.isEthernetPin(gpio)) { - return F("Eth"); - } + if (Settings.ETH_Pin_mdio_irq == gpio) { return F("Eth SPI IRQ"); } - if (includeEthernet && Settings.isEthernetPinOptional(gpio)) { - if (isGpioUsedInETHClockMode(Settings.ETH_Clock_Mode, gpio)) { return F("Eth Clock"); } + if (Settings.ETH_Pin_power_rst == gpio) { return F("Eth SPI RST"); } + } + } else { + if (Settings.isEthernetPin(gpio)) { + return F("Eth"); + } - if (Settings.ETH_Pin_mdc_cs == gpio) { return F("Eth MDC"); } + if (includeEthernet && Settings.isEthernetPinOptional(gpio)) { + if (isGpioUsedInETHClockMode(Settings.ETH_Clock_Mode, gpio)) { return F("Eth Clock"); } - if (Settings.ETH_Pin_mdio_irq == gpio) { return F("Eth MDIO"); } + if (Settings.ETH_Pin_mdc_cs == gpio) { return F("Eth MDC"); } - if (Settings.ETH_Pin_power_rst == gpio) { return F("Eth Pwr"); } + if (Settings.ETH_Pin_mdio_irq == gpio) { return F("Eth MDIO"); } - return F("Eth"); + if (Settings.ETH_Pin_power_rst == gpio) { return F("Eth Pwr"); } + + return F("Eth"); + } } #endif // if FEATURE_ETHERNET