mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 12:37:45 +01:00
Fix ethernet clk_mode for GPIO0_OUT (#4307)
* Fix GPIO0_OUT definition for ethernet component * Formatting --------- Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
parent
4f138c600b
commit
c12dd77c64
@ -36,12 +36,25 @@ ETHERNET_TYPES = {
|
||||
"JL1101": EthernetType.ETHERNET_TYPE_JL1101,
|
||||
}
|
||||
|
||||
emac_rmii_clock_mode_t = cg.global_ns.enum("emac_rmii_clock_mode_t")
|
||||
emac_rmii_clock_gpio_t = cg.global_ns.enum("emac_rmii_clock_gpio_t")
|
||||
CLK_MODES = {
|
||||
"GPIO0_IN": emac_rmii_clock_gpio_t.EMAC_CLK_IN_GPIO,
|
||||
"GPIO0_OUT": emac_rmii_clock_gpio_t.EMAC_APPL_CLK_OUT_GPIO,
|
||||
"GPIO16_OUT": emac_rmii_clock_gpio_t.EMAC_CLK_OUT_GPIO,
|
||||
"GPIO17_OUT": emac_rmii_clock_gpio_t.EMAC_CLK_OUT_180_GPIO,
|
||||
"GPIO0_IN": (
|
||||
emac_rmii_clock_mode_t.EMAC_CLK_EXT_IN,
|
||||
emac_rmii_clock_gpio_t.EMAC_CLK_IN_GPIO,
|
||||
),
|
||||
"GPIO0_OUT": (
|
||||
emac_rmii_clock_mode_t.EMAC_CLK_OUT,
|
||||
emac_rmii_clock_gpio_t.EMAC_APPL_CLK_OUT_GPIO,
|
||||
),
|
||||
"GPIO16_OUT": (
|
||||
emac_rmii_clock_mode_t.EMAC_CLK_OUT,
|
||||
emac_rmii_clock_gpio_t.EMAC_CLK_OUT_GPIO,
|
||||
),
|
||||
"GPIO17_OUT": (
|
||||
emac_rmii_clock_mode_t.EMAC_CLK_OUT,
|
||||
emac_rmii_clock_gpio_t.EMAC_CLK_OUT_180_GPIO,
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
@ -114,7 +127,7 @@ async def to_code(config):
|
||||
cg.add(var.set_mdc_pin(config[CONF_MDC_PIN]))
|
||||
cg.add(var.set_mdio_pin(config[CONF_MDIO_PIN]))
|
||||
cg.add(var.set_type(config[CONF_TYPE]))
|
||||
cg.add(var.set_clk_mode(CLK_MODES[config[CONF_CLK_MODE]]))
|
||||
cg.add(var.set_clk_mode(*CLK_MODES[config[CONF_CLK_MODE]]))
|
||||
cg.add(var.set_use_address(config[CONF_USE_ADDRESS]))
|
||||
|
||||
if CONF_POWER_PIN in config:
|
||||
|
@ -47,8 +47,8 @@ void EthernetComponent::setup() {
|
||||
|
||||
mac_config.smi_mdc_gpio_num = this->mdc_pin_;
|
||||
mac_config.smi_mdio_gpio_num = this->mdio_pin_;
|
||||
mac_config.clock_config.rmii.clock_mode = this->clk_mode_ == EMAC_CLK_IN_GPIO ? EMAC_CLK_EXT_IN : EMAC_CLK_OUT;
|
||||
mac_config.clock_config.rmii.clock_gpio = this->clk_mode_;
|
||||
mac_config.clock_config.rmii.clock_mode = this->clk_mode_;
|
||||
mac_config.clock_config.rmii.clock_gpio = this->clk_gpio_;
|
||||
|
||||
esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&mac_config);
|
||||
|
||||
@ -315,7 +315,10 @@ void EthernetComponent::set_power_pin(int power_pin) { this->power_pin_ = power_
|
||||
void EthernetComponent::set_mdc_pin(uint8_t mdc_pin) { this->mdc_pin_ = mdc_pin; }
|
||||
void EthernetComponent::set_mdio_pin(uint8_t mdio_pin) { this->mdio_pin_ = mdio_pin; }
|
||||
void EthernetComponent::set_type(EthernetType type) { this->type_ = type; }
|
||||
void EthernetComponent::set_clk_mode(emac_rmii_clock_gpio_t clk_mode) { this->clk_mode_ = clk_mode; }
|
||||
void EthernetComponent::set_clk_mode(emac_rmii_clock_mode_t clk_mode, emac_rmii_clock_gpio_t clk_gpio) {
|
||||
this->clk_mode_ = clk_mode;
|
||||
this->clk_gpio_ = clk_gpio;
|
||||
}
|
||||
void EthernetComponent::set_manual_ip(const ManualIP &manual_ip) { this->manual_ip_ = manual_ip; }
|
||||
|
||||
std::string EthernetComponent::get_use_address() const {
|
||||
|
@ -50,7 +50,7 @@ class EthernetComponent : public Component {
|
||||
void set_mdc_pin(uint8_t mdc_pin);
|
||||
void set_mdio_pin(uint8_t mdio_pin);
|
||||
void set_type(EthernetType type);
|
||||
void set_clk_mode(emac_rmii_clock_gpio_t clk_mode);
|
||||
void set_clk_mode(emac_rmii_clock_mode_t clk_mode, emac_rmii_clock_gpio_t clk_gpio);
|
||||
void set_manual_ip(const ManualIP &manual_ip);
|
||||
|
||||
network::IPAddress get_ip_address();
|
||||
@ -70,7 +70,8 @@ class EthernetComponent : public Component {
|
||||
uint8_t mdc_pin_{23};
|
||||
uint8_t mdio_pin_{18};
|
||||
EthernetType type_{ETHERNET_TYPE_LAN8720};
|
||||
emac_rmii_clock_gpio_t clk_mode_{EMAC_CLK_IN_GPIO};
|
||||
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_{};
|
||||
|
||||
bool started_{false};
|
||||
|
Loading…
Reference in New Issue
Block a user