From e15011009bed7e6fb225dbe68e4ab73bdb828720 Mon Sep 17 00:00:00 2001 From: David Gauchard Date: Tue, 10 Mar 2020 12:24:00 +0100 Subject: [PATCH] fix for esp8266 and esp32 when LMIC_USE_INTERRUPTS is used --- src/hal/hal.cpp | 3 +++ src/lmic/config.h | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/src/hal/hal.cpp b/src/hal/hal.cpp index 62271b49..d1f16e8a 100644 --- a/src/hal/hal.cpp +++ b/src/hal/hal.cpp @@ -109,14 +109,17 @@ static void hal_io_check() { // Interrupt handlers static ostime_t interrupt_time[NUM_DIO] = {0}; +LMIC_ISR_ATTR static void hal_isrPin0() { ostime_t now = os_getTime(); interrupt_time[0] = now ? now : 1; } +LMIC_ISR_ATTR static void hal_isrPin1() { ostime_t now = os_getTime(); interrupt_time[1] = now ? now : 1; } +LMIC_ISR_ATTR static void hal_isrPin2() { ostime_t now = os_getTime(); interrupt_time[2] = now ? now : 1; diff --git a/src/lmic/config.h b/src/lmic/config.h index 8673b46a..cc14614e 100644 --- a/src/lmic/config.h +++ b/src/lmic/config.h @@ -212,4 +212,11 @@ # define LMIC_ENABLE_arbitrary_clock_error 0 /* PARAM */ #endif +#if defined(ESP8266) || defined(ESP32) +// functions called from an interrupt context need this attribute +#define LMIC_ISR_ATTR ICACHE_RAM_ATTR +#else +#define LMIC_ISR_ATTR +#endif + #endif // _lmic_config_h_