Skip to content

Commit

Permalink
Merge pull request letscontrolit#5101 from tonhuisman/feature/Console…
Browse files Browse the repository at this point in the history
…-check-fallback-gpio-pins-for-selector

[Console] Exclude Serial Console fall-back GPIOs only when fall-back enabled
  • Loading branch information
TD-er authored Aug 12, 2024
2 parents 6719f60 + 1fe6492 commit ab42e42
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docs/source/Tools/Tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ This console can be accessed via a serial port.
* Serial Port - The selected serial port to use for the console.
* ESP RX GPIO ← TX - GPIO pin used as RX, to connect with the TX of the other device.
* ESP TX GPIO → RX - GPIO pin used as TX, to connect with the RX of the other device.
* Fallback to Serial 0 - (Only on ESP32-C3/S2/S3) Configure HW Serial0 port as secondary port for the ESPEasy console.
* Fallback to Serial 0 - (Only on ESP32-C3/S2/S3) Configure HW Serial0 port as secondary port for the ESPEasy console. When unchecked, the Fallback RX/TX pins will be available for selection in the GPIO pin selector and GPIO boot-states configuration on the Hardware tab.

GPIO pin selection will only be shown for Serial Port types which require action GPIO pins.
For example USB CDC and HW CDC ports do not need specific GPIO pins for their configuration.
Expand Down
27 changes: 20 additions & 7 deletions src/src/Helpers/Hardware_GPIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,22 +489,35 @@ bool isSerialConsolePin(int gpio) {
if (!Settings.UseSerial) { return false; }

#if defined(SOC_RX0) && defined(SOC_TX0)
return gpio == SOC_TX0 || gpio == SOC_RX0;
return (gpio == SOC_TX0 || gpio == SOC_RX0)
#if USES_ESPEASY_CONSOLE_FALLBACK_PORT
&& Settings.console_serial0_fallback
#endif // if USES_ESPEASY_CONSOLE_FALLBACK_PORT
;
#else
#ifdef ESP32S2

// FIXME TD-er: Must check whether USB serial is used
return gpio == 1 || gpio == 3;
return (gpio == 1 || gpio == 3)
#if USES_ESPEASY_CONSOLE_FALLBACK_PORT
&& Settings.console_serial0_fallback
#endif // if USES_ESPEASY_CONSOLE_FALLBACK_PORT
;

#elif defined(ESP32S3)

// FIXME TD-er: Must check whether USB serial is used
return gpio == 43 || gpio == 44;
return (gpio == 43 || gpio == 44)
#if USES_ESPEASY_CONSOLE_FALLBACK_PORT
&& Settings.console_serial0_fallback
#endif // if USES_ESPEASY_CONSOLE_FALLBACK_PORT
;

#elif defined(ESP32C3)

// FIXME TD-er: Must check whether USB serial is used
return gpio == 21 || gpio == 20;
return (gpio == 21 || gpio == 20)
#if USES_ESPEASY_CONSOLE_FALLBACK_PORT
&& Settings.console_serial0_fallback
#endif // if USES_ESPEASY_CONSOLE_FALLBACK_PORT
;

#elif defined(ESP32_CLASSIC)
return gpio == 1 || gpio == 3;
Expand Down
13 changes: 6 additions & 7 deletions src/src/Helpers/StringGenerator_GPIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,7 @@ const __FlashStringHelper* getConflictingUse(int gpio, PinSelectPurpose purpose)
#if FEATURE_SD
bool includeSDCard = true;
#endif
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
// FIXME TD-er: Must check whether this can be a conflict.
bool includeSerial = false;
#else
bool includeSerial = true;
#endif
bool includeSerial = Settings.UseSerial; // Only need to check if Serial Port Console is enabled

#if FEATURE_ETHERNET
bool includeEthernet = true;
Expand Down Expand Up @@ -270,7 +265,11 @@ const __FlashStringHelper* getConflictingUse(int gpio, PinSelectPurpose purpose)
if (includeSerial) {
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
if (Settings.UseSerial &&
Settings.console_serial_port == 2) // 2 == ESPEasySerialPort::serial0
(Settings.console_serial_port == 2 // 2 == ESPEasySerialPort::serial0
#if USES_ESPEASY_CONSOLE_FALLBACK_PORT
|| Settings.console_serial0_fallback
#endif // if USES_ESPEASY_CONSOLE_FALLBACK_PORT
))
#else
if (Settings.UseSerial)
#endif
Expand Down

0 comments on commit ab42e42

Please sign in to comment.