mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 21:44:55 +01:00
Add KSZ8081 support. (#4668)
Co-authored-by: Your Name <you@example.com>
This commit is contained in:
parent
b5fbe0b145
commit
0547f2a931
3 changed files with 20 additions and 4 deletions
|
@ -34,6 +34,7 @@ ETHERNET_TYPES = {
|
|||
"DP83848": EthernetType.ETHERNET_TYPE_DP83848,
|
||||
"IP101": EthernetType.ETHERNET_TYPE_IP101,
|
||||
"JL1101": EthernetType.ETHERNET_TYPE_JL1101,
|
||||
"KSZ8081": EthernetType.ETHERNET_TYPE_KSZ8081,
|
||||
}
|
||||
|
||||
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);
|
||||
break;
|
||||
}
|
||||
case ETHERNET_TYPE_KSZ8081: {
|
||||
phy = esp_eth_phy_new_ksz8081(&phy_config);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
this->mark_failed();
|
||||
return;
|
||||
|
@ -140,7 +144,7 @@ void EthernetComponent::loop() {
|
|||
}
|
||||
|
||||
void EthernetComponent::dump_config() {
|
||||
std::string eth_type;
|
||||
const char *eth_type;
|
||||
switch (this->type_) {
|
||||
case ETHERNET_TYPE_LAN8720:
|
||||
eth_type = "LAN8720";
|
||||
|
@ -158,6 +162,14 @@ void EthernetComponent::dump_config() {
|
|||
eth_type = "IP101";
|
||||
break;
|
||||
|
||||
case ETHERNET_TYPE_JL1101:
|
||||
eth_type = "JL1101";
|
||||
break;
|
||||
|
||||
case ETHERNET_TYPE_KSZ8081:
|
||||
eth_type = "KSZ8081";
|
||||
break;
|
||||
|
||||
default:
|
||||
eth_type = "Unknown";
|
||||
break;
|
||||
|
@ -170,7 +182,8 @@ void EthernetComponent::dump_config() {
|
|||
}
|
||||
ESP_LOGCONFIG(TAG, " MDC Pin: %u", this->mdc_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; }
|
||||
|
|
|
@ -14,11 +14,13 @@ namespace esphome {
|
|||
namespace ethernet {
|
||||
|
||||
enum EthernetType {
|
||||
ETHERNET_TYPE_LAN8720 = 0,
|
||||
ETHERNET_TYPE_UNKNOWN = 0,
|
||||
ETHERNET_TYPE_LAN8720,
|
||||
ETHERNET_TYPE_RTL8201,
|
||||
ETHERNET_TYPE_DP83848,
|
||||
ETHERNET_TYPE_IP101,
|
||||
ETHERNET_TYPE_JL1101,
|
||||
ETHERNET_TYPE_KSZ8081,
|
||||
};
|
||||
|
||||
struct ManualIP {
|
||||
|
@ -69,7 +71,7 @@ class EthernetComponent : public Component {
|
|||
int power_pin_{-1};
|
||||
uint8_t mdc_pin_{23};
|
||||
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_gpio_t clk_gpio_{EMAC_CLK_IN_GPIO};
|
||||
optional<ManualIP> manual_ip_{};
|
||||
|
|
Loading…
Reference in a new issue