From 63ce3a5d59f35959230c695f273c8a3f453c2567 Mon Sep 17 00:00:00 2001 From: Mahavir Jain Date: Wed, 7 Sep 2022 12:17:15 +0530 Subject: [PATCH] protocol_examples_common: fix build for SPI_ETHERNET case with IDF v5.x --- .github/workflows/target-test.yml | 9 ++++++++- common_components/protocol_examples_common/connect.c | 11 +++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/target-test.yml b/.github/workflows/target-test.yml index cf0b2fe7f..362d08002 100644 --- a/.github/workflows/target-test.yml +++ b/.github/workflows/target-test.yml @@ -56,16 +56,23 @@ jobs: run: | . ${IDF_PATH}/export.sh cd $GITHUB_WORKSPACE/esp-protocols/components/mdns/examples/ - idf.py set-target ${{ matrix.idf_target }} + idf.py set-target ${{ matrix.idf_target }} + echo "Building for default configuration" + idf.py build + rm sdkconfig + echo "Building for sdkconfig.ci.eth_def" cat sdkconfig.ci.eth_def >> sdkconfig.defaults idf.py build rm sdkconfig sdkconfig.defaults + echo "Building for sdkconfig.ci.eth_custom_netif" cat sdkconfig.ci.eth_custom_netif >> sdkconfig.defaults idf.py build rm sdkconfig sdkconfig.defaults + echo "Building for sdkconfig.ci.eth_socket" cat sdkconfig.ci.eth_socket >> sdkconfig.defaults idf.py build rm sdkconfig sdkconfig.defaults + echo "Building for sdkconfig.ci.eth_no_ipv6" cat sdkconfig.ci.eth_no_ipv6 >> sdkconfig.defaults idf.py build cd $GITHUB_WORKSPACE/esp-protocols/components/mdns/tests/test_apps/ diff --git a/common_components/protocol_examples_common/connect.c b/common_components/protocol_examples_common/connect.c index 85878d78b..08cc348d1 100644 --- a/common_components/protocol_examples_common/connect.c +++ b/common_components/protocol_examples_common/connect.c @@ -396,7 +396,9 @@ static esp_netif_t *eth_start(void) #endif #elif CONFIG_EXAMPLE_USE_SPI_ETHERNET gpio_install_isr_service(0); +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) spi_device_handle_t spi_handle = NULL; +#endif spi_bus_config_t buscfg = { .miso_io_num = CONFIG_EXAMPLE_ETH_SPI_MISO_GPIO, .mosi_io_num = CONFIG_EXAMPLE_ETH_SPI_MOSI_GPIO, @@ -414,9 +416,14 @@ static esp_netif_t *eth_start(void) .spics_io_num = CONFIG_EXAMPLE_ETH_SPI_CS_GPIO, .queue_size = 20 }; +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) ESP_ERROR_CHECK(spi_bus_add_device(CONFIG_EXAMPLE_ETH_SPI_HOST, &devcfg, &spi_handle)); /* dm9051 ethernet driver is based on spi driver */ eth_dm9051_config_t dm9051_config = ETH_DM9051_DEFAULT_CONFIG(spi_handle); +#else + eth_dm9051_config_t dm9051_config = ETH_DM9051_DEFAULT_CONFIG(CONFIG_EXAMPLE_ETH_SPI_HOST, &devcfg); +#endif // ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) + dm9051_config.int_gpio_num = CONFIG_EXAMPLE_ETH_SPI_INT_GPIO; s_mac = esp_eth_mac_new_dm9051(&dm9051_config, &mac_config); s_phy = esp_eth_phy_new_dm9051(&phy_config); @@ -429,9 +436,13 @@ static esp_netif_t *eth_start(void) .spics_io_num = CONFIG_EXAMPLE_ETH_SPI_CS_GPIO, .queue_size = 20 }; +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) ESP_ERROR_CHECK(spi_bus_add_device(CONFIG_EXAMPLE_ETH_SPI_HOST, &devcfg, &spi_handle)); /* w5500 ethernet driver is based on spi driver */ eth_w5500_config_t w5500_config = ETH_W5500_DEFAULT_CONFIG(spi_handle); +#else + eth_w5500_config_t w5500_config = ETH_W5500_DEFAULT_CONFIG(CONFIG_EXAMPLE_ETH_SPI_HOST, &devcfg); +#endif // ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) w5500_config.int_gpio_num = CONFIG_EXAMPLE_ETH_SPI_INT_GPIO; s_mac = esp_eth_mac_new_w5500(&w5500_config, &mac_config); s_phy = esp_eth_phy_new_w5500(&phy_config);