Skip to content

Commit b7bf1de

Browse files
authored
Fix ethenet
1 parent 492773c commit b7bf1de

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

libraries/Ethernet/src/ETH.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_typ
233233
tcpipInit();
234234

235235
tcpip_adapter_set_default_eth_handlers();
236-
236+
237237
esp_netif_config_t cfg = ESP_NETIF_DEFAULT_ETH();
238238
esp_netif_t *eth_netif = esp_netif_new(&cfg);
239239

@@ -245,6 +245,12 @@ 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+
249+
// Theo - core 2.0.2.3 start of fix 1 of 2
250+
mac_config.clock_config.rmii.clock_mode = (eth_clock_mode) ? EMAC_CLK_OUT : EMAC_CLK_EXT_IN;
251+
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;
252+
// Theo - core 2.0.2.3 end of fix 1 of 2
253+
248254
mac_config.smi_mdc_gpio_num = mdc;
249255
mac_config.smi_mdio_gpio_num = mdio;
250256
mac_config.sw_reset_timeout_ms = 1000;
@@ -305,13 +311,17 @@ bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_typ
305311

306312
eth_handle = NULL;
307313
esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(eth_mac, eth_phy);
308-
eth_config.on_lowlevel_init_done = on_lowlevel_init_done;
314+
315+
// Theo - core 2.0.2.3 start of fix 2 of 2
316+
// eth_config.on_lowlevel_init_done = on_lowlevel_init_done;
317+
// Theo - core 2.0.2.3 end of fix 2 of 2
318+
309319
//eth_config.on_lowlevel_deinit_done = on_lowlevel_deinit_done;
310320
if(esp_eth_driver_install(&eth_config, &eth_handle) != ESP_OK || eth_handle == NULL){
311321
log_e("esp_eth_driver_install failed");
312322
return false;
313323
}
314-
324+
315325
/* attach Ethernet driver to TCP/IP stack */
316326
if(esp_netif_attach(eth_netif, esp_eth_new_netif_glue(eth_handle)) != ESP_OK){
317327
log_e("esp_netif_attach failed");
@@ -386,7 +396,7 @@ bool ETHClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, I
386396
{
387397
esp_err_t err = ESP_OK;
388398
tcpip_adapter_ip_info_t info;
389-
399+
390400
if(local_ip != (uint32_t)0x00000000 && local_ip != INADDR_NONE){
391401
info.ip.addr = static_cast<uint32_t>(local_ip);
392402
info.gw.addr = static_cast<uint32_t>(gateway);
@@ -408,7 +418,7 @@ bool ETHClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, I
408418
log_e("STA IP could not be configured! Error: %d", err);
409419
return false;
410420
}
411-
421+
412422
if(info.ip.addr){
413423
staticIP = true;
414424
} else {

0 commit comments

Comments
 (0)