implement fix C++ invalid type conversion error in esp_eth_mac_esp.h for IDF 5.3.0 and 5.3.1

Signed-off-by: Viacheslav Bocharov <adeep@lexina.in>
This commit is contained in:
Viacheslav Bocharov 2024-09-27 10:36:36 +03:00
parent f5442fa7d4
commit ba753d550f
No known key found for this signature in database
GPG key ID: 476858332E6951A5

View file

@ -127,14 +127,34 @@ void EthernetComponent::setup() {
phy_config.reset_gpio_num = this->power_pin_; phy_config.reset_gpio_num = this->power_pin_;
#if ESP_IDF_VERSION_MAJOR >= 5 #if ESP_IDF_VERSION_MAJOR >= 5
#if ESP_IDF_VERSION_MINOR >= 3 && ESP_IDF_VERSION_PATCH < 2
// fix https://github.com/espressif/esp-idf/commit/e9df36a2dfe9ee074f421aedaff8952a348b339d
// for v5.3.0 and v5.3.1
eth_esp32_emac_config_t esp32_emac_config = {
.smi_gpio = {.mdc_num = this->mdc_pin_, .mdio_num = this->mdio_pin_},
.interface = EMAC_DATA_INTERFACE_RMII,
.clock_config = {.rmii =
{
.clock_mode = this->clk_mode_,
.clock_gpio = this->clk_gpio_,
}},
.dma_burst_len = ETH_DMA_BURST_LEN_32,
.intr_priority = 0,
};
#else // ESP_IDF_VERSION_MINOR >= 3 && ESP_IDF_VERSION_PATCH > 2
eth_esp32_emac_config_t esp32_emac_config = ETH_ESP32_EMAC_DEFAULT_CONFIG(); eth_esp32_emac_config_t esp32_emac_config = ETH_ESP32_EMAC_DEFAULT_CONFIG();
#if ESP_IDF_VERSION_MINOR >= 3
esp32_emac_config.smi_gpio = {.mdc_num = this->mdc_pin_, .mdio_num = this->mdio_pin_};
#else // ESP_IDF_VERSION_MINOR < 3
esp32_emac_config.smi_mdc_gpio_num = this->mdc_pin_; esp32_emac_config.smi_mdc_gpio_num = this->mdc_pin_;
esp32_emac_config.smi_mdio_gpio_num = this->mdio_pin_; esp32_emac_config.smi_mdio_gpio_num = this->mdio_pin_;
#endif
esp32_emac_config.clock_config.rmii.clock_mode = this->clk_mode_; esp32_emac_config.clock_config.rmii.clock_mode = this->clk_mode_;
esp32_emac_config.clock_config.rmii.clock_gpio = this->clk_gpio_; esp32_emac_config.clock_config.rmii.clock_gpio = this->clk_gpio_;
#endif
esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&esp32_emac_config, &mac_config); esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&esp32_emac_config, &mac_config);
#else #else // ESP_IDF_VERSION_MAJOR < 5
mac_config.smi_mdc_gpio_num = this->mdc_pin_; mac_config.smi_mdc_gpio_num = this->mdc_pin_;
mac_config.smi_mdio_gpio_num = this->mdio_pin_; mac_config.smi_mdio_gpio_num = this->mdio_pin_;
mac_config.clock_config.rmii.clock_mode = this->clk_mode_; mac_config.clock_config.rmii.clock_mode = this->clk_mode_;