Skip to content

Commit

Permalink
Add ethernet component support for lan867x
Browse files Browse the repository at this point in the history
Microchip 10BASE-T1S Single Pair Ethernet PHY for ESP IDF >= 5
  • Loading branch information
adeepn committed Dec 12, 2023
1 parent cc7d167 commit e26bd2e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions esphome/components/ethernet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"JL1101": EthernetType.ETHERNET_TYPE_JL1101,
"KSZ8081": EthernetType.ETHERNET_TYPE_KSZ8081,
"KSZ8081RNA": EthernetType.ETHERNET_TYPE_KSZ8081RNA,
"LAN867X": EthernetType.ETHERNET_TYPE_LAN867X,
}

emac_rmii_clock_mode_t = cg.global_ns.enum("emac_rmii_clock_mode_t")
Expand Down
14 changes: 14 additions & 0 deletions esphome/components/ethernet/ethernet_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ void EthernetComponent::setup() {
this->phy_ = esp_eth_phy_new_lan87xx(&phy_config);
break;
}
#if ESP_IDF_VERSION_MAJOR >= 5
case ETHERNET_TYPE_LAN867X: {
this->phy_ = esp_eth_phy_new_lan867x(&phy_config);
break;
}
#endif
case ETHERNET_TYPE_RTL8201: {
this->phy_ = esp_eth_phy_new_rtl8201(&phy_config);
break;
Expand Down Expand Up @@ -102,6 +108,8 @@ void EthernetComponent::setup() {

esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(mac, this->phy_);
this->eth_handle_ = nullptr;

ESP_LOGCONFIG(TAG, "Setting up Ethernet... pre install driver");
err = esp_eth_driver_install(&eth_config, &this->eth_handle_);
ESPHL_ERROR_CHECK(err, "ETH driver install error");

Expand Down Expand Up @@ -190,6 +198,12 @@ void EthernetComponent::dump_config() {
eth_type = "LAN8720";
break;

#if ESP_IDF_VERSION_MAJOR >= 5
case ETHERNET_TYPE_LAN867X:
eth_type = "LAN867X";
break;
#endif

case ETHERNET_TYPE_RTL8201:
eth_type = "RTL8201";
break;
Expand Down
7 changes: 7 additions & 0 deletions esphome/components/ethernet/ethernet_component.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ enum EthernetType {
ETHERNET_TYPE_JL1101,
ETHERNET_TYPE_KSZ8081,
ETHERNET_TYPE_KSZ8081RNA,
#if ESP_IDF_VERSION_MAJOR >= 5
ETHERNET_TYPE_LAN867X,
#endif
};

struct ManualIP {
Expand Down Expand Up @@ -102,6 +105,10 @@ class EthernetComponent : public Component {
extern EthernetComponent *global_eth_component;
extern "C" esp_eth_phy_t *esp_eth_phy_new_jl1101(const eth_phy_config_t *config);

#if ESP_IDF_VERSION_MAJOR >= 5
extern "C" esp_eth_phy_t *esp_eth_phy_new_lan867x(const eth_phy_config_t *config);
#endif

} // namespace ethernet
} // namespace esphome

Expand Down

0 comments on commit e26bd2e

Please sign in to comment.