diff --git a/cpu/esp32/esp-eth/esp_eth_netdev.c b/cpu/esp32/esp-eth/esp_eth_netdev.c index 2ad287a945d4f1b9bfaeb673441aa59d8b0b059f..f3dd51cb860894457d84ca4f7b3fb4c58add900b 100644 --- a/cpu/esp32/esp-eth/esp_eth_netdev.c +++ b/cpu/esp32/esp-eth/esp_eth_netdev.c @@ -109,11 +109,14 @@ static esp_err_t IRAM_ATTR _eth_input_callback(void *buffer, uint16_t len, void return ESP_OK; } -#if EMAC_PHY_POWER_PIN != GPIO_UNDEF static void _esp_eth_phy_power_enable_gpio(bool enable) { assert(EMAC_ETHERNET_PHY_CONFIG.phy_power_enable); + if (EMAC_PHY_POWER_PIN == GPIO_UNDEF) { + return; + } + if (!enable) { EMAC_ETHERNET_PHY_CONFIG.phy_power_enable(false); } @@ -127,7 +130,6 @@ static void _esp_eth_phy_power_enable_gpio(bool enable) EMAC_ETHERNET_PHY_CONFIG.phy_power_enable(true); } } -#endif static int _esp_eth_init(netdev_t *netdev) { @@ -146,13 +148,13 @@ static int _esp_eth_init(netdev_t *netdev) config.gpio_config = _eth_gpio_config_rmii; config.tcpip_input = _eth_input_callback; - #if EMAC_PHY_POWER_PIN != GPIO_UNDEF /* * Replace the default 'power enable' function with an example-specific * one that toggles a power GPIO. */ - config.phy_power_enable = phy_device_power_enable_via_gpio; - #endif + if (EMAC_PHY_POWER_PIN != GPIO_UNDEF) { + config.phy_power_enable = _esp_eth_phy_power_enable_gpio; + } /* initialize EMAC with config */ if (ret == ESP_OK && (ret = esp_eth_init(&config)) != ESP_OK) { diff --git a/cpu/esp32/include/periph_cpu.h b/cpu/esp32/include/periph_cpu.h index 02eeb72acb1250f6e11c0f042d630785b8466e31..61262de42209021582d83f81a24254fc60e1ba14 100644 --- a/cpu/esp32/include/periph_cpu.h +++ b/cpu/esp32/include/periph_cpu.h @@ -46,16 +46,6 @@ extern "C" { #define PORT_GPIO 0 /**< port GPIO */ /** @} */ -/** - * @brief Definition of a fitting UNDEF value - */ -#define GPIO_UNDEF (0xff) - -/** - * @brief Define CPU specific GPIO pin generator macro - */ -#define GPIO_PIN(x, y) ((x << 4) | y) - /** * @brief Define CPU specific number of GPIO pins * @{