martin-ger / esp_mqtt

MQTT Broker/Bridge on the ESP8266
MIT License
293 stars 68 forks source link

Interrupt attachment in c not working #41

Open bastianhjaeger opened 6 years ago

bastianhjaeger commented 6 years ago

How do I add a interrupt to GPIO 0

This seems not to work (derived from user_basic/user_main.c):

#include "user_interface.h"
#include "mqtt/mqtt_server.h"
#include "user_config.h"
#include "easygpio.h"

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

int interruptOne = 42;

void ICACHE_FLASH_ATTR user_init() {
  struct station_config stationConf;

  // Initialize the UART
  uart_div_modify(0, UART_CLK_FREQ / 115200);

  os_printf("\r\n\r\nMQTT Broker starting\r\n");

  // Setup STA
  ...
  // Allow larger number of TCP (=MQTT) clients
  ...

  easygpio_pinMode(13, EASYGPIO_PULLUP, EASYGPIO_OUTPUT);
  easygpio_outputSet(13, 0); // turn on

  //easygpio_pinMode(0, EASYGPIO_PULLUP, EASYGPIO_INPUT);
  easygpio_attachInterrupt(0, EASYGPIO_PULLUP, &sonoffBtnInterrupt, &interruptOne);

  //Start MQTT broker
  MQTT_server_start(MQTT_PORT, MQTT_MAX_SUBSCRIPTIONS, MQTT_MAX_RETAINED_TOPICS);
}
martin-ger commented 6 years ago

Using the scripting language is no option?

bastianhjaeger commented 6 years ago

No. I tried backtracking from the script method, but unfortunately do not see the issue.

bastianhjaeger commented 6 years ago

Any idea?