Skip to content

Commit 5a710be

Browse files
committed
fix(eth): Fix RMII Ethernet not being able to be restarted
1 parent 9e2f755 commit 5a710be

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

libraries/Ethernet/src/ETH.cpp

+11-12
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i
271271
eth_mac_config.sw_reset_timeout_ms = 1000;
272272
eth_mac_config.rx_task_stack_size = _task_stack_size;
273273

274-
esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&mac_config, &eth_mac_config);
275-
if (mac == NULL) {
274+
_mac = esp_eth_mac_new_esp32(&mac_config, &eth_mac_config);
275+
if (_mac == NULL) {
276276
log_e("esp_eth_mac_new_esp32 failed");
277277
return false;
278278
}
@@ -281,26 +281,25 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i
281281
phy_config.phy_addr = phy_addr;
282282
phy_config.reset_gpio_num = _pin_power;
283283

284-
esp_eth_phy_t *phy = NULL;
285284
switch (type) {
286285
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0)
287-
case ETH_PHY_GENERIC: phy = esp_eth_phy_new_generic(&phy_config); break;
286+
case ETH_PHY_GENERIC: _phy = esp_eth_phy_new_generic(&phy_config); break;
288287
#endif
289-
case ETH_PHY_LAN8720: phy = esp_eth_phy_new_lan87xx(&phy_config); break;
290-
case ETH_PHY_TLK110: phy = esp_eth_phy_new_ip101(&phy_config); break;
291-
case ETH_PHY_RTL8201: phy = esp_eth_phy_new_rtl8201(&phy_config); break;
292-
case ETH_PHY_DP83848: phy = esp_eth_phy_new_dp83848(&phy_config); break;
293-
case ETH_PHY_KSZ8041: phy = esp_eth_phy_new_ksz80xx(&phy_config); break;
294-
case ETH_PHY_KSZ8081: phy = esp_eth_phy_new_ksz80xx(&phy_config); break;
288+
case ETH_PHY_LAN8720: _phy = esp_eth_phy_new_lan87xx(&phy_config); break;
289+
case ETH_PHY_TLK110: _phy = esp_eth_phy_new_ip101(&phy_config); break;
290+
case ETH_PHY_RTL8201: _phy = esp_eth_phy_new_rtl8201(&phy_config); break;
291+
case ETH_PHY_DP83848: _phy = esp_eth_phy_new_dp83848(&phy_config); break;
292+
case ETH_PHY_KSZ8041: _phy = esp_eth_phy_new_ksz80xx(&phy_config); break;
293+
case ETH_PHY_KSZ8081: _phy = esp_eth_phy_new_ksz80xx(&phy_config); break;
295294
default: log_e("Unsupported PHY %d", type); break;
296295
}
297-
if (phy == NULL) {
296+
if (_phy == NULL) {
298297
log_e("esp_eth_phy_new failed");
299298
return false;
300299
}
301300

302301
_eth_handle = NULL;
303-
esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(mac, phy);
302+
esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(_mac, _phy);
304303
ret = esp_eth_driver_install(&eth_config, &_eth_handle);
305304
if (ret != ESP_OK) {
306305
log_e("Ethernet driver install failed: %d", ret);

0 commit comments

Comments
 (0)