Skip to content
Snippets Groups Projects
Commit d9706d1c authored by Gunar Schorcht's avatar Gunar Schorcht Committed by Schorcht
Browse files

cpu/esp32: GPIO macro cleanup in periph_cpu.h

The default macros GPIO_PIN and GPIO_UNDEF do not have to be overridden. The GPIO_PIN macro definition was even wrong for 40 GPIOs without splitting into ports, even if that did not lead to erroneous behavior.
parent ee3efa34
Branches
No related tags found
No related merge requests found
...@@ -109,11 +109,14 @@ static esp_err_t IRAM_ATTR _eth_input_callback(void *buffer, uint16_t len, void ...@@ -109,11 +109,14 @@ static esp_err_t IRAM_ATTR _eth_input_callback(void *buffer, uint16_t len, void
return ESP_OK; return ESP_OK;
} }
#if EMAC_PHY_POWER_PIN != GPIO_UNDEF
static void _esp_eth_phy_power_enable_gpio(bool enable) static void _esp_eth_phy_power_enable_gpio(bool enable)
{ {
assert(EMAC_ETHERNET_PHY_CONFIG.phy_power_enable); assert(EMAC_ETHERNET_PHY_CONFIG.phy_power_enable);
if (EMAC_PHY_POWER_PIN == GPIO_UNDEF) {
return;
}
if (!enable) { if (!enable) {
EMAC_ETHERNET_PHY_CONFIG.phy_power_enable(false); EMAC_ETHERNET_PHY_CONFIG.phy_power_enable(false);
} }
...@@ -127,7 +130,6 @@ static void _esp_eth_phy_power_enable_gpio(bool enable) ...@@ -127,7 +130,6 @@ static void _esp_eth_phy_power_enable_gpio(bool enable)
EMAC_ETHERNET_PHY_CONFIG.phy_power_enable(true); EMAC_ETHERNET_PHY_CONFIG.phy_power_enable(true);
} }
} }
#endif
static int _esp_eth_init(netdev_t *netdev) static int _esp_eth_init(netdev_t *netdev)
{ {
...@@ -146,13 +148,13 @@ 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.gpio_config = _eth_gpio_config_rmii;
config.tcpip_input = _eth_input_callback; config.tcpip_input = _eth_input_callback;
#if EMAC_PHY_POWER_PIN != GPIO_UNDEF
/* /*
* Replace the default 'power enable' function with an example-specific * Replace the default 'power enable' function with an example-specific
* one that toggles a power GPIO. * one that toggles a power GPIO.
*/ */
config.phy_power_enable = phy_device_power_enable_via_gpio; if (EMAC_PHY_POWER_PIN != GPIO_UNDEF) {
#endif config.phy_power_enable = _esp_eth_phy_power_enable_gpio;
}
/* initialize EMAC with config */ /* initialize EMAC with config */
if (ret == ESP_OK && (ret = esp_eth_init(&config)) != ESP_OK) { if (ret == ESP_OK && (ret = esp_eth_init(&config)) != ESP_OK) {
......
...@@ -46,16 +46,6 @@ extern "C" { ...@@ -46,16 +46,6 @@ extern "C" {
#define PORT_GPIO 0 /**< port GPIO */ #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 * @brief Define CPU specific number of GPIO pins
* @{ * @{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment