From a06010e08a377f5048661edf898c5ee8dd3f428c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 16 Sep 2019 20:18:02 -0500 Subject: [PATCH] Macrofy attachInterrupt --- Marlin/src/HAL/HAL_AVR/endstop_interrupts.h | 69 ++++++------------- Marlin/src/HAL/HAL_DUE/endstop_interrupts.h | 23 ++++--- Marlin/src/HAL/HAL_ESP32/endstop_interrupts.h | 23 ++++--- .../src/HAL/HAL_LPC1768/endstop_interrupts.h | 45 ++++++------ .../HAL/HAL_TEENSY31_32/endstop_interrupts.h | 30 +++----- .../HAL/HAL_TEENSY35_36/endstop_interrupts.h | 25 +++---- 6 files changed, 91 insertions(+), 124 deletions(-) diff --git a/Marlin/src/HAL/HAL_AVR/endstop_interrupts.h b/Marlin/src/HAL/HAL_AVR/endstop_interrupts.h index c313f95ce..0266381c8 100644 --- a/Marlin/src/HAL/HAL_AVR/endstop_interrupts.h +++ b/Marlin/src/HAL/HAL_AVR/endstop_interrupts.h @@ -102,153 +102,124 @@ void pciSetup(const int8_t pin) { ISR(PCINT3_vect, ISR_ALIASOF(PCINT0_vect)); #endif -void setup_endstop_interrupts( void ) { - +void setup_endstop_interrupts(void) { + #define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE) #if HAS_X_MAX - #if (digitalPinToInterrupt(X_MAX_PIN) != NOT_AN_INTERRUPT) // if pin has an external interrupt - attachInterrupt(digitalPinToInterrupt(X_MAX_PIN), endstop_ISR, CHANGE); // assign it + #if (digitalPinToInterrupt(X_MAX_PIN) != NOT_AN_INTERRUPT) + _ATTACH(X_MAX_PIN); #else - // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration! - static_assert(digitalPinToPCICR(X_MAX_PIN), "X_MAX_PIN is not interrupt-capable"); // if pin has no pin change interrupt - error - pciSetup(X_MAX_PIN); // assign it + static_assert(digitalPinToPCICR(X_MAX_PIN), "X_MAX_PIN is not interrupt-capable"); + pciSetup(X_MAX_PIN); #endif #endif - #if HAS_X_MIN #if (digitalPinToInterrupt(X_MIN_PIN) != NOT_AN_INTERRUPT) - attachInterrupt(digitalPinToInterrupt(X_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(X_MIN_PIN); #else - // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration! static_assert(digitalPinToPCICR(X_MIN_PIN), "X_MIN_PIN is not interrupt-capable"); pciSetup(X_MIN_PIN); #endif #endif - #if HAS_Y_MAX #if (digitalPinToInterrupt(Y_MAX_PIN) != NOT_AN_INTERRUPT) - attachInterrupt(digitalPinToInterrupt(Y_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(Y_MAX_PIN); #else - // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration! static_assert(digitalPinToPCICR(Y_MAX_PIN), "Y_MAX_PIN is not interrupt-capable"); pciSetup(Y_MAX_PIN); #endif #endif - #if HAS_Y_MIN #if (digitalPinToInterrupt(Y_MIN_PIN) != NOT_AN_INTERRUPT) - attachInterrupt(digitalPinToInterrupt(Y_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(Y_MIN_PIN); #else - // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration! static_assert(digitalPinToPCICR(Y_MIN_PIN), "Y_MIN_PIN is not interrupt-capable"); pciSetup(Y_MIN_PIN); #endif #endif - #if HAS_Z_MAX #if (digitalPinToInterrupt(Z_MAX_PIN) != NOT_AN_INTERRUPT) - attachInterrupt(digitalPinToInterrupt(Z_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(Z_MAX_PIN); #else - // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration! static_assert(digitalPinToPCICR(Z_MAX_PIN), "Z_MAX_PIN is not interrupt-capable"); pciSetup(Z_MAX_PIN); #endif #endif - #if HAS_Z_MIN #if (digitalPinToInterrupt(Z_MIN_PIN) != NOT_AN_INTERRUPT) - attachInterrupt(digitalPinToInterrupt(Z_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(Z_MIN_PIN); #else - // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration! static_assert(digitalPinToPCICR(Z_MIN_PIN), "Z_MIN_PIN is not interrupt-capable"); pciSetup(Z_MIN_PIN); #endif #endif - #if HAS_X2_MAX #if (digitalPinToInterrupt(X2_MAX_PIN) != NOT_AN_INTERRUPT) - attachInterrupt(digitalPinToInterrupt(X2_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(X2_MAX_PIN); #else - // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration! static_assert(digitalPinToPCICR(X2_MAX_PIN), "X2_MAX_PIN is not interrupt-capable"); pciSetup(X2_MAX_PIN); #endif #endif - #if HAS_X2_MIN #if (digitalPinToInterrupt(X2_MIN_PIN) != NOT_AN_INTERRUPT) - attachInterrupt(digitalPinToInterrupt(X2_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(X2_MIN_PIN); #else - // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration! static_assert(digitalPinToPCICR(X2_MIN_PIN), "X2_MIN_PIN is not interrupt-capable"); pciSetup(X2_MIN_PIN); #endif #endif - #if HAS_Y2_MAX #if (digitalPinToInterrupt(Y2_MAX_PIN) != NOT_AN_INTERRUPT) - attachInterrupt(digitalPinToInterrupt(Y2_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(Y2_MAX_PIN); #else - // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration! static_assert(digitalPinToPCICR(Y2_MAX_PIN), "Y2_MAX_PIN is not interrupt-capable"); pciSetup(Y2_MAX_PIN); #endif #endif - #if HAS_Y2_MIN #if (digitalPinToInterrupt(Y2_MIN_PIN) != NOT_AN_INTERRUPT) - attachInterrupt(digitalPinToInterrupt(Y2_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(Y2_MIN_PIN); #else - // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration! static_assert(digitalPinToPCICR(Y2_MIN_PIN), "Y2_MIN_PIN is not interrupt-capable"); pciSetup(Y2_MIN_PIN); #endif #endif - #if HAS_Z2_MAX #if (digitalPinToInterrupt(Z2_MAX_PIN) != NOT_AN_INTERRUPT) - attachInterrupt(digitalPinToInterrupt(Z2_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(Z2_MAX_PIN); #else - // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration! static_assert(digitalPinToPCICR(Z2_MAX_PIN), "Z2_MAX_PIN is not interrupt-capable"); pciSetup(Z2_MAX_PIN); #endif #endif - #if HAS_Z2_MIN #if (digitalPinToInterrupt(Z2_MIN_PIN) != NOT_AN_INTERRUPT) - attachInterrupt(digitalPinToInterrupt(Z2_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(Z2_MIN_PIN); #else - // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration! static_assert(digitalPinToPCICR(Z2_MIN_PIN), "Z2_MIN_PIN is not interrupt-capable"); pciSetup(Z2_MIN_PIN); #endif #endif - #if HAS_Z3_MAX #if (digitalPinToInterrupt(Z3_MAX_PIN) != NOT_AN_INTERRUPT) - attachInterrupt(digitalPinToInterrupt(Z3_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(Z3_MAX_PIN); #else - // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration! static_assert(digitalPinToPCICR(Z3_MAX_PIN), "Z3_MAX_PIN is not interrupt-capable"); pciSetup(Z3_MAX_PIN); #endif #endif - #if HAS_Z3_MIN #if (digitalPinToInterrupt(Z3_MIN_PIN) != NOT_AN_INTERRUPT) - attachInterrupt(digitalPinToInterrupt(Z3_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(Z3_MIN_PIN); #else - // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration! static_assert(digitalPinToPCICR(Z3_MIN_PIN), "Z3_MIN_PIN is not interrupt-capable"); pciSetup(Z3_MIN_PIN); #endif #endif - #if HAS_Z_MIN_PROBE_PIN #if (digitalPinToInterrupt(Z_MIN_PROBE_PIN) != NOT_AN_INTERRUPT) - attachInterrupt(digitalPinToInterrupt(Z_MIN_PROBE_PIN), endstop_ISR, CHANGE); + _ATTACH(Z_MIN_PROBE_PIN); #else - // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration! static_assert(digitalPinToPCICR(Z_MIN_PROBE_PIN), "Z_MIN_PROBE_PIN is not interrupt-capable"); pciSetup(Z_MIN_PROBE_PIN); #endif diff --git a/Marlin/src/HAL/HAL_DUE/endstop_interrupts.h b/Marlin/src/HAL/HAL_DUE/endstop_interrupts.h index d97b8453c..909450be7 100644 --- a/Marlin/src/HAL/HAL_DUE/endstop_interrupts.h +++ b/Marlin/src/HAL/HAL_DUE/endstop_interrupts.h @@ -46,37 +46,38 @@ void endstop_ISR(void) { endstops.update(); } */ void setup_endstop_interrupts(void) { + #define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE) #if HAS_X_MAX - attachInterrupt(digitalPinToInterrupt(X_MAX_PIN), endstop_ISR, CHANGE); // assign it + _ATTACH(X_MAX_PIN); #endif #if HAS_X_MIN - attachInterrupt(digitalPinToInterrupt(X_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(X_MIN_PIN); #endif #if HAS_Y_MAX - attachInterrupt(digitalPinToInterrupt(Y_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(Y_MAX_PIN); #endif #if HAS_Y_MIN - attachInterrupt(digitalPinToInterrupt(Y_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(Y_MIN_PIN); #endif #if HAS_Z_MAX - attachInterrupt(digitalPinToInterrupt(Z_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(Z_MAX_PIN); #endif #if HAS_Z_MIN - attachInterrupt(digitalPinToInterrupt(Z_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(Z_MIN_PIN); #endif #if HAS_Z2_MAX - attachInterrupt(digitalPinToInterrupt(Z2_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(Z2_MAX_PIN); #endif #if HAS_Z2_MIN - attachInterrupt(digitalPinToInterrupt(Z2_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(Z2_MIN_PIN); #endif #if HAS_Z3_MAX - attachInterrupt(digitalPinToInterrupt(Z3_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(Z3_MAX_PIN); #endif #if HAS_Z3_MIN - attachInterrupt(digitalPinToInterrupt(Z3_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(Z3_MIN_PIN); #endif #if HAS_Z_MIN_PROBE_PIN - attachInterrupt(digitalPinToInterrupt(Z_MIN_PROBE_PIN), endstop_ISR, CHANGE); + _ATTACH(Z_MIN_PROBE_PIN); #endif } diff --git a/Marlin/src/HAL/HAL_ESP32/endstop_interrupts.h b/Marlin/src/HAL/HAL_ESP32/endstop_interrupts.h index 9e5fc8a66..800488379 100644 --- a/Marlin/src/HAL/HAL_ESP32/endstop_interrupts.h +++ b/Marlin/src/HAL/HAL_ESP32/endstop_interrupts.h @@ -41,37 +41,38 @@ void ICACHE_RAM_ATTR endstop_ISR(void) { endstops.update(); } void setup_endstop_interrupts(void) { + #define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE) #if HAS_X_MAX - attachInterrupt(digitalPinToInterrupt(X_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(X_MAX_PIN); #endif #if HAS_X_MIN - attachInterrupt(digitalPinToInterrupt(X_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(X_MIN_PIN); #endif #if HAS_Y_MAX - attachInterrupt(digitalPinToInterrupt(Y_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(Y_MAX_PIN); #endif #if HAS_Y_MIN - attachInterrupt(digitalPinToInterrupt(Y_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(Y_MIN_PIN); #endif #if HAS_Z_MAX - attachInterrupt(digitalPinToInterrupt(Z_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(Z_MAX_PIN); #endif #if HAS_Z_MIN - attachInterrupt(digitalPinToInterrupt(Z_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(Z_MIN_PIN); #endif #if HAS_Z2_MAX - attachInterrupt(digitalPinToInterrupt(Z2_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(Z2_MAX_PIN); #endif #if HAS_Z2_MIN - attachInterrupt(digitalPinToInterrupt(Z2_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(Z2_MIN_PIN); #endif #if HAS_Z3_MAX - attachInterrupt(digitalPinToInterrupt(Z3_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(Z3_MAX_PIN); #endif #if HAS_Z3_MIN - attachInterrupt(digitalPinToInterrupt(Z3_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(Z3_MIN_PIN); #endif #if HAS_Z_MIN_PROBE_PIN - attachInterrupt(digitalPinToInterrupt(Z_MIN_PROBE_PIN), endstop_ISR, CHANGE); + _ATTACH(Z_MIN_PROBE_PIN); #endif } diff --git a/Marlin/src/HAL/HAL_LPC1768/endstop_interrupts.h b/Marlin/src/HAL/HAL_LPC1768/endstop_interrupts.h index a1d9aba16..b1da0ce0f 100644 --- a/Marlin/src/HAL/HAL_LPC1768/endstop_interrupts.h +++ b/Marlin/src/HAL/HAL_LPC1768/endstop_interrupts.h @@ -41,70 +41,71 @@ void endstop_ISR(void) { endstops.update(); } void setup_endstop_interrupts(void) { + #define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE) #if HAS_X_MAX #if !LPC1768_PIN_INTERRUPT_M(X_MAX_PIN) - #error "X_MAX_PIN is not an INTERRUPT capable pin." + #error "X_MAX_PIN is not INTERRUPT-capable." #endif - attachInterrupt(digitalPinToInterrupt(X_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(X_MAX_PIN); #endif #if HAS_X_MIN #if !LPC1768_PIN_INTERRUPT_M(X_MIN_PIN) - #error "X_MIN_PIN is not an INTERRUPT capable pin." + #error "X_MIN_PIN is not INTERRUPT-capable." #endif - attachInterrupt(digitalPinToInterrupt(X_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(X_MIN_PIN); #endif #if HAS_Y_MAX #if !LPC1768_PIN_INTERRUPT_M(Y_MAX_PIN) - #error "Y_MAX_PIN is not an INTERRUPT capable pin." + #error "Y_MAX_PIN is not INTERRUPT-capable." #endif - attachInterrupt(digitalPinToInterrupt(Y_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(Y_MAX_PIN); #endif #if HAS_Y_MIN #if !LPC1768_PIN_INTERRUPT_M(Y_MIN_PIN) - #error "Y_MIN_PIN is not an INTERRUPT capable pin." + #error "Y_MIN_PIN is not INTERRUPT-capable." #endif - attachInterrupt(digitalPinToInterrupt(Y_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(Y_MIN_PIN); #endif #if HAS_Z_MAX #if !LPC1768_PIN_INTERRUPT_M(Z_MAX_PIN) - #error "Z_MAX_PIN is not an INTERRUPT capable pin." + #error "Z_MAX_PIN is not INTERRUPT-capable." #endif - attachInterrupt(digitalPinToInterrupt(Z_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(Z_MAX_PIN); #endif #if HAS_Z_MIN #if !LPC1768_PIN_INTERRUPT_M(Z_MIN_PIN) - #error "Z_MIN_PIN is not an INTERRUPT capable pin." + #error "Z_MIN_PIN is not INTERRUPT-capable." #endif - attachInterrupt(digitalPinToInterrupt(Z_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(Z_MIN_PIN); #endif #if HAS_Z2_MAX #if !LPC1768_PIN_INTERRUPT_M(Z2_MAX_PIN) - #error "Z2_MAX_PIN is not an INTERRUPT capable pin." + #error "Z2_MAX_PIN is not INTERRUPT-capable." #endif - attachInterrupt(digitalPinToInterrupt(Z2_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(Z2_MAX_PIN); #endif #if HAS_Z2_MIN #if !LPC1768_PIN_INTERRUPT_M(Z2_MIN_PIN) - #error "Z2_MIN_PIN is not an INTERRUPT capable pin." + #error "Z2_MIN_PIN is not INTERRUPT-capable." #endif - attachInterrupt(digitalPinToInterrupt(Z2_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(Z2_MIN_PIN); #endif #if HAS_Z3_MAX #if !LPC1768_PIN_INTERRUPT_M(Z3_MIN_PIN) - #error "Z3_MIN_PIN is not an INTERRUPT capable pin." + #error "Z3_MIN_PIN is not INTERRUPT-capable." #endif - attachInterrupt(digitalPinToInterrupt(Z3_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(Z3_MAX_PIN); #endif #if HAS_Z3_MIN #if !LPC1768_PIN_INTERRUPT_M(Z3_MIN_PIN) - #error "Z3_MIN_PIN is not an INTERRUPT capable pin." + #error "Z3_MIN_PIN is not INTERRUPT-capable." #endif - attachInterrupt(digitalPinToInterrupt(Z3_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(Z3_MIN_PIN); #endif #if HAS_Z_MIN_PROBE_PIN #if !LPC1768_PIN_INTERRUPT_M(Z_MIN_PROBE_PIN) - #error "Z_MIN_PROBE_PIN is not an INTERRUPT capable pin." + #error "Z_MIN_PROBE_PIN is not INTERRUPT-capable." #endif - attachInterrupt(digitalPinToInterrupt(Z_MIN_PROBE_PIN), endstop_ISR, CHANGE); + _ATTACH(Z_MIN_PROBE_PIN); #endif } diff --git a/Marlin/src/HAL/HAL_TEENSY31_32/endstop_interrupts.h b/Marlin/src/HAL/HAL_TEENSY31_32/endstop_interrupts.h index 743f91781..6dea12f5e 100644 --- a/Marlin/src/HAL/HAL_TEENSY31_32/endstop_interrupts.h +++ b/Marlin/src/HAL/HAL_TEENSY31_32/endstop_interrupts.h @@ -45,41 +45,33 @@ void endstop_ISR(void) { endstops.update(); } * On Due, all pins support external interrupt capability. */ -void setup_endstop_interrupts( void ) { - +void setup_endstop_interrupts(void) { + #define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE) #if HAS_X_MAX - attachInterrupt(digitalPinToInterrupt(X_MAX_PIN), endstop_ISR, CHANGE); // assign it + _ATTACH(X_MAX_PIN); #endif - #if HAS_X_MIN - attachInterrupt(digitalPinToInterrupt(X_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(X_MIN_PIN); #endif - #if HAS_Y_MAX - attachInterrupt(digitalPinToInterrupt(Y_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(Y_MAX_PIN); #endif - #if HAS_Y_MIN - attachInterrupt(digitalPinToInterrupt(Y_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(Y_MIN_PIN); #endif - #if HAS_Z_MAX - attachInterrupt(digitalPinToInterrupt(Z_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(Z_MAX_PIN); #endif - #if HAS_Z_MIN - attachInterrupt(digitalPinToInterrupt(Z_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(Z_MIN_PIN); #endif - #if HAS_Z2_MAX - attachInterrupt(digitalPinToInterrupt(Z2_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(Z2_MAX_PIN); #endif - #if HAS_Z2_MIN - attachInterrupt(digitalPinToInterrupt(Z2_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(Z2_MIN_PIN); #endif - #if HAS_Z_MIN_PROBE_PIN - attachInterrupt(digitalPinToInterrupt(Z_MIN_PROBE_PIN), endstop_ISR, CHANGE); + _ATTACH(Z_MIN_PROBE_PIN); #endif } diff --git a/Marlin/src/HAL/HAL_TEENSY35_36/endstop_interrupts.h b/Marlin/src/HAL/HAL_TEENSY35_36/endstop_interrupts.h index 137cb472e..f9950cc5a 100644 --- a/Marlin/src/HAL/HAL_TEENSY35_36/endstop_interrupts.h +++ b/Marlin/src/HAL/HAL_TEENSY35_36/endstop_interrupts.h @@ -44,38 +44,39 @@ void endstop_ISR(void) { endstops.update(); } * Endstop interrupts for Due based targets. * On Due, all pins support external interrupt capability. */ -void setup_endstop_interrupts( void ) { +void setup_endstop_interrupts(void) { + #define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE) #if HAS_X_MAX - attachInterrupt(digitalPinToInterrupt(X_MAX_PIN), endstop_ISR, CHANGE); // assign it + _ATTACH(X_MAX_PIN); #endif #if HAS_X_MIN - attachInterrupt(digitalPinToInterrupt(X_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(X_MIN_PIN); #endif #if HAS_Y_MAX - attachInterrupt(digitalPinToInterrupt(Y_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(Y_MAX_PIN); #endif #if HAS_Y_MIN - attachInterrupt(digitalPinToInterrupt(Y_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(Y_MIN_PIN); #endif #if HAS_Z_MAX - attachInterrupt(digitalPinToInterrupt(Z_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(Z_MAX_PIN); #endif #if HAS_Z_MIN - attachInterrupt(digitalPinToInterrupt(Z_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(Z_MIN_PIN); #endif #if HAS_Z2_MAX - attachInterrupt(digitalPinToInterrupt(Z2_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(Z2_MAX_PIN); #endif #if HAS_Z2_MIN - attachInterrupt(digitalPinToInterrupt(Z2_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(Z2_MIN_PIN); #endif #if HAS_Z3_MAX - attachInterrupt(digitalPinToInterrupt(Z3_MAX_PIN), endstop_ISR, CHANGE); + _ATTACH(Z3_MAX_PIN); #endif #if HAS_Z3_MIN - attachInterrupt(digitalPinToInterrupt(Z3_MIN_PIN), endstop_ISR, CHANGE); + _ATTACH(Z3_MIN_PIN); #endif #if HAS_Z_MIN_PROBE_PIN - attachInterrupt(digitalPinToInterrupt(Z_MIN_PROBE_PIN), endstop_ISR, CHANGE); + _ATTACH(Z_MIN_PROBE_PIN); #endif }