esp8266_easygpio icon indicating copy to clipboard operation
esp8266_easygpio copied to clipboard

Interrupt attachment not working

Open bastianhjaeger opened this issue 7 years ago • 0 comments

How do I add a interrupt to GPIO 0

This seems not to work. Not sure if I need easygpio_pinMode before easygpio_attachInterrupt? I thought I might have forgotten some init function or similar, but I can not find any reference to it. What is wrong?

#include "osapi.h"
#include "easygpio.h"

int interruptOne = 42;

static void sonoffBtnInterrupt(void* arg) {
  uint8_t value = easygpio_inputGet(13);
  easygpio_outputSet(13, !value);
}

void ICACHE_FLASH_ATTR user_init() {
  easygpio_pinMode(13, EASYGPIO_PULLUP, EASYGPIO_OUTPUT);
  easygpio_outputSet(13, 0); // turn on

  //easygpio_pinMode(0, EASYGPIO_PULLUP, EASYGPIO_INPUT);
  bool success = easygpio_attachInterrupt(0, EASYGPIO_PULLUP, sonoffBtnInterrupt, &interruptOne);
  os_printf("easygpio_attachInterrupt success: %d\r\n", success);
}

Thanks in advance!

bastianhjaeger avatar Jul 03 '18 19:07 bastianhjaeger