-->
Page 1 of 1

Can't get the GPIO interrupt working - Win Eclipse IDE

PostPosted: Thu Nov 19, 2015 6:56 am
by Cicero
Hi all,

I'm using an ESP12, and trying to get an interrupt working on the negative edge of the labelled GPIO4 (which I understand is actually GPIO5!).

I'm using Cherts windows Eclipse IDE, with an old SDK v2.0.5 (22.05.2015). I can't keep up with the updates and having to keep going back to change my code.

Anyway, essentially I just can't get the interrupt called, and its really annoying. I'd appreciate it if anyone could help me out.

This is all I'm doing.

Code: Select allvoid ICACHE_FLASH_ATTR gpioInterrupt (void)
{
   DEBUG("In interrupt\r\n");
  eth.data_present = 1;
   eth.no_reset = 1;
   ETS_GPIO_INTR_DISABLE();
}

//#define USE_EASY_GPIO
void ICACHE_FLASH_ATTR ioInit() {}
  uint32 gpio_status;                                                       
   
  /* Button */
  PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0);
 
  PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO5_U, FUNC_GPIO5);    // enc reset
  PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO4_U, FUNC_GPIO4);    // enc interrupt
  #ifndef USE_EASY_GPIO
    /* Clear any interrupt flags related to gpio */
    gpio_status = GPIO_REG_READ(GPIO_STATUS_ADDRESS);
    GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, gpio_status);
    gpio_pin_intr_state_set((1<<ENCINTGPIO),GPIO_PIN_INTR_NEGEDGE);
   
    /* Attach and enable the interrupt handler */
    ETS_GPIO_INTR_ATTACH(gpioInterrupt , NULL);
    ETS_GPIO_INTR_ENABLE();
  #else
    easygpio_attachInterrupt(ENCINTGPIO, EASYGPIO_NOPULL, gpioInterrupt );
  #endif
   
   os_timer_disarm(&resetBtntimer);
   os_timer_setfn(&resetBtntimer, resetBtnTimerCb, NULL);
   os_timer_arm(&resetBtntimer, 500, 1);
 
  INFO("end io init\r\n");
}

Re: Can't get the GPIO interrupt working - Win Eclipse IDE

PostPosted: Thu Nov 19, 2015 8:54 am
by Cicero
FYI: Ok this worked.

Code: Select all  GPIO_DIS_OUTPUT(ENCINTGPIO);
  PIN_PULLUP_EN(PERIPHS_IO_MUX_GPIO5_U);
  ETS_GPIO_INTR_DISABLE();
  ETS_GPIO_INTR_ATTACH(gpioInterrupt,ENCINTGPIO);
 
  GPIO_REG_WRITE(GPIO_STATUS_W1TS_ADDRESS, BIT(ENCINTGPIO));
  gpio_pin_intr_state_set(GPIO_ID_PIN(ENCINTGPIO),GPIO_PIN_INTR_NEGEDGE);
  gpio_status = GPIO_REG_READ(GPIO_STATUS_ADDRESS);
  GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, gpio_status);
  ETS_GPIO_INTR_ENABLE();