From f42672d2e1621b45df962c2c1e739d739d4a7e0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Procha=CC=81zka?= <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Thu, 5 May 2022 14:37:35 +0200 Subject: [PATCH 1/3] Changed in pinMode() default intr_type pins default configuration has intr_type = GPIO_INTR_DISABLE With this implementation, it will set the intr_type to previously set intr_type. It will no longer disable interrupt, when pinmode is called multiple times on same pin with interrupt enabled. --- cores/esp32/esp32-hal-gpio.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cores/esp32/esp32-hal-gpio.c b/cores/esp32/esp32-hal-gpio.c index e21063a8596..3d1c787c8bb 100644 --- a/cores/esp32/esp32-hal-gpio.c +++ b/cores/esp32/esp32-hal-gpio.c @@ -95,12 +95,16 @@ extern void ARDUINO_ISR_ATTR __pinMode(uint8_t pin, uint8_t mode) log_e("Invalid pin selected"); return; } + + gpio_hal_context_t gpiohal; + gpiohal.dev = GPIO_LL_GET_HW(GPIO_PORT_0); + gpio_config_t conf = { - .pin_bit_mask = (1ULL<pin[pin].int_type /*!< GPIO interrupt type - previously set */ }; if (mode < 0x20) {//io conf.mode = mode & (INPUT | OUTPUT); From 48fe1261f31ec14281f38b29737bb1ec62bf03bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Procha=CC=81zka?= <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Mon, 9 May 2022 18:25:27 +0200 Subject: [PATCH 2/3] Indentation fix --- cores/esp32/esp32-hal-gpio.c | 48 ++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/cores/esp32/esp32-hal-gpio.c b/cores/esp32/esp32-hal-gpio.c index 3d1c787c8bb..780e8b5c11c 100644 --- a/cores/esp32/esp32-hal-gpio.c +++ b/cores/esp32/esp32-hal-gpio.c @@ -91,34 +91,34 @@ static InterruptHandle_t __pinInterruptHandlers[SOC_GPIO_PIN_COUNT] = {0,}; extern void ARDUINO_ISR_ATTR __pinMode(uint8_t pin, uint8_t mode) { - if (!GPIO_IS_VALID_GPIO(pin)) { + if (!GPIO_IS_VALID_GPIO(pin)) { log_e("Invalid pin selected"); - return; - } - + return; + } + gpio_hal_context_t gpiohal; gpiohal.dev = GPIO_LL_GET_HW(GPIO_PORT_0); - gpio_config_t conf = { - .pin_bit_mask = (1ULL<pin[pin].int_type /*!< GPIO interrupt type - previously set */ - }; - if (mode < 0x20) {//io - conf.mode = mode & (INPUT | OUTPUT); - if (mode & OPEN_DRAIN) { - conf.mode |= GPIO_MODE_DEF_OD; - } - if (mode & PULLUP) { - conf.pull_up_en = GPIO_PULLUP_ENABLE; - } - if (mode & PULLDOWN) { - conf.pull_down_en = GPIO_PULLDOWN_ENABLE; - } - } - if(gpio_config(&conf) != ESP_OK) + gpio_config_t conf = { + .pin_bit_mask = (1ULL<pin[pin].int_type /*!< GPIO interrupt type - previously set */ + }; + if (mode < 0x20) {//io + conf.mode = mode & (INPUT | OUTPUT); + if (mode & OPEN_DRAIN) { + conf.mode |= GPIO_MODE_DEF_OD; + } + if (mode & PULLUP) { + conf.pull_up_en = GPIO_PULLUP_ENABLE; + } + if (mode & PULLDOWN) { + conf.pull_down_en = GPIO_PULLDOWN_ENABLE; + } + } + if(gpio_config(&conf) != ESP_OK) { log_e("GPIO config failed"); return; From 04977d26ad0c750aab09d5d16d05b1abebc2b13f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Procha=CC=81zka?= <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Mon, 9 May 2022 18:26:43 +0200 Subject: [PATCH 3/3] Indentation fix --- cores/esp32/esp32-hal-gpio.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cores/esp32/esp32-hal-gpio.c b/cores/esp32/esp32-hal-gpio.c index 780e8b5c11c..359682c3433 100644 --- a/cores/esp32/esp32-hal-gpio.c +++ b/cores/esp32/esp32-hal-gpio.c @@ -100,11 +100,11 @@ extern void ARDUINO_ISR_ATTR __pinMode(uint8_t pin, uint8_t mode) gpiohal.dev = GPIO_LL_GET_HW(GPIO_PORT_0); gpio_config_t conf = { - .pin_bit_mask = (1ULL<pin[pin].int_type /*!< GPIO interrupt type - previously set */ + .pin_bit_mask = (1ULL<pin[pin].int_type /*!< GPIO interrupt type - previously set */ }; if (mode < 0x20) {//io conf.mode = mode & (INPUT | OUTPUT);