diff --git a/libraries/Ethernet/src/ETH.cpp b/libraries/Ethernet/src/ETH.cpp index 92d91b40a1a..11d5d3cdea3 100644 --- a/libraries/Ethernet/src/ETH.cpp +++ b/libraries/Ethernet/src/ETH.cpp @@ -351,8 +351,13 @@ bool ETHClass::beginSPI(eth_phy_type_t type, uint8_t phy_addr, int cs, int irq, log_w("ETH Already Started"); return true; } +#if ETH_SPI_SUPPORTS_NO_IRQ + if(cs < 0){ + log_e("CS pin must be defined!"); +#else if(cs < 0 || irq < 0){ log_e("CS and IRQ pins must be defined!"); +#endif return false; } @@ -447,6 +452,11 @@ bool ETHClass::beginSPI(eth_phy_type_t type, uint8_t phy_addr, int cs, int irq, if(type == ETH_PHY_W5500){ eth_w5500_config_t mac_config = ETH_W5500_DEFAULT_CONFIG(spi_host, &spi_devcfg); mac_config.int_gpio_num = _pin_irq; +#if ETH_SPI_SUPPORTS_NO_IRQ + if (_pin_irq < 0) { + mac_config.poll_period_ms = 10; + } +#endif #if ETH_SPI_SUPPORTS_CUSTOM if(_spi != NULL){ mac_config.custom_spi_driver.config = this; @@ -586,8 +596,13 @@ bool ETHClass::beginSPI(eth_phy_type_t type, uint8_t phy_addr, int cs, int irq, #if ETH_SPI_SUPPORTS_CUSTOM } #endif - if(!perimanSetPinBus(_pin_irq, ESP32_BUS_TYPE_ETHERNET_SPI, (void *)(this), -1, -1)){ goto err; } - +#if ETH_SPI_SUPPORTS_NO_IRQ + if(_pin_irq != -1){ +#endif + if(!perimanSetPinBus(_pin_irq, ESP32_BUS_TYPE_ETHERNET_SPI, (void *)(this), -1, -1)){ goto err; } +#if ETH_SPI_SUPPORTS_NO_IRQ + } +#endif if(_pin_sck != -1){ if(!perimanSetPinBus(_pin_sck, ESP32_BUS_TYPE_ETHERNET_SPI, (void *)(this), -1, -1)){ goto err; } }