IDF4.4.6中,esp_eth_mac_new_esp32 函数用什么替代了?

Mars.CN
Posts: 44
Joined: Tue Jan 11, 2022 1:36 am

IDF4.4.6中,esp_eth_mac_new_esp32 函数用什么替代了?

Postby Mars.CN » Sun Mar 10, 2024 1:42 am

我在编译 MicroPython 的时候,在 networl_lan.c 文件中遇到了一个错误,没有找到 esp_eth_mac_new_esp32 函数,编译器提示可以用 esp_eth_mac_new_w5500 此类函数代替,但是感觉还是有问题。
MicroPython 官方给出的是必须是 IDF4.1 以上的版本才可以,但我这个版本应该是比较新的了,依然找不到这个函数。
因为后面还有其他代码,所有不可能用 esp_eth_mac_new_w5500 替代,请问应该如何解决?

Code: Select all

    eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
    mac_config.smi_mdc_gpio_num = self->mdc_pin;
    mac_config.smi_mdio_gpio_num = self->mdio_pin;
    esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&mac_config);
    
    eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
    phy_config.phy_addr = self->phy_addr;
    phy_config.reset_gpio_num = self->phy_power_pin;
    self->phy = NULL;

    switch (args[ARG_phy_type].u_int) {
        case PHY_LAN8720:
            self->phy = esp_eth_phy_new_lan8720(&phy_config);
            break;
        case PHY_IP101:
            self->phy = esp_eth_phy_new_ip101(&phy_config);
            break;
        case PHY_RTL8201:
            self->phy = esp_eth_phy_new_rtl8201(&phy_config);
            break;
        case PHY_DP83848:
            self->phy = esp_eth_phy_new_dp83848(&phy_config);
            break;
        case PHY_W5500:
            self->phy = esp_eth_phy_new_w5500(&phy_config);
            break;
        case PHY_DM9051:
            self->phy = esp_eth_phy_new_dm9051(&phy_config);
            break;
        case PHY_KSZ8851SNL:
            self->phy = esp_eth_phy_new_ksz8851snl(&phy_config);
            break;
        case PHY_KSZ8041:
            #if ESP_IDF_VERSION_MINOR >= 3      // KSZ8041 is new in ESP-IDF v4.3
            self->phy = esp_eth_phy_new_ksz8041(&phy_config);
            break;
            #endif
        default:
            mp_raise_ValueError(MP_ERROR_TEXT("unknown phy"));
    }
以上这段是 MicroPython 给出的代码

Mars.CN
Posts: 44
Joined: Tue Jan 11, 2022 1:36 am

Re: IDF4.4.6中,esp_eth_mac_new_esp32 函数用什么替代了?

Postby Mars.CN » Sun Mar 10, 2024 2:02 am

我看了一下 IDF 的源码,在 /home/mars/esp/esp-idf/components/esp_eth/include/esp_eth_mac.h 找到了 esp_eth_mac_new_esp32 的定义,但是被 CONFIG_ETH_USE_ESP32_EMAC 标签限制了,这个标签在 menuconfig 中找不到配置项,应该如何做?手动加入吗?

Who is online

Users browsing this forum: Google [Bot] and 121 guests