forked from esphome/esphome
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial Support for ESP32-C2 & ESP32-C6
Add initial support for GPIO validation on ESP32-C2 and ESP32-C6 ESP32-C2: https://www.espressif.com/sites/default/files/documentation/esp8684_datasheet_en.pdf ESP32-C6: https://www.espressif.com/sites/default/files/documentation/esp32-c6_datasheet_en.pdf [fix conflicts in esphome/components/adc/sensor.py] Signed-off-by: Stijn Tintel <[email protected]>
- Loading branch information
Showing
10 changed files
with
132 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,6 @@ | |
KEY_SDKCONFIG_OPTIONS, | ||
KEY_SUBMODULES, | ||
KEY_VARIANT, | ||
VARIANT_ESP32C3, | ||
VARIANT_FRIENDLY, | ||
VARIANTS, | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import logging | ||
|
||
from esphome.const import CONF_INPUT, CONF_MODE, CONF_NUMBER | ||
|
||
import esphome.config_validation as cv | ||
|
||
_ESP32C2_STRAPPING_PINS = {8, 9} | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
def esp32_c2_validate_gpio_pin(value): | ||
if value < 0 or value > 20: | ||
raise cv.Invalid(f"Invalid pin number: {value} (must be 0-20)") | ||
if value in _ESP32C2_STRAPPING_PINS: | ||
_LOGGER.warning( | ||
"GPIO%d is a Strapping PIN and should be avoided.\n" | ||
"Attaching external pullup/down resistors to strapping pins can cause unexpected failures.\n" | ||
"See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins", | ||
value, | ||
) | ||
|
||
return value | ||
|
||
|
||
def esp32_c2_validate_supports(value): | ||
num = value[CONF_NUMBER] | ||
mode = value[CONF_MODE] | ||
is_input = mode[CONF_INPUT] | ||
|
||
if num < 0 or num > 20: | ||
raise cv.Invalid(f"Invalid pin number: {value} (must be 0-20)") | ||
|
||
if is_input: | ||
# All ESP32 pins support input mode | ||
pass | ||
return value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import logging | ||
|
||
from esphome.const import CONF_INPUT, CONF_MODE, CONF_NUMBER | ||
|
||
import esphome.config_validation as cv | ||
|
||
_ESP32C6_SPI_PSRAM_PINS = { | ||
24: "SPICS0", | ||
25: "SPIQ", | ||
26: "SPIWP", | ||
27: "VDD_SPI", | ||
28: "SPIHD", | ||
29: "SPICLK", | ||
30: "SPID", | ||
} | ||
|
||
_ESP32C6_STRAPPING_PINS = {8, 9, 15} | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
def esp32_c6_validate_gpio_pin(value): | ||
if value < 0 or value > 23: | ||
raise cv.Invalid(f"Invalid pin number: {value} (must be 0-23)") | ||
if value in _ESP32C6_SPI_PSRAM_PINS: | ||
raise cv.Invalid( | ||
f"This pin cannot be used on ESP32-C6s and is already used by the SPI/PSRAM interface (function: {_ESP32C6_SPI_PSRAM_PINS[value]})" | ||
) | ||
if value in _ESP32C6_STRAPPING_PINS: | ||
_LOGGER.warning( | ||
"GPIO%d is a Strapping PIN and should be avoided.\n" | ||
"Attaching external pullup/down resistors to strapping pins can cause unexpected failures.\n" | ||
"See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins", | ||
value, | ||
) | ||
|
||
return value | ||
|
||
|
||
def esp32_c6_validate_supports(value): | ||
num = value[CONF_NUMBER] | ||
mode = value[CONF_MODE] | ||
is_input = mode[CONF_INPUT] | ||
|
||
if num < 0 or num > 23: | ||
raise cv.Invalid(f"Invalid pin number: {value} (must be 0-23)") | ||
if is_input: | ||
# All ESP32 pins support input mode | ||
pass | ||
return value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters