From b993313ac16b02e83b17e3434f1b5d36bdd92296 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 5 Apr 2022 11:30:12 -0500 Subject: [PATCH 1/2] Don't reset GPIO4 (used for voltage monitoring) --- ports/espressif/boards/adafruit_magtag_2.9_grayscale/board.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ports/espressif/boards/adafruit_magtag_2.9_grayscale/board.c b/ports/espressif/boards/adafruit_magtag_2.9_grayscale/board.c index 18dd280cea..3eee2f119b 100644 --- a/ports/espressif/boards/adafruit_magtag_2.9_grayscale/board.c +++ b/ports/espressif/boards/adafruit_magtag_2.9_grayscale/board.c @@ -188,6 +188,10 @@ bool espressif_board_reset_pin_number(gpio_num_t pin_number) { gpio_config(&cfg); return true; } + // Pin 4 is used for voltage monitoring, so don't reset + if (pin_number == 4) { + return true; + } return false; } From 99dc4029dcadc5a4dc88930223cdba4951863eb8 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 6 Apr 2022 11:33:56 -0400 Subject: [PATCH 2/2] Espressif: disable pull-up on AnalogIn creation --- ports/espressif/common-hal/analogio/AnalogIn.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ports/espressif/common-hal/analogio/AnalogIn.c b/ports/espressif/common-hal/analogio/AnalogIn.c index ba85d42735..adb8b15065 100644 --- a/ports/espressif/common-hal/analogio/AnalogIn.c +++ b/ports/espressif/common-hal/analogio/AnalogIn.c @@ -55,6 +55,10 @@ void common_hal_analogio_analogin_construct(analogio_analogin_obj_t *self, } common_hal_mcu_pin_claim(pin); self->pin = pin; + // Pull-ups are enabled by default for power-saving reasons on quiescent pins. + // Turn off the pull-up as soon as we know the pin will be used for analog reads, + // since it may take a while for the voltage to stabilize if the input is high-impedance. + gpio_pullup_dis(pin->number); } bool common_hal_analogio_analogin_deinited(analogio_analogin_obj_t *self) {