mirror of
https://github.com/esphome/esphome.git
synced 2024-11-30 10:44:13 +01:00
openeth
This commit is contained in:
parent
e9cf3623d1
commit
58b4bb0447
3 changed files with 23 additions and 1 deletions
|
@ -59,6 +59,7 @@ ETHERNET_TYPES = {
|
|||
"KSZ8081": EthernetType.ETHERNET_TYPE_KSZ8081,
|
||||
"KSZ8081RNA": EthernetType.ETHERNET_TYPE_KSZ8081RNA,
|
||||
"W5500": EthernetType.ETHERNET_TYPE_W5500,
|
||||
"OPENETH": EthernetType.ETHERNET_TYPE_OPENETH,
|
||||
}
|
||||
|
||||
SPI_ETHERNET_TYPES = ["W5500"]
|
||||
|
@ -171,6 +172,7 @@ CONFIG_SCHEMA = cv.All(
|
|||
"KSZ8081": RMII_SCHEMA,
|
||||
"KSZ8081RNA": RMII_SCHEMA,
|
||||
"W5500": SPI_SCHEMA,
|
||||
"OPENETH": BASE_SCHEMA,
|
||||
},
|
||||
upper=True,
|
||||
),
|
||||
|
@ -240,6 +242,9 @@ async def to_code(config):
|
|||
if CORE.using_esp_idf:
|
||||
add_idf_sdkconfig_option("CONFIG_ETH_USE_SPI_ETHERNET", True)
|
||||
add_idf_sdkconfig_option("CONFIG_ETH_SPI_ETHERNET_W5500", True)
|
||||
elif config[CONF_TYPE] == "OPENETH":
|
||||
cg.add_define("USE_ETHERNET_OPENETH")
|
||||
add_idf_sdkconfig_option("CONFIG_ETH_USE_OPENETH", True)
|
||||
else:
|
||||
cg.add(var.set_phy_addr(config[CONF_PHY_ADDR]))
|
||||
cg.add(var.set_mdc_pin(config[CONF_MDC_PIN]))
|
||||
|
|
|
@ -119,6 +119,8 @@ void EthernetComponent::setup() {
|
|||
phy_config.reset_gpio_num = this->reset_pin_;
|
||||
|
||||
esp_eth_mac_t *mac = esp_eth_mac_new_w5500(&w5500_config, &mac_config);
|
||||
#elif defined(USE_ETHERNET_OPENETH)
|
||||
esp_eth_mac_t *mac = esp_eth_mac_new_openeth(&mac_config);
|
||||
#else
|
||||
phy_config.phy_addr = this->phy_addr_;
|
||||
phy_config.reset_gpio_num = this->power_pin_;
|
||||
|
@ -130,7 +132,8 @@ void EthernetComponent::setup() {
|
|||
esp32_emac_config.clock_config.rmii.clock_mode = this->clk_mode_;
|
||||
esp32_emac_config.clock_config.rmii.clock_gpio = this->clk_gpio_;
|
||||
|
||||
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(&mac_config);
|
||||
|
||||
#else
|
||||
mac_config.smi_mdc_gpio_num = this->mdc_pin_;
|
||||
mac_config.smi_mdio_gpio_num = this->mdio_pin_;
|
||||
|
@ -138,10 +141,19 @@ void EthernetComponent::setup() {
|
|||
mac_config.clock_config.rmii.clock_gpio = this->clk_gpio_;
|
||||
|
||||
esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&mac_config);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
switch (this->type_) {
|
||||
#ifdef USE_ETHERNET_OPENETH
|
||||
case ETHERNET_TYPE_OPENETH: {
|
||||
phy_config.autonego_timeout_ms = 1000;
|
||||
this->phy_ = esp_eth_phy_new_dp83848(&phy_config);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#if CONFIG_ETH_USE_ESP32_EMAC
|
||||
case ETHERNET_TYPE_LAN8720: {
|
||||
this->phy_ = esp_eth_phy_new_lan87xx(&phy_config);
|
||||
|
@ -301,6 +313,10 @@ void EthernetComponent::dump_config() {
|
|||
eth_type = "W5500";
|
||||
break;
|
||||
|
||||
case ETHERNET_TYPE_OPENETH:
|
||||
eth_type = "OPENETH";
|
||||
break;
|
||||
|
||||
default:
|
||||
eth_type = "Unknown";
|
||||
break;
|
||||
|
|
|
@ -25,6 +25,7 @@ enum EthernetType {
|
|||
ETHERNET_TYPE_KSZ8081,
|
||||
ETHERNET_TYPE_KSZ8081RNA,
|
||||
ETHERNET_TYPE_W5500,
|
||||
ETHERNET_TYPE_OPENETH,
|
||||
};
|
||||
|
||||
struct ManualIP {
|
||||
|
|
Loading…
Reference in a new issue