Skip to content

Commit 113de1f

Browse files
TD-erlucasssvazme-no-dev
authored
[Enhancement] Support no-IRQ for SPI Ethernet W5500 (#9251)
* [W5500] Support no-IRQ Requires this commit from ESP-IDF to be cherry picked: espressif/esp-idf@fd0a1dc * Remove unrelated code to support ETH_PHY_JL1101 * remove the commented check and fix the error message * Guard feature to be enabled when IDF backports it to v5.1 --------- Co-authored-by: Lucas Saavedra Vaz <[email protected]> Co-authored-by: Me No Dev <[email protected]>
1 parent a5b3119 commit 113de1f

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

Diff for: libraries/Ethernet/src/ETH.cpp

+17-2
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,13 @@ bool ETHClass::beginSPI(eth_phy_type_t type, uint8_t phy_addr, int cs, int irq,
351351
log_w("ETH Already Started");
352352
return true;
353353
}
354+
#if ETH_SPI_SUPPORTS_NO_IRQ
355+
if(cs < 0){
356+
log_e("CS pin must be defined!");
357+
#else
354358
if(cs < 0 || irq < 0){
355359
log_e("CS and IRQ pins must be defined!");
360+
#endif
356361
return false;
357362
}
358363

@@ -447,6 +452,11 @@ bool ETHClass::beginSPI(eth_phy_type_t type, uint8_t phy_addr, int cs, int irq,
447452
if(type == ETH_PHY_W5500){
448453
eth_w5500_config_t mac_config = ETH_W5500_DEFAULT_CONFIG(spi_host, &spi_devcfg);
449454
mac_config.int_gpio_num = _pin_irq;
455+
#if ETH_SPI_SUPPORTS_NO_IRQ
456+
if (_pin_irq < 0) {
457+
mac_config.poll_period_ms = 10;
458+
}
459+
#endif
450460
#if ETH_SPI_SUPPORTS_CUSTOM
451461
if(_spi != NULL){
452462
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,
586596
#if ETH_SPI_SUPPORTS_CUSTOM
587597
}
588598
#endif
589-
if(!perimanSetPinBus(_pin_irq, ESP32_BUS_TYPE_ETHERNET_SPI, (void *)(this), -1, -1)){ goto err; }
590-
599+
#if ETH_SPI_SUPPORTS_NO_IRQ
600+
if(_pin_irq != -1){
601+
#endif
602+
if(!perimanSetPinBus(_pin_irq, ESP32_BUS_TYPE_ETHERNET_SPI, (void *)(this), -1, -1)){ goto err; }
603+
#if ETH_SPI_SUPPORTS_NO_IRQ
604+
}
605+
#endif
591606
if(_pin_sck != -1){
592607
if(!perimanSetPinBus(_pin_sck, ESP32_BUS_TYPE_ETHERNET_SPI, (void *)(this), -1, -1)){ goto err; }
593608
}

0 commit comments

Comments
 (0)