forked from espressif/arduino-esp32
Changed pinMode() default interrupt type DISABLED to previously set (#6695)
* 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.
This commit is contained in:
@ -91,30 +91,34 @@ static InterruptHandle_t __pinInterruptHandlers[SOC_GPIO_PIN_COUNT] = {0,};
|
|||||||
|
|
||||||
extern void ARDUINO_ISR_ATTR __pinMode(uint8_t pin, uint8_t mode)
|
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");
|
log_e("Invalid pin selected");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gpio_config_t conf = {
|
|
||||||
.pin_bit_mask = (1ULL<<pin), /*!< GPIO pin: set with bit mask, each bit maps to a GPIO */
|
gpio_hal_context_t gpiohal;
|
||||||
.mode = GPIO_MODE_DISABLE, /*!< GPIO mode: set input/output mode */
|
gpiohal.dev = GPIO_LL_GET_HW(GPIO_PORT_0);
|
||||||
.pull_up_en = GPIO_PULLUP_DISABLE, /*!< GPIO pull-up */
|
|
||||||
.pull_down_en = GPIO_PULLDOWN_DISABLE, /*!< GPIO pull-down */
|
gpio_config_t conf = {
|
||||||
.intr_type = GPIO_INTR_DISABLE /*!< GPIO interrupt type */
|
.pin_bit_mask = (1ULL<<pin), /*!< GPIO pin: set with bit mask, each bit maps to a GPIO */
|
||||||
};
|
.mode = GPIO_MODE_DISABLE, /*!< GPIO mode: set input/output mode */
|
||||||
if (mode < 0x20) {//io
|
.pull_up_en = GPIO_PULLUP_DISABLE, /*!< GPIO pull-up */
|
||||||
conf.mode = mode & (INPUT | OUTPUT);
|
.pull_down_en = GPIO_PULLDOWN_DISABLE, /*!< GPIO pull-down */
|
||||||
if (mode & OPEN_DRAIN) {
|
.intr_type = gpiohal.dev->pin[pin].int_type /*!< GPIO interrupt type - previously set */
|
||||||
conf.mode |= GPIO_MODE_DEF_OD;
|
};
|
||||||
}
|
if (mode < 0x20) {//io
|
||||||
if (mode & PULLUP) {
|
conf.mode = mode & (INPUT | OUTPUT);
|
||||||
conf.pull_up_en = GPIO_PULLUP_ENABLE;
|
if (mode & OPEN_DRAIN) {
|
||||||
}
|
conf.mode |= GPIO_MODE_DEF_OD;
|
||||||
if (mode & PULLDOWN) {
|
}
|
||||||
conf.pull_down_en = GPIO_PULLDOWN_ENABLE;
|
if (mode & PULLUP) {
|
||||||
}
|
conf.pull_up_en = GPIO_PULLUP_ENABLE;
|
||||||
}
|
}
|
||||||
if(gpio_config(&conf) != ESP_OK)
|
if (mode & PULLDOWN) {
|
||||||
|
conf.pull_down_en = GPIO_PULLDOWN_ENABLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(gpio_config(&conf) != ESP_OK)
|
||||||
{
|
{
|
||||||
log_e("GPIO config failed");
|
log_e("GPIO config failed");
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user