未验证 提交 7c9b837c 编写于 作者: S Steven Müllener 提交者: GitHub

Fix Reading MAC from efuse for ESP32 Arduino 2.x.x (#6458) (#6459)

Also support ESP_IDF_VERSION_MAJOR > 3
Fixes #6458
Co-authored-by: NRodrigo Garcia <rodrigo.garcia@espressif.com>
Co-authored-by: NMe No Dev <me-no-dev@users.noreply.github.com>
上级 5c5a112f
......@@ -226,12 +226,19 @@ ETHClass::ETHClass()
ETHClass::~ETHClass()
{}
bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_type_t type, eth_clock_mode_t clock_mode)
bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_type_t type, eth_clock_mode_t clock_mode, bool use_mac_from_efuse)
{
#if ESP_IDF_VERSION_MAJOR > 3
eth_clock_mode = clock_mode;
tcpipInit();
if (use_mac_from_efuse)
{
uint8_t p[6] = { 0x00,0x00,0x00,0x00,0x00,0x00 };
esp_efuse_mac_get_custom(p);
esp_base_mac_addr_set(p);
}
tcpip_adapter_set_default_eth_handlers();
esp_netif_config_t cfg = ESP_NETIF_DEFAULT_ETH();
......@@ -363,6 +370,14 @@ bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_typ
}
tcpipInit();
if (use_mac_from_efuse)
{
uint8_t p[6] = { 0x00,0x00,0x00,0x00,0x00,0x00 };
esp_efuse_mac_get_custom(p);
esp_base_mac_addr_set(p);
}
err = esp_eth_init(&eth_config);
if(!err){
initialized = true;
......
......@@ -75,7 +75,7 @@ class ETHClass {
ETHClass();
~ETHClass();
bool begin(uint8_t phy_addr=ETH_PHY_ADDR, int power=ETH_PHY_POWER, int mdc=ETH_PHY_MDC, int mdio=ETH_PHY_MDIO, eth_phy_type_t type=ETH_PHY_TYPE, eth_clock_mode_t clk_mode=ETH_CLK_MODE);
bool begin(uint8_t phy_addr=ETH_PHY_ADDR, int power=ETH_PHY_POWER, int mdc=ETH_PHY_MDC, int mdio=ETH_PHY_MDIO, eth_phy_type_t type=ETH_PHY_TYPE, eth_clock_mode_t clk_mode=ETH_CLK_MODE, bool use_mac_from_efuse=false);
bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = (uint32_t)0x00000000, IPAddress dns2 = (uint32_t)0x00000000);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册