From 71d19fa9c912db916c23b4485cea13d4a15055ee Mon Sep 17 00:00:00 2001 From: Ondrej Kosta Date: Mon, 3 Apr 2023 17:35:41 +0200 Subject: [PATCH] Ethernet driver and documentation clean-up --- components/esp_eth/src/esp_eth_phy.c | 36 ---------------------- components/hal/esp32/include/hal/emac_ll.h | 2 +- docs/en/api-reference/network/esp_eth.rst | 21 +++++++------ 3 files changed, 12 insertions(+), 47 deletions(-) delete mode 100644 components/esp_eth/src/esp_eth_phy.c diff --git a/components/esp_eth/src/esp_eth_phy.c b/components/esp_eth/src/esp_eth_phy.c deleted file mode 100644 index 05b09eb17a..0000000000 --- a/components/esp_eth/src/esp_eth_phy.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -#include -#include -#include "esp_log.h" -#include "esp_eth_driver.h" -#include "eth_phy_regs_struct.h" - -static const char *TAG = "esp_eth.phy"; - -esp_err_t esp_eth_detect_phy_addr(esp_eth_mediator_t *eth, int *detected_addr) -{ - if (!eth || !detected_addr) { - ESP_LOGE(TAG, "eth and detected_addr can't be null"); - return ESP_ERR_INVALID_ARG; - } - int addr_try = 0; - uint32_t reg_value = 0; - for (; addr_try < 16; addr_try++) { - eth->phy_reg_read(eth, addr_try, ETH_PHY_IDR1_REG_ADDR, ®_value); - if (reg_value != 0xFFFF && reg_value != 0x00) { - *detected_addr = addr_try; - break; - } - } - if (addr_try < 16) { - ESP_LOGD(TAG, "Found PHY address: %d", addr_try); - return ESP_OK; - } else { - ESP_LOGE(TAG, "No PHY device detected"); - return ESP_ERR_NOT_FOUND; - } -} diff --git a/components/hal/esp32/include/hal/emac_ll.h b/components/hal/esp32/include/hal/emac_ll.h index a93e44bdd6..1c8e705215 100644 --- a/components/hal/esp32/include/hal/emac_ll.h +++ b/components/hal/esp32/include/hal/emac_ll.h @@ -241,7 +241,7 @@ static inline void emac_ll_set_back_off_limit(emac_mac_dev_t *mac_regs, uint32_t static inline void emac_ll_deferral_check_enable(emac_mac_dev_t *mac_regs, bool enable) { - mac_regs->gmacconfig.padcrcstrip = enable; + mac_regs->gmacconfig.deferralcheck = enable; } static inline void emac_ll_set_preamble_length(emac_mac_dev_t *mac_regs, uint32_t len) diff --git a/docs/en/api-reference/network/esp_eth.rst b/docs/en/api-reference/network/esp_eth.rst index f6024fb770..3844417cbb 100644 --- a/docs/en/api-reference/network/esp_eth.rst +++ b/docs/en/api-reference/network/esp_eth.rst @@ -191,10 +191,11 @@ The Ethernet driver is implemented in an Object-Oriented style. Any operation on :: - eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG(); // apply default MAC configuration - mac_config.smi_mdc_gpio_num = CONFIG_EXAMPLE_ETH_MDC_GPIO; // alter the GPIO used for MDC signal - mac_config.smi_mdio_gpio_num = CONFIG_EXAMPLE_ETH_MDIO_GPIO; // alter the GPIO used for MDIO signal - esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&mac_config); // create MAC instance + eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG(); // apply default common MAC configuration + eth_esp32_emac_config_t esp32_emac_config = ETH_ESP32_EMAC_DEFAULT_CONFIG(); // apply default vendor specific MAC configuration + esp32_emac_config.smi_mdc_gpio_num = CONFIG_EXAMPLE_ETH_MDC_GPIO; // alter the GPIO used for MDC signal + esp32_emac_config.smi_mdio_gpio_num = CONFIG_EXAMPLE_ETH_MDIO_GPIO; // alter the GPIO used for MDIO signal + esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&esp32_emac_config, &mac_config); // create MAC instance eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG(); // apply default PHY configuration phy_config.phy_addr = CONFIG_EXAMPLE_ETH_PHY_ADDR; // alter the PHY address according to your board design @@ -214,14 +215,14 @@ The Ethernet driver is implemented in an Object-Oriented style. Any operation on :: - eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG(); // apply default MAC configuration + eth_esp32_emac_config_t esp32_emac_config = ETH_ESP32_EMAC_DEFAULT_CONFIG(); // apply default vendor specific MAC configuration // ... - mac_config.interface = EMAC_DATA_INTERFACE_RMII; // alter EMAC Data Interface - mac_config.clock_config.rmii.clock_mode = EMAC_CLK_OUT; // select EMAC REF_CLK mode - mac_config.clock_config.rmii.clock_gpio = EMAC_CLK_OUT_GPIO; // select GPIO number used to input/output EMAC REF_CLK - esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&mac_config); // create MAC instance + esp32_emac_config.interface = EMAC_DATA_INTERFACE_RMII; // alter EMAC Data Interface + esp32_emac_config.clock_config.rmii.clock_mode = EMAC_CLK_OUT; // select EMAC REF_CLK mode + esp32_emac_config.clock_config.rmii.clock_gpio = EMAC_CLK_OUT_GPIO; // select GPIO number used to input/output EMAC REF_CLK + esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&esp32_emac_config, &mac_config); // create MAC instance SPI-Ethernet Module @@ -231,7 +232,7 @@ SPI-Ethernet Module :: - eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG(); // apply default MAC configuration + eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG(); // apply default common MAC configuration eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG(); // apply default PHY configuration phy_config.phy_addr = CONFIG_EXAMPLE_ETH_PHY_ADDR; // alter the PHY address according to your board design phy_config.reset_gpio_num = CONFIG_EXAMPLE_ETH_PHY_RST_GPIO; // alter the GPIO used for PHY reset