Skip to content

Commit

Permalink
Take advantage of polling-based W5500 when interrupt wire is not conn…
Browse files Browse the repository at this point in the history
…ected
  • Loading branch information
DavidSchinazi committed Dec 24, 2024
1 parent a8c8b2b commit c83a8f6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/jazzlights/networks/esp32_ethernet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,22 @@ constexpr int kEthernetPinCS = 19;
constexpr int kEthernetPinMISO = 23;
constexpr int kEthernetPinMOSI = 33;
constexpr int kEthernetPinReset = -1;
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
constexpr int kEthernetPinInterrupt = -1;
#else
constexpr int kEthernetPinInterrupt = 21; // Fake because -1 isn't supported in ESP-IDF v4.
#endif
#elif JL_IS_CONTROLLER(ATOM_S3)
constexpr int kEthernetPinSCK = 5;
constexpr int kEthernetPinCS = 6;
constexpr int kEthernetPinMISO = 7;
constexpr int kEthernetPinMOSI = 8;
constexpr int kEthernetPinReset = -1;
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
constexpr int kEthernetPinInterrupt = -1;
#else
constexpr int kEthernetPinInterrupt = 21; // Fake because -1 isn't supported in ESP-IDF v4.
#endif
#else
#error "Unexpected controller"
#endif
Expand Down Expand Up @@ -533,14 +541,14 @@ Esp32EthernetNetwork::Esp32EthernetNetwork()
// eth_w5500_config_t w5500_config = ETH_W5500_DEFAULT_CONFIG(CONFIG_EXAMPLE_ETH_SPI_HOST, &spi_devcfg);
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
eth_w5500_config_t w5500_config = ETH_W5500_DEFAULT_CONFIG(host_id, &spi_devcfg);
if (kEthernetPinInterrupt < 0) { w5500_config.poll_period_ms = 10; }
#else
spi_device_handle_t spi_handle = nullptr;
ESP_ERROR_CHECK(spi_bus_add_device(host_id, &spi_devcfg, &spi_handle));
eth_w5500_config_t w5500_config = ETH_W5500_DEFAULT_CONFIG(spi_handle);
#endif
w5500_config.int_gpio_num =
kEthernetPinInterrupt; // spi_eth_module_config->int_gpio; -- see comments in the other code version below
// w5500_config.poll_period_ms = spi_eth_module_config->polling_ms;
esp_eth_mac_t* mac = esp_eth_mac_new_w5500(&w5500_config, &mac_config);
esp_eth_phy_t* phy = esp_eth_phy_new_w5500(&phy_config);

Expand Down

0 comments on commit c83a8f6

Please sign in to comment.