1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-29 00:11:16 +01:00

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.
This commit is contained in:
Gunar Schorcht 2018-12-18 17:56:22 +01:00 committed by Schorcht
parent ee3efa3436
commit d9706d1cd5
2 changed files with 7 additions and 15 deletions

View File

@ -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) {

View File

@ -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
* @{