mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 01:07:45 +01:00
openeth ethernet / qemu support (#7020)
This commit is contained in:
parent
1596a85e4f
commit
9699719305
5 changed files with 22 additions and 0 deletions
|
@ -59,6 +59,7 @@ ETHERNET_TYPES = {
|
||||||
"KSZ8081": EthernetType.ETHERNET_TYPE_KSZ8081,
|
"KSZ8081": EthernetType.ETHERNET_TYPE_KSZ8081,
|
||||||
"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,
|
||||||
}
|
}
|
||||||
|
|
||||||
SPI_ETHERNET_TYPES = ["W5500"]
|
SPI_ETHERNET_TYPES = ["W5500"]
|
||||||
|
@ -171,6 +172,7 @@ CONFIG_SCHEMA = cv.All(
|
||||||
"KSZ8081": RMII_SCHEMA,
|
"KSZ8081": RMII_SCHEMA,
|
||||||
"KSZ8081RNA": RMII_SCHEMA,
|
"KSZ8081RNA": RMII_SCHEMA,
|
||||||
"W5500": SPI_SCHEMA,
|
"W5500": SPI_SCHEMA,
|
||||||
|
"OPENETH": BASE_SCHEMA,
|
||||||
},
|
},
|
||||||
upper=True,
|
upper=True,
|
||||||
),
|
),
|
||||||
|
@ -240,6 +242,9 @@ async def to_code(config):
|
||||||
if CORE.using_esp_idf:
|
if CORE.using_esp_idf:
|
||||||
add_idf_sdkconfig_option("CONFIG_ETH_USE_SPI_ETHERNET", True)
|
add_idf_sdkconfig_option("CONFIG_ETH_USE_SPI_ETHERNET", True)
|
||||||
add_idf_sdkconfig_option("CONFIG_ETH_SPI_ETHERNET_W5500", 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:
|
else:
|
||||||
cg.add(var.set_phy_addr(config[CONF_PHY_ADDR]))
|
cg.add(var.set_phy_addr(config[CONF_PHY_ADDR]))
|
||||||
cg.add(var.set_mdc_pin(config[CONF_MDC_PIN]))
|
cg.add(var.set_mdc_pin(config[CONF_MDC_PIN]))
|
||||||
|
|
|
@ -120,6 +120,8 @@ void EthernetComponent::setup() {
|
||||||
phy_config.reset_gpio_num = this->reset_pin_;
|
phy_config.reset_gpio_num = this->reset_pin_;
|
||||||
|
|
||||||
esp_eth_mac_t *mac = esp_eth_mac_new_w5500(&w5500_config, &mac_config);
|
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
|
#else
|
||||||
phy_config.phy_addr = this->phy_addr_;
|
phy_config.phy_addr = this->phy_addr_;
|
||||||
phy_config.reset_gpio_num = this->power_pin_;
|
phy_config.reset_gpio_num = this->power_pin_;
|
||||||
|
@ -143,6 +145,13 @@ void EthernetComponent::setup() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (this->type_) {
|
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
|
#if CONFIG_ETH_USE_ESP32_EMAC
|
||||||
case ETHERNET_TYPE_LAN8720: {
|
case ETHERNET_TYPE_LAN8720: {
|
||||||
this->phy_ = esp_eth_phy_new_lan87xx(&phy_config);
|
this->phy_ = esp_eth_phy_new_lan87xx(&phy_config);
|
||||||
|
@ -302,6 +311,10 @@ void EthernetComponent::dump_config() {
|
||||||
eth_type = "W5500";
|
eth_type = "W5500";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ETHERNET_TYPE_OPENETH:
|
||||||
|
eth_type = "OPENETH";
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
eth_type = "Unknown";
|
eth_type = "Unknown";
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -25,6 +25,7 @@ enum EthernetType {
|
||||||
ETHERNET_TYPE_KSZ8081,
|
ETHERNET_TYPE_KSZ8081,
|
||||||
ETHERNET_TYPE_KSZ8081RNA,
|
ETHERNET_TYPE_KSZ8081RNA,
|
||||||
ETHERNET_TYPE_W5500,
|
ETHERNET_TYPE_W5500,
|
||||||
|
ETHERNET_TYPE_OPENETH,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ManualIP {
|
struct ManualIP {
|
||||||
|
|
2
tests/components/ethernet/common-openeth.yaml
Normal file
2
tests/components/ethernet/common-openeth.yaml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
ethernet:
|
||||||
|
type: OPENETH
|
1
tests/components/ethernet/test-openeth.esp32-idf.yaml
Normal file
1
tests/components/ethernet/test-openeth.esp32-idf.yaml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<<: !include common-openeth.yaml
|
Loading…
Reference in a new issue