How can I get callback reason (POS_EDGE or NEG_EDGE) from my global ISR callback? I looked to some registers like:
-GPIO_STATUS_REG = GPIO 0-31 interrupt status register.
-GPIO_ACPU_INT_REG = GPIO 0-31 APP_CPU interrupt status.
But no sense to me.
Code: Select all
void IRAM_ATTR GISR(void*par)
{
uint8_t gpio = (uint32_t) par;
uint8_t read = 0;
//Change to interrupt reason
if (gpio < 32) {read = (REG_READ(GPIO_IN_REG) >> gpio) & 0x1;}
else {read = (REG_READ(GPIO_IN1_REG) >> (gpio-32)) & 0x1;}
switch (gpio)
{
case usr_inp0: vTimerSetTimerID(pinTMR[0], (void*) 0+read); xTimerReset(pinTMR[0], 0); break;
case usr_inp1: vTimerSetTimerID(pinTMR[1], (void*) 2+read); xTimerReset(pinTMR[1], 0); break;
case usr_inp2: vTimerSetTimerID(pinTMR[2], (void*) 4+read); xTimerReset(pinTMR[2], 0); break;
case usr_inp3: vTimerSetTimerID(pinTMR[3], (void*) 6+read); xTimerReset(pinTMR[3], 0); break;
case usr_inp4: vTimerSetTimerID(pinTMR[4], (void*) 8+read); xTimerReset(pinTMR[4], 0); break;
case usr_inp5: vTimerSetTimerID(pinTMR[5], (void*)10+read); xTimerReset(pinTMR[5], 0); break;
case usr_inp6: vTimerSetTimerID(pinTMR[6], (void*)12+read); xTimerReset(pinTMR[6], 0); break;
case sys_inp0: webAP = 1; break;
}
}
void initPins()
{
gpio_install_isr_service(ESP_INTR_FLAG_LEVEL1);
gpio_set_intr_type(gpio_num_t(usr_inp0), GPIO_INTR_ANYEDGE); gpio_isr_handler_add(gpio_num_t(usr_inp0), GISR, (void*)usr_inp0);
//.......To all others 6 pins
}