Skip to content

Commit

Permalink
add E32V2 board profile, fix autodetect and GPIOs
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDvP committed Oct 22, 2023
1 parent 509d213 commit 5e6b0f6
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 16 deletions.
3 changes: 1 addition & 2 deletions interface/src/project/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) ||
Expand Down
2 changes: 1 addition & 1 deletion src/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 3 additions & 1 deletion src/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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") {
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define EMSESP_APP_VERSION "3.6.3-dev.4a"
#define EMSESP_APP_VERSION "3.6.3-dev.4b"
51 changes: 40 additions & 11 deletions src/web/WebSettingsService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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());
Expand Down

0 comments on commit 5e6b0f6

Please sign in to comment.