[Eth] Add option to autodetect Eth PHY address + documentation

This commit is contained in:
TD-er
2022-02-08 13:06:15 +01:00
parent e9b70074ea
commit 61dc72643c
4 changed files with 23 additions and 5 deletions
+19 -1
View File
@@ -202,19 +202,29 @@ Select the used PHY controller type:
* LAN8710 (LAN8720 is also supported, but none of the newer features are supported)
* TLK110
* RTL8201 (since ESP32 IDF 4.4)
* DP83848 (since ESP32 IDF 4.4)
* DM9051 (since ESP32 IDF 4.4)
.. note:: The LAN8710 and LAN8720 are also available with an "A" suffix.
These are the same chips, only produced after the brand SMSC was taken over by Microchip Technology.
Ethernet PHY Address
^^^^^^^^^^^^^^^^^^^^
The PHY address depends on the hardware and the PHY configuration.
On some chips, like the LAN8720, the board designer may set this address by pulling some pins either high or low at power on.
In theory, one could use multiple PHY adapters on the same RMII bus, but this is not supported by ESPEasy.
* Espressif's Ethernet board with TLK110 PHY use PHY address 31.
* Common Waveshare LAN8720 PHY breakout use PHY address 1.
* Common Waveshare LAN8720 PHY breakout board (and clones) use PHY address 1.
* Olimex ESP32 EVB REV B IoT LAN8710 PHY Board with CAN use PHY address 0.
* Other LAN8720 breakouts often use PHY address 0.
If the PHY address is incorrect then the EMAC will initialise but all attempts to read/write configuration registers on the PHY will fail.
N.B. There is support for an auto detect of this PHY address, by setting it to -1, but at least on the LAN8720 this does not seem to work.
GPIO pins
^^^^^^^^^
@@ -238,6 +248,8 @@ Another option is to let the ESP provide the clock to the PHY.
* 50MHz APLL Output on GPIO16
* 50MHz APLL Inverted Output on GPIO17
.. note:: When using an external crystal oscillator, this is connected to GPIO-0. Make sure this crystal is not active, or connected to GPIO-0, during boot or else the ESP32 may boot into flash mode.
Power pin
"""""""""
@@ -250,6 +262,12 @@ The Olimex ESP32-EVB does have a specific delay circuit to only allow power to t
For other boards, the default is often GPIO-17, but this may change per board.
(Changed: 2022-01-20)
If the power pin is defined, ESPEasy will toggle the ethernet module off and on at boot.
Some Ethernet modules, like the LAN8720, may sometimes get stuck and need to be reset to get it to work again.
RMII PHY Wiring
"""""""""""""""
+1 -1
View File
@@ -46,7 +46,7 @@ String Command_Subnet (struct EventStruct *event, const char* Line)
#ifdef HAS_ETHERNET
String Command_ETH_Phy_Addr (struct EventStruct *event, const char* Line)
{
return Command_GetORSetUint8_t(event, F("ETH_Phy_Addr:"), Line, reinterpret_cast<uint8_t*>(&Settings.ETH_Phy_Addr),1);
return Command_GetORSetInt8_t(event, F("ETH_Phy_Addr:"), Line, reinterpret_cast<int8_t*>(&Settings.ETH_Phy_Addr),1);
}
String Command_ETH_Pin_mdc (struct EventStruct *event, const char* Line)
+1 -1
View File
@@ -303,7 +303,7 @@ class SettingsStruct_tmpl
// Try to extend settings to make the checksum 4-uint8_t aligned.
// uint8_t ProgmemMd5[16]; // crc of the binary that last saved the struct to file.
// uint8_t md5[16];
uint8_t ETH_Phy_Addr;
int8_t ETH_Phy_Addr;
int8_t ETH_Pin_mdc;
int8_t ETH_Pin_mdio;
int8_t ETH_Pin_power;
+2 -2
View File
@@ -238,8 +238,8 @@ void handle_hardware() {
addSelector(F("ethtype"), nrItems, ethPhyTypes, ethPhyTypes_index, nullptr, static_cast<int>(Settings.ETH_Phy_Type), false, true);
}
addFormNumericBox(F("Ethernet PHY Address"), F("ethphy"), Settings.ETH_Phy_Addr, 0, 255);
addFormNote(F("I&sup2;C-address of Ethernet PHY (0 or 1 for LAN8720, 31 for TLK110)"));
addFormNumericBox(F("Ethernet PHY Address"), F("ethphy"), Settings.ETH_Phy_Addr, -1, 127);
addFormNote(F("I&sup2;C-address of Ethernet PHY (0 or 1 for LAN8720, 31 for TLK110, -1 autodetect)"));
addFormPinSelect(PinSelectPurpose::Ethernet, formatGpioName_output(F("Ethernet MDC pin")), F("ethmdc"), Settings.ETH_Pin_mdc);
addFormPinSelect(PinSelectPurpose::Ethernet, formatGpioName_input(F("Ethernet MIO pin")), F("ethmdio"), Settings.ETH_Pin_mdio);
addFormPinSelect(PinSelectPurpose::Ethernet, formatGpioName_output(F("Ethernet Power pin")), F("ethpower"), Settings.ETH_Pin_power);