esp_mqtt icon indicating copy to clipboard operation
esp_mqtt copied to clipboard

Interrupt attachment in c not working

Open bastianhjaeger opened this issue 6 years ago • 3 comments

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);
}

bastianhjaeger avatar Jul 02 '18 21:07 bastianhjaeger

Using the scripting language is no option?

martin-ger avatar Jul 02 '18 21:07 martin-ger

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

bastianhjaeger avatar Jul 02 '18 21:07 bastianhjaeger

Any idea?

bastianhjaeger avatar Jul 03 '18 19:07 bastianhjaeger