Here is the snippet of code of what I am doing:
static void pin13_interrupt(void *arg)
{
uint32 gpio_status = GPIO_REG_READ(GPIO_STATUS_ADDRESS);
//disable interrupt
gpio_pin_intr_state_set(GPIO_ID_PIN(13), GPIO_PIN_INTR_DISABLE);
os_delay_us(500000);
INFO("i have been hit\n");
//clear interrupt status
GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, gpio_status & BIT(13));
//enable interrupt
gpio_pin_intr_state_set(GPIO_ID_PIN(0), 3);
}
void ICACHE_FLASH_ATTR user_init(void)
{
ETS_GPIO_INTR_DISABLE(); // Disable gpio interrupts
ETS_GPIO_INTR_ATTACH(pin13_interrupt, 13); // GPIO13 interrupt handler
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, FUNC_GPIO13); // Set GPIO13 function
gpio_output_set(0, 0, 0, GPIO_ID_PIN(13)); // Set GPIO13 as input
GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, BIT(13)); // Clear GPIO13 status
gpio_pin_intr_state_set(GPIO_ID_PIN(13), 3); // Interrupt on any GPIO13 edge
ETS_GPIO_INTR_ENABLE(); // Enable gpio interrupts
}