mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-12 18:59:51 +03:00
allow uart0 pin for eth (check eth first) #2794
This commit is contained in:
@@ -375,6 +375,7 @@ void System::syslog_init() {
|
|||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
if (syslog_enabled_) {
|
if (syslog_enabled_) {
|
||||||
// start & configure syslog
|
// start & configure syslog
|
||||||
|
syslog_.maximum_log_messages(10);
|
||||||
syslog_.log_level((uuid::log::Level)syslog_level_);
|
syslog_.log_level((uuid::log::Level)syslog_level_);
|
||||||
syslog_.mark_interval(syslog_mark_interval_);
|
syslog_.mark_interval(syslog_mark_interval_);
|
||||||
syslog_.destination(syslog_host_.c_str(), syslog_port_);
|
syslog_.destination(syslog_host_.c_str(), syslog_port_);
|
||||||
@@ -2338,19 +2339,17 @@ void System::set_valid_system_gpios() {
|
|||||||
// 38 and 39 are input only
|
// 38 and 39 are input only
|
||||||
// 45 and 36 are strapping pins, input only
|
// 45 and 36 are strapping pins, input only
|
||||||
valid_system_gpios_ = string_range_to_vector("0-14, 17, 18, 21, 33-39, 45, 46");
|
valid_system_gpios_ = string_range_to_vector("0-14, 17, 18, 21, 33-39, 45, 46");
|
||||||
#elif CONFIG_IDF_TARGET_ESP32 || defined(EMSESP_STANDALONE)
|
#elif CONFIG_IDF_TARGET_ESP32
|
||||||
// 1 and 3 are UART0 pins
|
// 1 and 3 are UART0 pins, but used for some eth-boards (BBQKees-E32, OlimexPOE)
|
||||||
// 32-39 is ADC1, input only
|
// 32-39 is ADC1, input only
|
||||||
valid_system_gpios_ = string_range_to_vector("0, 2, 4, 5, 12-19, 23, 25-27, 32-39");
|
|
||||||
#else
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// if psram is enabled remove pins 16 and 17 from the list, if set
|
|
||||||
#if CONFIG_IDF_TARGET_ESP32
|
|
||||||
if (ESP.getPsramSize() > 0) {
|
if (ESP.getPsramSize() > 0) {
|
||||||
valid_system_gpios_.erase(std::remove(valid_system_gpios_.begin(), valid_system_gpios_.end(), 16), valid_system_gpios_.end());
|
// if psram is enabled remove pins 16 and 17 from the list
|
||||||
valid_system_gpios_.erase(std::remove(valid_system_gpios_.begin(), valid_system_gpios_.end(), 17), valid_system_gpios_.end());
|
valid_system_gpios_ = string_range_to_vector("0-5, 12-15, 18-19, 23, 25-27, 32-39");
|
||||||
|
} else {
|
||||||
|
valid_system_gpios_ = string_range_to_vector("0-5, 12-19, 23, 25-27, 32-39");
|
||||||
}
|
}
|
||||||
|
#elif defined(EMSESP_STANDALONE)
|
||||||
|
valid_system_gpios_ = string_range_to_vector("0-5, 12-19, 23, 25-27, 32-39");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -123,6 +123,30 @@ StateUpdateResult WebSettings::update(JsonObject root, WebSettings & settings) {
|
|||||||
add_flags(ChangeFlags::RESTART);
|
add_flags(ChangeFlags::RESTART);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_flag(original_settings.phy_type, settings.phy_type, ChangeFlags::RESTART);
|
||||||
|
// ETH has changed, so we need to check the ethernet pins. Only if ETH is being used.
|
||||||
|
if (settings.phy_type != PHY_type::PHY_TYPE_NONE) {
|
||||||
|
check_flag(original_settings.eth_power, settings.eth_power, ChangeFlags::RESTART);
|
||||||
|
check_flag(original_settings.eth_clock_mode, settings.eth_clock_mode, ChangeFlags::RESTART);
|
||||||
|
if (settings.eth_power != -1) { // Ethernet Power -1 means disabled
|
||||||
|
EMSESP::system_.remove_gpio(settings.eth_power, true);
|
||||||
|
}
|
||||||
|
// remove the ethernet pins from valid list, regardless of whether the GPIOs are valid or not
|
||||||
|
EMSESP::system_.remove_gpio(23, true); // MDC
|
||||||
|
EMSESP::system_.remove_gpio(18, true); // MDIO
|
||||||
|
if (settings.eth_clock_mode < 2) {
|
||||||
|
EMSESP::system_.remove_gpio(0, true); // ETH.clock input
|
||||||
|
} else if (settings.eth_clock_mode == 2) {
|
||||||
|
EMSESP::system_.remove_gpio(16, true); // ETH.clock output
|
||||||
|
} else if (settings.eth_clock_mode == 3) {
|
||||||
|
EMSESP::system_.remove_gpio(17, true); // ETH.clock output
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#if CONFIG_IDF_TARGET_ESP32
|
||||||
|
// Uart0 pins not allowed for all other gpio
|
||||||
|
EMSESP::system_.remove_gpio(1, true);
|
||||||
|
EMSESP::system_.remove_gpio(3, true);
|
||||||
|
#endif
|
||||||
// if any of the GPIOs have changed and re-validate them
|
// if any of the GPIOs have changed and re-validate them
|
||||||
bool have_valid_gpios = true;
|
bool have_valid_gpios = true;
|
||||||
|
|
||||||
@@ -155,26 +179,6 @@ StateUpdateResult WebSettings::update(JsonObject root, WebSettings & settings) {
|
|||||||
check_flag(original_settings.pbutton_gpio, settings.pbutton_gpio, ChangeFlags::BUTTON);
|
check_flag(original_settings.pbutton_gpio, settings.pbutton_gpio, ChangeFlags::BUTTON);
|
||||||
have_valid_gpios = have_valid_gpios && EMSESP::system_.add_gpio(settings.pbutton_gpio, "Button");
|
have_valid_gpios = have_valid_gpios && EMSESP::system_.add_gpio(settings.pbutton_gpio, "Button");
|
||||||
|
|
||||||
check_flag(original_settings.phy_type, settings.phy_type, ChangeFlags::RESTART);
|
|
||||||
// ETH has changed, so we need to check the ethernet pins. Only if ETH is being used.
|
|
||||||
if (settings.phy_type != PHY_type::PHY_TYPE_NONE) {
|
|
||||||
check_flag(original_settings.eth_power, settings.eth_power, ChangeFlags::RESTART);
|
|
||||||
check_flag(original_settings.eth_clock_mode, settings.eth_clock_mode, ChangeFlags::RESTART);
|
|
||||||
if (settings.eth_power != -1) { // Ethernet Power -1 means disabled
|
|
||||||
EMSESP::system_.remove_gpio(settings.eth_power, true);
|
|
||||||
}
|
|
||||||
// remove the ethernet pins from valid list, regardless of whether the GPIOs are valid or not
|
|
||||||
EMSESP::system_.remove_gpio(23, true); // MDC
|
|
||||||
EMSESP::system_.remove_gpio(18, true); // MDIO
|
|
||||||
if (settings.eth_clock_mode < 2) {
|
|
||||||
EMSESP::system_.remove_gpio(0, true); // ETH.clock input
|
|
||||||
} else if (settings.eth_clock_mode == 2) {
|
|
||||||
EMSESP::system_.remove_gpio(16, true); // ETH.clock output
|
|
||||||
} else if (settings.eth_clock_mode == 3) {
|
|
||||||
EMSESP::system_.remove_gpio(17, true); // ETH.clock output
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if the LED type, eth_phy_addr or eth_clock_mode have changed
|
// check if the LED type, eth_phy_addr or eth_clock_mode have changed
|
||||||
check_flag(original_settings.led_type, settings.led_type, ChangeFlags::LED);
|
check_flag(original_settings.led_type, settings.led_type, ChangeFlags::LED);
|
||||||
check_flag(original_settings.eth_phy_addr, settings.eth_phy_addr, ChangeFlags::RESTART);
|
check_flag(original_settings.eth_phy_addr, settings.eth_phy_addr, ChangeFlags::RESTART);
|
||||||
|
|||||||
Reference in New Issue
Block a user