From c70c8a93906085d61ab7346a7cf0826c72606cd8 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sat, 15 Jan 2022 19:28:00 -0500 Subject: [PATCH 1/2] fix espressif open-drain --- ports/espressif/common-hal/digitalio/DigitalInOut.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ports/espressif/common-hal/digitalio/DigitalInOut.c b/ports/espressif/common-hal/digitalio/DigitalInOut.c index 24c5d5110d..b5199672b1 100644 --- a/ports/espressif/common-hal/digitalio/DigitalInOut.c +++ b/ports/espressif/common-hal/digitalio/DigitalInOut.c @@ -108,11 +108,9 @@ digitalinout_result_t common_hal_digitalio_digitalinout_set_drive_mode( digitalio_digitalinout_obj_t *self, digitalio_drive_mode_t drive_mode) { gpio_num_t number = self->pin->number; - gpio_mode_t mode; + gpio_mode_t mode = GPIO_MODE_DEF_OUTPUT; if (drive_mode == DRIVE_MODE_OPEN_DRAIN) { - mode = GPIO_MODE_DEF_OD; - } else { - mode = GPIO_MODE_DEF_OUTPUT; + mode |= GPIO_MODE_DEF_OD; } esp_err_t result = gpio_set_direction(number, mode); if (result != ESP_OK) { From 11848b1826f81ee5cd2d01e0f7339c21e34618f3 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sat, 15 Jan 2022 23:05:33 -0500 Subject: [PATCH 2/2] use GPIO_MODE_ instead of GPIO_MODE_DEF --- ports/espressif/common-hal/digitalio/DigitalInOut.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/espressif/common-hal/digitalio/DigitalInOut.c b/ports/espressif/common-hal/digitalio/DigitalInOut.c index b5199672b1..bf52965d28 100644 --- a/ports/espressif/common-hal/digitalio/DigitalInOut.c +++ b/ports/espressif/common-hal/digitalio/DigitalInOut.c @@ -71,7 +71,7 @@ void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t *self void common_hal_digitalio_digitalinout_switch_to_input( digitalio_digitalinout_obj_t *self, digitalio_pull_t pull) { common_hal_digitalio_digitalinout_set_pull(self, pull); - gpio_set_direction(self->pin->number, GPIO_MODE_DEF_INPUT); + gpio_set_direction(self->pin->number, GPIO_MODE_INPUT); } digitalinout_result_t common_hal_digitalio_digitalinout_switch_to_output( @@ -108,9 +108,9 @@ digitalinout_result_t common_hal_digitalio_digitalinout_set_drive_mode( digitalio_digitalinout_obj_t *self, digitalio_drive_mode_t drive_mode) { gpio_num_t number = self->pin->number; - gpio_mode_t mode = GPIO_MODE_DEF_OUTPUT; + gpio_mode_t mode = GPIO_MODE_OUTPUT; if (drive_mode == DRIVE_MODE_OPEN_DRAIN) { - mode |= GPIO_MODE_DEF_OD; + mode |= GPIO_MODE_OUTPUT_OD; } esp_err_t result = gpio_set_direction(number, mode); if (result != ESP_OK) {