mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-03 10:30:58 +02:00
Merge branch 'contrib/github_pr_16869' into 'master'
feat(examples): improved example for Ethernet SPI polling mode without interrupt (GitHub PR) Closes IDFGH-15933 See merge request espressif/esp-idf!41071
This commit is contained in:
@@ -295,10 +295,18 @@ menu "Example Connection Configuration"
|
|||||||
|
|
||||||
config EXAMPLE_ETH_SPI_INT_GPIO
|
config EXAMPLE_ETH_SPI_INT_GPIO
|
||||||
int "Interrupt GPIO number"
|
int "Interrupt GPIO number"
|
||||||
range ENV_GPIO_RANGE_MIN ENV_GPIO_IN_RANGE_MAX
|
range -1 ENV_GPIO_IN_RANGE_MAX
|
||||||
default 4
|
default 4
|
||||||
help
|
help
|
||||||
Set the GPIO number used by the SPI Ethernet module interrupt line.
|
Set the GPIO number used by the SPI Ethernet module interrupt line.
|
||||||
|
Set -1 to use SPI Ethernet module in polling mode.
|
||||||
|
|
||||||
|
config EXAMPLE_ETH_SPI_POLLING_MS_VAL
|
||||||
|
depends on EXAMPLE_ETH_SPI_INT_GPIO < 0
|
||||||
|
int "Polling period in msec of SPI Ethernet Module"
|
||||||
|
default 10
|
||||||
|
help
|
||||||
|
Set SPI Ethernet module polling period.
|
||||||
endif # EXAMPLE_USE_SPI_ETHERNET
|
endif # EXAMPLE_USE_SPI_ETHERNET
|
||||||
|
|
||||||
config EXAMPLE_ETH_PHY_RST_GPIO
|
config EXAMPLE_ETH_PHY_RST_GPIO
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
*/
|
*/
|
||||||
@@ -115,7 +115,7 @@ static esp_netif_t *eth_start(void)
|
|||||||
s_phy = esp_eth_phy_new_dp83848(&phy_config);
|
s_phy = esp_eth_phy_new_dp83848(&phy_config);
|
||||||
#elif CONFIG_EXAMPLE_ETH_PHY_KSZ80XX
|
#elif CONFIG_EXAMPLE_ETH_PHY_KSZ80XX
|
||||||
s_phy = esp_eth_phy_new_ksz80xx(&phy_config);
|
s_phy = esp_eth_phy_new_ksz80xx(&phy_config);
|
||||||
#endif
|
#endif // CONFIG_EXAMPLE_ETH_PHY_GENERIC
|
||||||
#elif CONFIG_EXAMPLE_USE_SPI_ETHERNET
|
#elif CONFIG_EXAMPLE_USE_SPI_ETHERNET
|
||||||
gpio_install_isr_service(0);
|
gpio_install_isr_service(0);
|
||||||
spi_bus_config_t buscfg = {
|
spi_bus_config_t buscfg = {
|
||||||
@@ -136,20 +136,26 @@ static esp_netif_t *eth_start(void)
|
|||||||
/* dm9051 ethernet driver is based on spi driver */
|
/* dm9051 ethernet driver is based on spi driver */
|
||||||
eth_dm9051_config_t dm9051_config = ETH_DM9051_DEFAULT_CONFIG(CONFIG_EXAMPLE_ETH_SPI_HOST, &spi_devcfg);
|
eth_dm9051_config_t dm9051_config = ETH_DM9051_DEFAULT_CONFIG(CONFIG_EXAMPLE_ETH_SPI_HOST, &spi_devcfg);
|
||||||
dm9051_config.int_gpio_num = CONFIG_EXAMPLE_ETH_SPI_INT_GPIO;
|
dm9051_config.int_gpio_num = CONFIG_EXAMPLE_ETH_SPI_INT_GPIO;
|
||||||
|
#if CONFIG_EXAMPLE_ETH_SPI_INT_GPIO < 0
|
||||||
|
dm9051_config.poll_period_ms = CONFIG_EXAMPLE_ETH_SPI_POLLING_MS_VAL;
|
||||||
|
#endif // CONFIG_EXAMPLE_ETH_SPI_INT_GPIO
|
||||||
s_mac = esp_eth_mac_new_dm9051(&dm9051_config, &mac_config);
|
s_mac = esp_eth_mac_new_dm9051(&dm9051_config, &mac_config);
|
||||||
s_phy = esp_eth_phy_new_dm9051(&phy_config);
|
s_phy = esp_eth_phy_new_dm9051(&phy_config);
|
||||||
#elif CONFIG_EXAMPLE_USE_W5500
|
#elif CONFIG_EXAMPLE_USE_W5500
|
||||||
/* w5500 ethernet driver is based on spi driver */
|
/* w5500 ethernet driver is based on spi driver */
|
||||||
eth_w5500_config_t w5500_config = ETH_W5500_DEFAULT_CONFIG(CONFIG_EXAMPLE_ETH_SPI_HOST, &spi_devcfg);
|
eth_w5500_config_t w5500_config = ETH_W5500_DEFAULT_CONFIG(CONFIG_EXAMPLE_ETH_SPI_HOST, &spi_devcfg);
|
||||||
w5500_config.int_gpio_num = CONFIG_EXAMPLE_ETH_SPI_INT_GPIO;
|
w5500_config.int_gpio_num = CONFIG_EXAMPLE_ETH_SPI_INT_GPIO;
|
||||||
|
#if CONFIG_EXAMPLE_ETH_SPI_INT_GPIO < 0
|
||||||
|
w5500_config.poll_period_ms = CONFIG_EXAMPLE_ETH_SPI_POLLING_MS_VAL;
|
||||||
|
#endif // CONFIG_EXAMPLE_ETH_SPI_INT_GPIO
|
||||||
s_mac = esp_eth_mac_new_w5500(&w5500_config, &mac_config);
|
s_mac = esp_eth_mac_new_w5500(&w5500_config, &mac_config);
|
||||||
s_phy = esp_eth_phy_new_w5500(&phy_config);
|
s_phy = esp_eth_phy_new_w5500(&phy_config);
|
||||||
#endif
|
#endif // CONFIG_EXAMPLE_USE_DM9051
|
||||||
#elif CONFIG_EXAMPLE_USE_OPENETH
|
#elif CONFIG_EXAMPLE_USE_OPENETH
|
||||||
phy_config.autonego_timeout_ms = 100;
|
phy_config.autonego_timeout_ms = 100;
|
||||||
s_mac = esp_eth_mac_new_openeth(&mac_config);
|
s_mac = esp_eth_mac_new_openeth(&mac_config);
|
||||||
s_phy = esp_eth_phy_new_dp83848(&phy_config);
|
s_phy = esp_eth_phy_new_dp83848(&phy_config);
|
||||||
#endif
|
#endif // CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET
|
||||||
|
|
||||||
// Install Ethernet driver
|
// Install Ethernet driver
|
||||||
esp_eth_config_t config = ETH_DEFAULT_CONFIG(s_mac, s_phy);
|
esp_eth_config_t config = ETH_DEFAULT_CONFIG(s_mac, s_phy);
|
||||||
|
Reference in New Issue
Block a user