mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
add E32V2 board profile, fix autodetect and GPIOs
This commit is contained in:
@@ -8,8 +8,7 @@ export const GPIO_VALIDATOR = {
|
||||
if (
|
||||
value &&
|
||||
(value === 1 ||
|
||||
(value >= 6 && value <= 12) ||
|
||||
(value >= 14 && value <= 15) ||
|
||||
(value >= 6 && value <= 11) ||
|
||||
value === 20 ||
|
||||
value === 24 ||
|
||||
(value >= 28 && value <= 31) ||
|
||||
|
||||
@@ -284,7 +284,7 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
|
||||
std::vector<int8_t> data; // led, dallas, rx, tx, button, phy_type, eth_power, eth_phy_addr, eth_clock_mode
|
||||
std::string board_profile = Helpers::toUpper(arguments.front());
|
||||
if (!to_app(shell).system_.load_board_profile(data, board_profile)) {
|
||||
shell.println("Invalid board profile (S32, E32, MH-ET, NODEMCU, OLIMEX, OLIMEXPOE, C3MINI, S2MINI, S3MINI, CUSTOM)");
|
||||
shell.println("Invalid board profile (S32, E32, E32V2, MH-ET, NODEMCU, OLIMEX, OLIMEXPOE, C3MINI, S2MINI, S3MINI, CUSTOM)");
|
||||
return;
|
||||
}
|
||||
to_app(shell).webSettingsService.update(
|
||||
|
||||
@@ -391,7 +391,7 @@ void System::wifi_tweak() {
|
||||
// and https://nodemcu.readthedocs.io/en/dev-esp32/modules/gpio/
|
||||
bool System::is_valid_gpio(uint8_t pin) {
|
||||
#if CONFIG_IDF_TARGET_ESP32 || EMSESP_STANDALONE
|
||||
if ((pin == 1) || (pin >= 6 && pin <= 12) || (pin >= 14 && pin <= 15) || (pin == 20) || (pin == 24) || (pin >= 28 && pin <= 31) || (pin > 40)) {
|
||||
if ((pin == 1) || (pin >= 6 && pin <= 11) || (pin == 20) || (pin == 24) || (pin >= 28 && pin <= 31) || (pin > 40)) {
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
if ((pin >= 19 && pin <= 20) || (pin >= 22 && pin <= 32) || (pin > 40)) {
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
@@ -1440,6 +1440,8 @@ bool System::load_board_profile(std::vector<int8_t> & data, const std::string &
|
||||
data = {2, 18, 23, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // BBQKees Gateway S32
|
||||
} else if (board_profile == "E32") {
|
||||
data = {2, 4, 5, 17, 33, PHY_type::PHY_TYPE_LAN8720, 16, 1, 0}; // BBQKees Gateway E32
|
||||
} else if (board_profile == "E32V2") {
|
||||
data = {2, 14, 4, 5, 0, PHY_type::PHY_TYPE_LAN8720, 15, 0, 1}; // BBQKees Gateway E32 V2
|
||||
} else if (board_profile == "MH-ET") {
|
||||
data = {2, 18, 23, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // MH-ET Live D1 Mini
|
||||
} else if (board_profile == "NODEMCU") {
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define EMSESP_APP_VERSION "3.6.3-dev.4a"
|
||||
#define EMSESP_APP_VERSION "3.6.3-dev.4b"
|
||||
|
||||
@@ -101,17 +101,33 @@ StateUpdateResult WebSettings::update(JsonObject & root, WebSettings & settings)
|
||||
if (!System::load_board_profile(data, settings.board_profile.c_str())) {
|
||||
// unknown, check for ethernet, use default E32/S32
|
||||
// data is led, dallas, rx, tx, pbutton, phy, eth_power, eth_addr, eth_clock
|
||||
#ifndef EMSESP_STANDALONE
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
if (ETH.begin((eth_phy_type_t)1, 16, 23, 18, ETH_PHY_LAN8720, ETH_CLOCK_GPIO0_IN)) {
|
||||
// BBQKees Gateway E32
|
||||
data = {EMSESP_DEFAULT_LED_GPIO, 4, 5, 17, 33, PHY_type::PHY_TYPE_LAN8720, 16, 1, 0};
|
||||
#if CONFIG_IDF_TARGET_ESP32 && !defined(EMSESP_STANDALONE)
|
||||
switch (EMSESP::nvs_.getUChar("boot")) {
|
||||
case 0:
|
||||
if (ETH.begin((eth_phy_type_t)1, 16, 23, 18, ETH_PHY_LAN8720, ETH_CLOCK_GPIO0_IN)) {
|
||||
EMSESP::nvs_.putUChar("boot", 2); // set to E32
|
||||
ESP.restart();
|
||||
}
|
||||
EMSESP::nvs_.putUChar("boot", 1); // next test for E32V2
|
||||
ESP.restart();
|
||||
case 1:
|
||||
if (ETH.begin((eth_phy_type_t)0, 15, 23, 18, ETH_PHY_LAN8720, ETH_CLOCK_GPIO0_OUT)) {
|
||||
EMSESP::nvs_.putUChar("boot", 3); // set to E32V2
|
||||
ESP.restart();
|
||||
}
|
||||
EMSESP::nvs_.putUChar("boot", 4); // set to S32
|
||||
ESP.restart();
|
||||
case 2:
|
||||
settings.board_profile = "E32";
|
||||
} else
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
// BBQKees Gateway S32
|
||||
data = {EMSESP_DEFAULT_LED_GPIO, 4, 5, 17, 33, PHY_type::PHY_TYPE_LAN8720, 16, 1, 0};
|
||||
break;
|
||||
case 3:
|
||||
settings.board_profile = "E32V2";
|
||||
data = {EMSESP_DEFAULT_LED_GPIO, 14, 4, 5, 0, PHY_type::PHY_TYPE_LAN8720, 15, 0, 1}; // BBQKees Gateway E32 V2
|
||||
break;
|
||||
case 4:
|
||||
default:
|
||||
settings.board_profile = "S32";
|
||||
data = {EMSESP_DEFAULT_LED_GPIO,
|
||||
EMSESP_DEFAULT_DALLAS_GPIO,
|
||||
EMSESP_DEFAULT_RX_GPIO,
|
||||
@@ -121,8 +137,21 @@ StateUpdateResult WebSettings::update(JsonObject & root, WebSettings & settings)
|
||||
0,
|
||||
0,
|
||||
0};
|
||||
settings.board_profile = "S32";
|
||||
break;
|
||||
}
|
||||
#else
|
||||
// BBQKees Gateway S32
|
||||
data = {EMSESP_DEFAULT_LED_GPIO,
|
||||
EMSESP_DEFAULT_DALLAS_GPIO,
|
||||
EMSESP_DEFAULT_RX_GPIO,
|
||||
EMSESP_DEFAULT_TX_GPIO,
|
||||
EMSESP_DEFAULT_PBUTTON_GPIO,
|
||||
EMSESP_DEFAULT_PHY_TYPE,
|
||||
0,
|
||||
0,
|
||||
0};
|
||||
settings.board_profile = "S32";
|
||||
#endif
|
||||
EMSESP::logger().info("No board profile found. Re-setting to %s", settings.board_profile.c_str());
|
||||
} else {
|
||||
EMSESP::logger().info("Loading board profile %s", settings.board_profile.c_str());
|
||||
|
||||
Reference in New Issue
Block a user