@@ -163,10 +163,6 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i
163
163
164
164
Network.begin ();
165
165
_ethernets[_eth_index] = this ;
166
- if (_eth_ev_instance == NULL && esp_event_handler_instance_register (ETH_EVENT, ESP_EVENT_ANY_ID, &_eth_event_cb, NULL , &_eth_ev_instance)) {
167
- log_e (" event_handler_instance_register for ETH_EVENT Failed!" );
168
- return false ;
169
- }
170
166
171
167
eth_esp32_emac_config_t mac_config = ETH_ESP32_EMAC_DEFAULT_CONFIG ();
172
168
mac_config.clock_config .rmii .clock_mode = (clock_mode) ? EMAC_CLK_OUT : EMAC_CLK_EXT_IN;
@@ -297,6 +293,11 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i
297
293
return false ;
298
294
}
299
295
296
+ if (_eth_ev_instance == NULL && esp_event_handler_instance_register (ETH_EVENT, ESP_EVENT_ANY_ID, &_eth_event_cb, NULL , &_eth_ev_instance)) {
297
+ log_e (" event_handler_instance_register for ETH_EVENT Failed!" );
298
+ return false ;
299
+ }
300
+
300
301
/* attach to receive events */
301
302
initNetif ((Network_Interface_ID)(ESP_NETIF_ID_ETH + _eth_index));
302
303
@@ -561,10 +562,6 @@ bool ETHClass::beginSPI(
561
562
562
563
Network.begin ();
563
564
_ethernets[_eth_index] = this ;
564
- if (_eth_ev_instance == NULL && esp_event_handler_instance_register (ETH_EVENT, ESP_EVENT_ANY_ID, &_eth_event_cb, NULL , &_eth_ev_instance)) {
565
- log_e (" event_handler_instance_register for ETH_EVENT Failed!" );
566
- return false ;
567
- }
568
565
569
566
// Install GPIO ISR handler to be able to service SPI Eth modules interrupts
570
567
ret = gpio_install_isr_service (0 );
@@ -728,6 +725,11 @@ bool ETHClass::beginSPI(
728
725
return false ;
729
726
}
730
727
728
+ if (_eth_ev_instance == NULL && esp_event_handler_instance_register (ETH_EVENT, ESP_EVENT_ANY_ID, &_eth_event_cb, NULL , &_eth_ev_instance)) {
729
+ log_e (" event_handler_instance_register for ETH_EVENT Failed!" );
730
+ return false ;
731
+ }
732
+
731
733
/* attach to receive events */
732
734
initNetif ((Network_Interface_ID)(ESP_NETIF_ID_ETH + _eth_index));
733
735
0 commit comments