Skip to content

Commit 066886e

Browse files
authored
fix ethernet clock runtime setting (#6340)
this was not possible anymore since the GPIO refactoring. This superseeds espressif/esp32-arduino-lib-builder#60 (which works only for clock on GPIO17). A PR will provided to revert this. @me-no-dev fyi The fix is done from @arendst Credits go to him!
1 parent 1c57cf0 commit 066886e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Diff for: libraries/Ethernet/src/ETH.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_typ
245245
#endif
246246
#if CONFIG_ETH_USE_ESP32_EMAC
247247
eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
248+
mac_config.clock_config.rmii.clock_mode = (eth_clock_mode) ? EMAC_CLK_OUT : EMAC_CLK_EXT_IN;
249+
mac_config.clock_config.rmii.clock_gpio = (1 == eth_clock_mode) ? EMAC_APPL_CLK_OUT_GPIO : (2 == eth_clock_mode) ? EMAC_CLK_OUT_GPIO : (3 == eth_clock_mode) ? EMAC_CLK_OUT_180_GPIO : EMAC_CLK_IN_GPIO;
248250
mac_config.smi_mdc_gpio_num = mdc;
249251
mac_config.smi_mdio_gpio_num = mdio;
250252
mac_config.sw_reset_timeout_ms = 1000;
@@ -305,7 +307,7 @@ bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_typ
305307

306308
eth_handle = NULL;
307309
esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(eth_mac, eth_phy);
308-
eth_config.on_lowlevel_init_done = on_lowlevel_init_done;
310+
//eth_config.on_lowlevel_init_done = on_lowlevel_init_done;
309311
//eth_config.on_lowlevel_deinit_done = on_lowlevel_deinit_done;
310312
if(esp_eth_driver_install(&eth_config, &eth_handle) != ESP_OK || eth_handle == NULL){
311313
log_e("esp_eth_driver_install failed");
@@ -386,7 +388,7 @@ bool ETHClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, I
386388
{
387389
esp_err_t err = ESP_OK;
388390
tcpip_adapter_ip_info_t info;
389-
391+
390392
if(local_ip != (uint32_t)0x00000000 && local_ip != INADDR_NONE){
391393
info.ip.addr = static_cast<uint32_t>(local_ip);
392394
info.gw.addr = static_cast<uint32_t>(gateway);

0 commit comments

Comments
 (0)