Skip to content

Commit f42672d

Browse files
committed
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.
1 parent 0b3f1a9 commit f42672d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

cores/esp32/esp32-hal-gpio.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,16 @@ extern void ARDUINO_ISR_ATTR __pinMode(uint8_t pin, uint8_t mode)
9595
log_e("Invalid pin selected");
9696
return;
9797
}
98+
99+
gpio_hal_context_t gpiohal;
100+
gpiohal.dev = GPIO_LL_GET_HW(GPIO_PORT_0);
101+
98102
gpio_config_t conf = {
99-
.pin_bit_mask = (1ULL<<pin), /*!< GPIO pin: set with bit mask, each bit maps to a GPIO */
100-
.mode = GPIO_MODE_DISABLE, /*!< GPIO mode: set input/output mode */
101-
.pull_up_en = GPIO_PULLUP_DISABLE, /*!< GPIO pull-up */
102-
.pull_down_en = GPIO_PULLDOWN_DISABLE, /*!< GPIO pull-down */
103-
.intr_type = GPIO_INTR_DISABLE /*!< GPIO interrupt type */
103+
.pin_bit_mask = (1ULL<<pin), /*!< GPIO pin: set with bit mask, each bit maps to a GPIO */
104+
.mode = GPIO_MODE_DISABLE, /*!< GPIO mode: set input/output mode */
105+
.pull_up_en = GPIO_PULLUP_DISABLE, /*!< GPIO pull-up */
106+
.pull_down_en = GPIO_PULLDOWN_DISABLE, /*!< GPIO pull-down */
107+
.intr_type = gpiohal.dev->pin[pin].int_type /*!< GPIO interrupt type - previously set */
104108
};
105109
if (mode < 0x20) {//io
106110
conf.mode = mode & (INPUT | OUTPUT);

0 commit comments

Comments
 (0)