@@ -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;
@@ -286,6 +282,11 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i
286
282
return false ;
287
283
}
288
284
285
+ if (_eth_ev_instance == NULL && esp_event_handler_instance_register (ETH_EVENT, ESP_EVENT_ANY_ID, &_eth_event_cb, NULL , &_eth_ev_instance)) {
286
+ log_e (" event_handler_instance_register for ETH_EVENT Failed!" );
287
+ return false ;
288
+ }
289
+
289
290
/* attach to receive events */
290
291
initNetif ((Network_Interface_ID)(ESP_NETIF_ID_ETH + _eth_index));
291
292
@@ -550,10 +551,6 @@ bool ETHClass::beginSPI(
550
551
551
552
Network.begin ();
552
553
_ethernets[_eth_index] = this ;
553
- if (_eth_ev_instance == NULL && esp_event_handler_instance_register (ETH_EVENT, ESP_EVENT_ANY_ID, &_eth_event_cb, NULL , &_eth_ev_instance)) {
554
- log_e (" event_handler_instance_register for ETH_EVENT Failed!" );
555
- return false ;
556
- }
557
554
558
555
// Install GPIO ISR handler to be able to service SPI Eth modules interrupts
559
556
ret = gpio_install_isr_service (0 );
@@ -717,6 +714,11 @@ bool ETHClass::beginSPI(
717
714
return false ;
718
715
}
719
716
717
+ if (_eth_ev_instance == NULL && esp_event_handler_instance_register (ETH_EVENT, ESP_EVENT_ANY_ID, &_eth_event_cb, NULL , &_eth_ev_instance)) {
718
+ log_e (" event_handler_instance_register for ETH_EVENT Failed!" );
719
+ return false ;
720
+ }
721
+
720
722
/* attach to receive events */
721
723
initNetif ((Network_Interface_ID)(ESP_NETIF_ID_ETH + _eth_index));
722
724
0 commit comments