Skip to content

Commit

Permalink
[ESP32C3] Allow GPIO 11, 12, 13 to be used on specific boards
Browse files Browse the repository at this point in the history
  • Loading branch information
TD-er committed Dec 10, 2024
1 parent 30e4197 commit 150b10f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
5 changes: 5 additions & 0 deletions docs/source/Reference/GPIO.rst
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,14 @@ ESP32-C3 SPI flash pins

Pins connected to flash or PSRAM should not be used for anything else.

On boards with embedded flash, these pins cannot be used:

* GPIO-11: Flash voltage selector
* GPIO-12 ... -17: Connected to flash

On boards with external flash, GPIO-11, GPIO-12 and GPIO-13 can be selected.
However special care should be taken as some boards can still have these pins wired to the flash chip.

.. note:: By default VDD_SPI is the power supply pin for embedded flash or external flash. It can only be used as GPIO-11 only when the chip is connected to an external flash, and this flash is powered by an external power supply.


Expand Down
32 changes: 25 additions & 7 deletions src/src/Helpers/Hardware_GPIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,35 @@ bool getGpioInfo(int gpio, int& pinnr, bool& input, bool& output, bool& warning)
}

if (gpio == 11) {
// By default VDD_SPI is the power supply pin for embedded flash or external flash. It can only be used as GPIO11
// only when the chip is connected to an external flash, and this flash is powered by an external power supply
input = false;
output = false;
if (getChipFeatures().embeddedFlash) {
// See: https://www.letscontrolit.com/forum/viewtopic.php?p=71880#p71874
//
// By default VDD_SPI is the power supply pin for embedded flash or external flash.
// It can only be used as GPIO11 only when the chip is connected to an
// external flash, and this flash is powered by an external power supply
input = false;
output = false;
}
warning = true;
}

if (isFlashInterfacePin_ESPEasy(gpio)) {
// Connected to the integrated SPI flash.
input = false;
output = false;
if (getChipFeatures().embeddedFlash) {
// Connected to the integrated SPI flash.
input = false;
output = false;
} else {
// See: https://www.letscontrolit.com/forum/viewtopic.php?p=71880#p71874
if (gpio == 12 || gpio == 13) {
// SPIHD/GPIO12
// SPIWP/GPIO13
if (ESP.getFlashChipMode() != FM_DOUT &&
ESP.getFlashChipMode() != FM_DIO) {
input = false;
output = false;
}
}
}
warning = true;
}

Expand Down

0 comments on commit 150b10f

Please sign in to comment.