diff --git a/src/hal/hal.cpp b/src/hal/hal.cpp index 6e72a585..03efb8fc 100644 --- a/src/hal/hal.cpp +++ b/src/hal/hal.cpp @@ -118,27 +118,16 @@ void hal_pollPendingIRQs_helper() { #else // Interrupt handlers -static void hal_isrPin0() { - if (interrupt_time[0] == 0) { +template +static ICACHE_RAM_ATTR void hal_isrPin() { + if (interrupt_time[i] == 0) { ostime_t now = os_getTime(); - interrupt_time[0] = now ? now : 1; - } -} -static void hal_isrPin1() { - if (interrupt_time[1] == 0) { - ostime_t now = os_getTime(); - interrupt_time[1] = now ? now : 1; - } -} -static void hal_isrPin2() { - if (interrupt_time[2] == 0) { - ostime_t now = os_getTime(); - interrupt_time[2] = now ? now : 1; + interrupt_time[i] = now ? now : 1; } } typedef void (*isr_t)(); -static const isr_t interrupt_fns[NUM_DIO_INTERRUPT] = {hal_isrPin0, hal_isrPin1, hal_isrPin2}; +static const isr_t interrupt_fns[NUM_DIO_INTERRUPT] = {hal_isrPin<0>, hal_isrPin<1>, hal_isrPin<2>}; static_assert(NUM_DIO_INTERRUPT == 3, "number of interrupts must be 3 for initializing interrupt_fns[]"); static void hal_interrupt_init() { diff --git a/src/lmic/lmic.h b/src/lmic/lmic.h index 9463fa29..f9154ebd 100644 --- a/src/lmic/lmic.h +++ b/src/lmic/lmic.h @@ -92,6 +92,8 @@ # define LMIC_X_DEBUG_PRINTF(f, ...) do {;} while(0) #endif +#define LMIC_DEBUG_TRACE LMIC_DEBUG_PRINTF("*** Trace *** %s\n", __func__) + #ifdef __cplusplus extern "C"{ #endif