summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Shawcroft <scott@adafruit.com>2020-12-14 17:09:29 -0800
committerGitHub <noreply@github.com>2020-12-14 17:09:29 -0800
commitdc473b29e384fcd07abf8512a4f43d5c3975dd91 (patch)
tree63983374d667088a701ff415012aff07f7d6b4c2
parent6cced494022007e6d1fea1b022b37e5b6212111e (diff)
parentd793ec287234e1e968adf3b8e03c184c19339942 (diff)
Merge pull request #3643 from hierophect/esp32-pin-reset
ESP32-S2: Add IDF pin resets to Microcontroller
-rw-r--r--ports/esp32s2/common-hal/microcontroller/Pin.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/ports/esp32s2/common-hal/microcontroller/Pin.c b/ports/esp32s2/common-hal/microcontroller/Pin.c
index 394a19e69..81dfa1308 100644
--- a/ports/esp32s2/common-hal/microcontroller/Pin.c
+++ b/ports/esp32s2/common-hal/microcontroller/Pin.c
@@ -44,6 +44,20 @@ STATIC uint32_t in_use[2];
bool apa102_mosi_in_use;
bool apa102_sck_in_use;
+STATIC void floating_gpio_reset(gpio_num_t pin_number) {
+ // This is the same as gpio_reset_pin(), but without the pullup.
+ // Note that gpio_config resets the iomatrix to GPIO_FUNC as well.
+ gpio_config_t cfg = {
+ .pin_bit_mask = BIT64(pin_number),
+ .mode = GPIO_MODE_DISABLE,
+ .pull_up_en = false,
+ .pull_down_en = false,
+ .intr_type = GPIO_INTR_DISABLE,
+ };
+ gpio_config(&cfg);
+ PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[pin_number], 0);
+}
+
void never_reset_pin_number(gpio_num_t pin_number) {
if (pin_number == -1 ) {
return;
@@ -63,6 +77,8 @@ void reset_pin_number(gpio_num_t pin_number) {
never_reset_pins[pin_number / 32] &= ~(1 << pin_number % 32);
in_use[pin_number / 32] &= ~(1 << pin_number % 32);
+ floating_gpio_reset(pin_number);
+
#ifdef MICROPY_HW_NEOPIXEL
if (pin_number == MICROPY_HW_NEOPIXEL->number) {
neopixel_in_use = false;
@@ -83,9 +99,7 @@ void reset_all_pins(void) {
(never_reset_pins[i / 32] & (1 << i % 32)) != 0) {
continue;
}
- gpio_set_direction(i, GPIO_MODE_DEF_INPUT);
- gpio_pullup_dis(i);
- gpio_pulldown_dis(i);
+ floating_gpio_reset(i);
}
in_use[0] = 0;
in_use[1] = 0;