ESP-12 Hardware interrupts not working
Posted: Tue Aug 04, 2015 12:30 am
I am using esp_mqtt and want to include a hardware interrupt. I have done searching and trying but not has worked... Any help would be greatly appreciated!
Here is the snippet of code of what I am doing:
Here is the snippet of code of what I am doing:
Code: Select all
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
}