10000 esp32/machine_pin: Use rtc_gpio_deinit instead of gpio_reset_pin. · micropython/micropython@e5d2ddd · GitHub
[go: up one dir, main page]

Skip to content

Commit e5d2ddd

Browse files
committed
esp32/machine_pin: Use rtc_gpio_deinit instead of gpio_reset_pin.
Commit 8a917ad added the gpio_reset_pin() call to make sure that pins that were used as ADC inputs could subsequently be used as digital IO. But calling gpio_reset_pin() will enable the pull-up on the pin and so pull it high for a brief period. Instead use rtc_gpio_deinit() which will just reconfigure the pin as a digital IO and do nothing else. Fixes issue #7079 (see also #5771). Signed-off-by: Damien George <damien@micropython.org>
1 parent a9bbf70 commit e5d2ddd

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ports/esp32/machine_pin.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <string.h>
3131

3232
#include "driver/gpio.h"
33+
#include "driver/rtc_io.h"
3334

3435
#include "py/runtime.h"
3536
#include "py/mphal.h"
@@ -157,9 +158,11 @@ STATIC mp_obj_t machine_pin_obj_init_helper(const machine_pin_obj_t *self, size_
157158
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
158159
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
159160

160-
// reset the pin first if this is a mode-setting init (grab it back from ADC)
161+
// reset the pin to digital if this is a mode-setting init (grab it back from ADC)
161162
if (args[ARG_mode].u_obj != mp_const_none) {
162-
gpio_reset_pin(self->id);
163+
if (rtc_gpio_is_valid_gpio(self->id)) {
164+
rtc_gpio_deinit(self->id);
165+
}
163166
}
164167

165168
// configure the pin for gpio

0 commit comments

Comments
 (0)
0