Skip to content

Conversation

P-R-O-C-H-Y
Copy link
Member

Description of Change

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.

There is no option to get pin config from ESP-IDF API, that's why I made this implementation.

Tests scenarios

//To trigger ISR, connect GPIO 19 to GND.

uint32_t interrupt_count = 0;

void IRAM_ATTR pin_interrupt(void *arg) {
  interrupt_count++;
  pinMode(19, INPUT);
  //attachInterruptArg(19, pin_interrupt, 0, CHANGE);
}

void setup() {
  pinMode(19, INPUT);
  attachInterruptArg(19, pin_interrupt, 0, CHANGE);
}

void loop() {
  ESP_LOGD("loop", "interrupt count %d", interrupt_count);
  delay(500);
}

Related links

Closes #6669

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.
@P-R-O-C-H-Y P-R-O-C-H-Y added the Area: Peripherals API Relates to peripheral's APIs. label May 5, 2022
@P-R-O-C-H-Y P-R-O-C-H-Y added this to the 2.0.4 milestone May 5, 2022
@P-R-O-C-H-Y P-R-O-C-H-Y requested a review from me-no-dev May 5, 2022 12:42
@P-R-O-C-H-Y P-R-O-C-H-Y self-assigned this May 5, 2022
@github-actions
Copy link
Contributor

github-actions bot commented May 5, 2022

Unit Test Results

0 files  0 suites   0s ⏱️
0 tests 0 ✔️ 0 💤 0

Results for commit f42672d.

}

gpio_hal_context_t gpiohal;
gpiohal.dev = GPIO_LL_GET_HW(GPIO_PORT_0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation issue here :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wierd, I dont see that in GitHub Deskto / VS Code or GitHub integrated editor.

Copy link
Member Author

@P-R-O-C-H-Y P-R-O-C-H-Y May 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced tabs with spaces, should be fine now :)

@me-no-dev me-no-dev merged commit d302091 into espressif:master May 9, 2022
@P-R-O-C-H-Y P-R-O-C-H-Y deleted the GPIO_pinMode_Interrupt_memory branch April 19, 2023 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Peripherals API Relates to peripheral's APIs.

Projects

Development

Successfully merging this pull request may close these issues.

pinMode disables interrupts as a side effect

2 participants