ESP8266 Developer Zone The Official ESP8266 Forum 2015-08-19T16:26:08+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=970 2015-08-19T16:26:08+08:00 2015-08-19T16:26:08+08:00 https://bbs.espressif.com:443/viewtopic.php?t=970&p=3311#p3311 <![CDATA[GPIO interrupt using RTOS SDK: how to?]]>
I am trying to set up GPIO-based interrupt using the RTOS SDK (see code below).

It seems I need to use the gpio_pin_intr_state_set() function but it is missing from the SDK libraries. Any help would be greatly appreciated!

Best,
Emmanuel

void main_int_handler()
{
printf("main_int_callback!\n");
int i;
uint32 gpio_status = GPIO_REG_READ(GPIO_STATUS_ADDRESS);
uint32 gpio_mask = _xt_read_ints();
printf("Generic interrupt gpio_mask= 0x%08x, status = 0x%08x\n",gpio_mask,gpio_status);
for (i=0 ; i<16 ; i++) {
if ((0x1<<i) & gpio_status) {
printf("Mask set %d\n",i);
}
}

void registerInterrupt(int pin, GPIO_INT_TYPE mode)
{
portENTER_CRITICAL();

// disable open drain
GPIO_REG_WRITE(GPIO_PIN_ADDR(GPIO_ID_PIN(pin)),
GPIO_REG_READ(GPIO_PIN_ADDR(GPIO_ID_PIN(pin))) & (~ GPIO_PIN_PAD_DRIVER_SET(GPIO_PAD_DRIVER_ENABLE)));

//clear interrupt status
GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, BIT(pin));

// set the mode
_xt_isr_unmask(1<<ETS_GPIO_INUM);
//gpio_pin_intr_state_set(GPIO_ID_PIN(pin), mode); // does not link if this line is enabled...
portENABLE_INTERRUPTS();

portEXIT_CRITICAL();
}

in user_init():

_xt_isr_attach(ETS_GPIO_INUM, (_xt_isr)main_int_handler, NULL);
_xt_isr_unmask(1<<ETS_GPIO_INUM);
registerInterrupt(15, GPIO_PIN_INTR_ANYEDGE); // setting INT on GPIO15

Statistics: Posted by ecl66 — Wed Aug 19, 2015 4:26 pm


]]>