Skip to content

Commit c1a2ea2

Browse files
committed
Change to config-based resets
1 parent c7b5928 commit c1a2ea2

File tree

1 file changed

+15
-2
lines changed
  • ports/esp32s2/common-hal/microcontroller

1 file changed

+15
-2
lines changed

ports/esp32s2/common-hal/microcontroller/Pin.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ STATIC uint32_t in_use[2];
4444
bool apa102_mosi_in_use;
4545
bool apa102_sck_in_use;
4646

47+
STATIC void floating_gpio_reset(gpio_num_t pin_number) {
48+
// This is the same as gpio_reset_pin(), but without the pullup.
49+
// Note that gpio_config resets the iomatrix to GPIO_FUNC as well.
50+
gpio_config_t cfg = {
51+
.pin_bit_mask = BIT64(pin_number),
52+
.mode = GPIO_MODE_DISABLE,
53+
.pull_up_en = false,
54+
.pull_down_en = false,
55+
.intr_type = GPIO_INTR_DISABLE,
56+
};
57+
gpio_config(&cfg);
58+
}
59+
4760
void never_reset_pin_number(gpio_num_t pin_number) {
4861
if (pin_number == -1 ) {
4962
return;
@@ -63,7 +76,7 @@ void reset_pin_number(gpio_num_t pin_number) {
6376
never_reset_pins[pin_number / 32] &= ~(1 << pin_number % 32);
6477
in_use[pin_number / 32] &= ~(1 << pin_number % 32);
6578

66-
gpio_matrix_out(pin_number, 0x100, 0, 0);
79+
floating_gpio_reset(pin_number);
6780

6881
#ifdef MICROPY_HW_NEOPIXEL
6982
if (pin_number == MICROPY_HW_NEOPIXEL->number) {
@@ -85,7 +98,7 @@ void reset_all_pins(void) {
8598
(never_reset_pins[i / 32] & (1 << i % 32)) != 0) {
8699
continue;
87100
}
88-
gpio_matrix_out(i, 0x100, 0, 0);
101+
floating_gpio_reset(i);
89102
}
90103
in_use[0] = 0;
91104
in_use[1] = 0;

0 commit comments

Comments
 (0)