mirror of
https://github.com/esphome/esphome.git
synced 2025-02-27 15:28:29 +00:00
Add support for lan867x Microchip 10BASE-T1S Single Pair Ethernet PHY via espressif
esp-eth-drivers component for IDF>=5.3.0 Signed-off-by: Viacheslav Bocharov <adeep@lexina.in>
This commit is contained in:
parent
9e40d4cf45
commit
cfcb8e9d46
@ -1,7 +1,12 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from esphome import pins
|
from esphome import pins
|
||||||
import esphome.codegen as cg
|
import esphome.codegen as cg
|
||||||
from esphome.components.esp32 import add_idf_sdkconfig_option, get_esp32_variant
|
from esphome.components.esp32 import (
|
||||||
|
add_idf_component,
|
||||||
|
add_idf_sdkconfig_option,
|
||||||
|
get_esp32_variant,
|
||||||
|
)
|
||||||
from esphome.components.esp32.const import (
|
from esphome.components.esp32.const import (
|
||||||
VARIANT_ESP32C3,
|
VARIANT_ESP32C3,
|
||||||
VARIANT_ESP32S2,
|
VARIANT_ESP32S2,
|
||||||
@ -65,6 +70,7 @@ ETHERNET_TYPES = {
|
|||||||
"KSZ8081RNA": EthernetType.ETHERNET_TYPE_KSZ8081RNA,
|
"KSZ8081RNA": EthernetType.ETHERNET_TYPE_KSZ8081RNA,
|
||||||
"W5500": EthernetType.ETHERNET_TYPE_W5500,
|
"W5500": EthernetType.ETHERNET_TYPE_W5500,
|
||||||
"OPENETH": EthernetType.ETHERNET_TYPE_OPENETH,
|
"OPENETH": EthernetType.ETHERNET_TYPE_OPENETH,
|
||||||
|
"LAN867X": EthernetType.ETHERNET_TYPE_LAN867X,
|
||||||
}
|
}
|
||||||
|
|
||||||
SPI_ETHERNET_TYPES = ["W5500"]
|
SPI_ETHERNET_TYPES = ["W5500"]
|
||||||
@ -131,6 +137,9 @@ def _validate(config):
|
|||||||
else:
|
else:
|
||||||
use_address = CORE.name + config[CONF_DOMAIN]
|
use_address = CORE.name + config[CONF_DOMAIN]
|
||||||
config[CONF_USE_ADDRESS] = use_address
|
config[CONF_USE_ADDRESS] = use_address
|
||||||
|
if config.get(CONF_TYPE) == "LAN867X":
|
||||||
|
validator = cv.require_framework_version(esp_idf=cv.Version(5, 3, 0))
|
||||||
|
validator(config)
|
||||||
if config[CONF_TYPE] in SPI_ETHERNET_TYPES:
|
if config[CONF_TYPE] in SPI_ETHERNET_TYPES:
|
||||||
if _is_framework_spi_polling_mode_supported():
|
if _is_framework_spi_polling_mode_supported():
|
||||||
if CONF_POLLING_INTERVAL in config and CONF_INTERRUPT_PIN in config:
|
if CONF_POLLING_INTERVAL in config and CONF_INTERRUPT_PIN in config:
|
||||||
@ -175,6 +184,7 @@ PHY_REGISTER_SCHEMA = cv.Schema(
|
|||||||
cv.Optional(CONF_PAGE_ID): cv.hex_int,
|
cv.Optional(CONF_PAGE_ID): cv.hex_int,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
RMII_SCHEMA = BASE_SCHEMA.extend(
|
RMII_SCHEMA = BASE_SCHEMA.extend(
|
||||||
cv.Schema(
|
cv.Schema(
|
||||||
{
|
{
|
||||||
@ -221,6 +231,7 @@ CONFIG_SCHEMA = cv.All(
|
|||||||
"JL1101": RMII_SCHEMA,
|
"JL1101": RMII_SCHEMA,
|
||||||
"KSZ8081": RMII_SCHEMA,
|
"KSZ8081": RMII_SCHEMA,
|
||||||
"KSZ8081RNA": RMII_SCHEMA,
|
"KSZ8081RNA": RMII_SCHEMA,
|
||||||
|
"LAN867X": RMII_SCHEMA,
|
||||||
"W5500": SPI_SCHEMA,
|
"W5500": SPI_SCHEMA,
|
||||||
"OPENETH": BASE_SCHEMA,
|
"OPENETH": BASE_SCHEMA,
|
||||||
},
|
},
|
||||||
@ -277,6 +288,17 @@ async def to_code(config):
|
|||||||
var = cg.new_Pvariable(config[CONF_ID])
|
var = cg.new_Pvariable(config[CONF_ID])
|
||||||
await cg.register_component(var, config)
|
await cg.register_component(var, config)
|
||||||
|
|
||||||
|
if config[CONF_TYPE] == "LAN867X":
|
||||||
|
add_idf_component(
|
||||||
|
name="esp-eth-drivers",
|
||||||
|
repo="https://github.com/espressif/esp-eth-drivers.git",
|
||||||
|
ref="master",
|
||||||
|
path="lan867x",
|
||||||
|
)
|
||||||
|
add_idf_sdkconfig_option("CONFIG_GPIO_CTRL_FUNC_IN_IRAM", True)
|
||||||
|
add_idf_sdkconfig_option("CONFIG_ETHERNET_INTERNAL_SUPPORT", True)
|
||||||
|
add_idf_sdkconfig_option("CONFIG_ETHERNET_PHY_LAN867X", True)
|
||||||
|
|
||||||
if config[CONF_TYPE] == "W5500":
|
if config[CONF_TYPE] == "W5500":
|
||||||
cg.add(var.set_clk_pin(config[CONF_CLK_PIN]))
|
cg.add(var.set_clk_pin(config[CONF_CLK_PIN]))
|
||||||
cg.add(var.set_miso_pin(config[CONF_MISO_PIN]))
|
cg.add(var.set_miso_pin(config[CONF_MISO_PIN]))
|
||||||
|
@ -191,6 +191,12 @@ void EthernetComponent::setup() {
|
|||||||
this->phy_ = esp_eth_phy_new_w5500(&phy_config);
|
this->phy_ = esp_eth_phy_new_w5500(&phy_config);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#if ESP_IDF_VERSION_MAJOR >= 5 && ESP_IDF_VERSION_MINOR >= 3
|
||||||
|
case ETHERNET_TYPE_LAN867X: {
|
||||||
|
this->phy_ = esp_eth_phy_new_lan867x(&phy_config);
|
||||||
|
break;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
default: {
|
default: {
|
||||||
this->mark_failed();
|
this->mark_failed();
|
||||||
@ -318,6 +324,10 @@ void EthernetComponent::dump_config() {
|
|||||||
eth_type = "OPENETH";
|
eth_type = "OPENETH";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ETHERNET_TYPE_LAN867X:
|
||||||
|
eth_type = "LAN867X";
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
eth_type = "Unknown";
|
eth_type = "Unknown";
|
||||||
break;
|
break;
|
||||||
|
@ -12,6 +12,10 @@
|
|||||||
#include "esp_netif.h"
|
#include "esp_netif.h"
|
||||||
#include "esp_mac.h"
|
#include "esp_mac.h"
|
||||||
|
|
||||||
|
#if ESP_IDF_VERSION_MAJOR >= 5 && ESP_IDF_VERSION_MINOR >= 3
|
||||||
|
#include "esp_eth_phy_lan867x.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace ethernet {
|
namespace ethernet {
|
||||||
|
|
||||||
@ -26,6 +30,7 @@ enum EthernetType {
|
|||||||
ETHERNET_TYPE_KSZ8081RNA,
|
ETHERNET_TYPE_KSZ8081RNA,
|
||||||
ETHERNET_TYPE_W5500,
|
ETHERNET_TYPE_W5500,
|
||||||
ETHERNET_TYPE_OPENETH,
|
ETHERNET_TYPE_OPENETH,
|
||||||
|
ETHERNET_TYPE_LAN867X,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ManualIP {
|
struct ManualIP {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user