It's now 2024 and I'm using
ESP-IDF 5.1.2 (the most current stable) to try to do as suggested. Like the poster, I want to (re)use
GPIO18 and
GPIO19 of the
ESP32-C3 as tactical switch button inputs. So I'm trying to
disable the USB-JTAG driver on these pins.
Code: Select all
// For good measure set GPIO 18 and 19 twice, one time here
gpio_reset_pin(GPIO_NUM_18);
gpio_reset_pin(GPIO_NUM_19);
gpio_set_pull_mode(GPIO_NUM_18, GPIO_PULLDOWN_DISABLE);
gpio_set_pull_mode(GPIO_NUM_18, GPIO_PULLUP_ENABLE);
gpio_set_pull_mode(GPIO_NUM_19, GPIO_PULLDOWN_DISABLE);
gpio_set_pull_mode(GPIO_NUM_19, GPIO_PULLUP_ENABLE);
gpio_set_direction(GPIO_NUM_18, GPIO_MODE_INPUT);
gpio_set_direction(GPIO_NUM_19, GPIO_MODE_INPUT);
// For good measure set GPIO 18 and 19 twice, a second time here
gpio_config_t cfg;
esp_err_t result;
memset(&cfg, 0x0, sizeof(cfg));
cfg.pin_bit_mask |= (1LL << gpio);
cfg.mode = GPIO_MODE_INPUT;
cfg.pull_up_en = GPIO_PULLUP_ENABLE;
cfg.pull_down_en = GPIO_PULLDOWN_DISABLE;
cfg.intr_type = GPIO_INTR_ANYEDGE;
result = gpio_config(&cfg);
Expectation
I should be able to press the tactical switch button on
GPIO18 or
GPIO19 which drives the pin low and the MCU interrupts, just like I'm doing with GPIO8 and GPIO9. My device has four buttons.
Problem
While GPIO8 and GPIO9 work properly, when I press the button on
GPIO18 or
GPIO19 then nothing happens and the MCU does not interrupt.
Is anybody else having trouble doing this, and is it because the necessary code is
still not in ESP-IDF as of 5.1.2?
I'm using gpio_isr_handler_add() on both GPIO18 and GPIO19. Is that a problem?
There are some
CLEAR_PERI_REG_MASK() and
REG_SET_BIT() macros that I'm not using, because I'm unsure which parameters to pass. I hope these kinds of macros are not needed, what do you think?