mirror of
https://github.com/esphome/esphome.git
synced 2025-01-31 10:10:56 +00:00
Add KSZ8081 support. (#4668)
Co-authored-by: Your Name <you@example.com>
This commit is contained in:
parent
b5fbe0b145
commit
0547f2a931
@ -34,6 +34,7 @@ ETHERNET_TYPES = {
|
|||||||
"DP83848": EthernetType.ETHERNET_TYPE_DP83848,
|
"DP83848": EthernetType.ETHERNET_TYPE_DP83848,
|
||||||
"IP101": EthernetType.ETHERNET_TYPE_IP101,
|
"IP101": EthernetType.ETHERNET_TYPE_IP101,
|
||||||
"JL1101": EthernetType.ETHERNET_TYPE_JL1101,
|
"JL1101": EthernetType.ETHERNET_TYPE_JL1101,
|
||||||
|
"KSZ8081": EthernetType.ETHERNET_TYPE_KSZ8081,
|
||||||
}
|
}
|
||||||
|
|
||||||
emac_rmii_clock_mode_t = cg.global_ns.enum("emac_rmii_clock_mode_t")
|
emac_rmii_clock_mode_t = cg.global_ns.enum("emac_rmii_clock_mode_t")
|
||||||
|
@ -74,6 +74,10 @@ void EthernetComponent::setup() {
|
|||||||
phy = esp_eth_phy_new_jl1101(&phy_config);
|
phy = esp_eth_phy_new_jl1101(&phy_config);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ETHERNET_TYPE_KSZ8081: {
|
||||||
|
phy = esp_eth_phy_new_ksz8081(&phy_config);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
this->mark_failed();
|
this->mark_failed();
|
||||||
return;
|
return;
|
||||||
@ -140,7 +144,7 @@ void EthernetComponent::loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EthernetComponent::dump_config() {
|
void EthernetComponent::dump_config() {
|
||||||
std::string eth_type;
|
const char *eth_type;
|
||||||
switch (this->type_) {
|
switch (this->type_) {
|
||||||
case ETHERNET_TYPE_LAN8720:
|
case ETHERNET_TYPE_LAN8720:
|
||||||
eth_type = "LAN8720";
|
eth_type = "LAN8720";
|
||||||
@ -158,6 +162,14 @@ void EthernetComponent::dump_config() {
|
|||||||
eth_type = "IP101";
|
eth_type = "IP101";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ETHERNET_TYPE_JL1101:
|
||||||
|
eth_type = "JL1101";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ETHERNET_TYPE_KSZ8081:
|
||||||
|
eth_type = "KSZ8081";
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
eth_type = "Unknown";
|
eth_type = "Unknown";
|
||||||
break;
|
break;
|
||||||
@ -170,7 +182,8 @@ void EthernetComponent::dump_config() {
|
|||||||
}
|
}
|
||||||
ESP_LOGCONFIG(TAG, " MDC Pin: %u", this->mdc_pin_);
|
ESP_LOGCONFIG(TAG, " MDC Pin: %u", this->mdc_pin_);
|
||||||
ESP_LOGCONFIG(TAG, " MDIO Pin: %u", this->mdio_pin_);
|
ESP_LOGCONFIG(TAG, " MDIO Pin: %u", this->mdio_pin_);
|
||||||
ESP_LOGCONFIG(TAG, " Type: %s", eth_type.c_str());
|
ESP_LOGCONFIG(TAG, " Type: %s", eth_type);
|
||||||
|
ESP_LOGCONFIG(TAG, " PHY addr: %u", this->phy_addr_);
|
||||||
}
|
}
|
||||||
|
|
||||||
float EthernetComponent::get_setup_priority() const { return setup_priority::WIFI; }
|
float EthernetComponent::get_setup_priority() const { return setup_priority::WIFI; }
|
||||||
|
@ -14,11 +14,13 @@ namespace esphome {
|
|||||||
namespace ethernet {
|
namespace ethernet {
|
||||||
|
|
||||||
enum EthernetType {
|
enum EthernetType {
|
||||||
ETHERNET_TYPE_LAN8720 = 0,
|
ETHERNET_TYPE_UNKNOWN = 0,
|
||||||
|
ETHERNET_TYPE_LAN8720,
|
||||||
ETHERNET_TYPE_RTL8201,
|
ETHERNET_TYPE_RTL8201,
|
||||||
ETHERNET_TYPE_DP83848,
|
ETHERNET_TYPE_DP83848,
|
||||||
ETHERNET_TYPE_IP101,
|
ETHERNET_TYPE_IP101,
|
||||||
ETHERNET_TYPE_JL1101,
|
ETHERNET_TYPE_JL1101,
|
||||||
|
ETHERNET_TYPE_KSZ8081,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ManualIP {
|
struct ManualIP {
|
||||||
@ -69,7 +71,7 @@ class EthernetComponent : public Component {
|
|||||||
int power_pin_{-1};
|
int power_pin_{-1};
|
||||||
uint8_t mdc_pin_{23};
|
uint8_t mdc_pin_{23};
|
||||||
uint8_t mdio_pin_{18};
|
uint8_t mdio_pin_{18};
|
||||||
EthernetType type_{ETHERNET_TYPE_LAN8720};
|
EthernetType type_{ETHERNET_TYPE_UNKNOWN};
|
||||||
emac_rmii_clock_mode_t clk_mode_{EMAC_CLK_EXT_IN};
|
emac_rmii_clock_mode_t clk_mode_{EMAC_CLK_EXT_IN};
|
||||||
emac_rmii_clock_gpio_t clk_gpio_{EMAC_CLK_IN_GPIO};
|
emac_rmii_clock_gpio_t clk_gpio_{EMAC_CLK_IN_GPIO};
|
||||||
optional<ManualIP> manual_ip_{};
|
optional<ManualIP> manual_ip_{};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user