Skip to content

Instantly share code, notes, and snippets.

@davea
Last active June 16, 2017 19:32
Show Gist options
  • Save davea/bd1cf2770724c023224f68cc19998335 to your computer and use it in GitHub Desktop.
Save davea/bd1cf2770724c023224f68cc19998335 to your computer and use it in GitHub Desktop.
Minimal case of interrupt handler causing crash on ESP8266. Compile with `ENABLE_WIFI` to see the crash. For https://github.com/puuu/ESPiLight/pull/9
#include <Arduino.h>
#include <ESPiLight.h>
#ifdef ENABLE_WIFI
#include <ESP8266WiFi.h>
#define WIFI_SSID "myssid"
#define WIFI_PSK "mypassphrase"
#endif
#define TRANSMITTER_PIN -1
#define RECEIVER_PIN 4
ESPiLight rf(TRANSMITTER_PIN);
void rfCallback(const uint16_t* codes, int length) {
Serial.printf("Received length %d\n", length);
}
void setup(void) {
Serial.begin(9600);
#ifdef ENABLE_WIFI
Serial.print(F("Setting up wifi connection..."));
WiFi.disconnect(true);
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PSK);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(F("."));
}
Serial.println(F(" done."));
#endif
rf.setPulseTrainCallBack(rfCallback);
rf.initReceiver(RECEIVER_PIN);
}
void loop(void) {
rf.loop();
delay(10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment