2017-06-17 23:19:42 +02:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2019-06-28 06:57:50 +02:00
|
|
|
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2017-06-17 23:19:42 +02:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-28 06:57:50 +02:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2017-06-17 23:19:42 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
2018-11-04 09:25:55 +01:00
|
|
|
#pragma once
|
2017-06-17 23:19:42 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Endstop Interrupts
|
|
|
|
*
|
|
|
|
* Without endstop interrupts the endstop pins must be polled continually in
|
2018-05-16 09:08:43 +02:00
|
|
|
* the temperature-ISR via endstops.update(), most of the time finding no change.
|
2017-06-17 23:19:42 +02:00
|
|
|
* With this feature endstops.update() is called only when we know that at
|
|
|
|
* least one endstop has changed state, saving valuable CPU cycles.
|
|
|
|
*
|
|
|
|
* This feature only works when all used endstop pins can generate an 'external interrupt'.
|
|
|
|
*
|
|
|
|
* Test whether pins issue interrupts on your board by flashing 'pin_interrupt_test.ino'.
|
|
|
|
* (Located in Marlin/buildroot/share/pin_interrupt_test/pin_interrupt_test.ino)
|
|
|
|
*/
|
|
|
|
|
2018-05-16 09:08:43 +02:00
|
|
|
#include "../../module/endstops.h"
|
2018-04-13 03:25:08 +02:00
|
|
|
|
|
|
|
// One ISR for all EXT-Interrupts
|
2018-06-22 03:14:16 +02:00
|
|
|
void endstop_ISR(void) { endstops.update(); }
|
2017-06-17 23:19:42 +02:00
|
|
|
|
|
|
|
void setup_endstop_interrupts(void) {
|
|
|
|
#if HAS_X_MAX
|
2018-07-05 00:51:45 +02:00
|
|
|
#if !LPC1768_PIN_INTERRUPT_M(X_MAX_PIN)
|
|
|
|
#error "X_MAX_PIN is not an INTERRUPT capable pin."
|
|
|
|
#endif
|
|
|
|
attachInterrupt(digitalPinToInterrupt(X_MAX_PIN), endstop_ISR, CHANGE);
|
2017-06-17 23:19:42 +02:00
|
|
|
#endif
|
|
|
|
#if HAS_X_MIN
|
2018-07-05 00:51:45 +02:00
|
|
|
#if !LPC1768_PIN_INTERRUPT_M(X_MIN_PIN)
|
|
|
|
#error "X_MIN_PIN is not an INTERRUPT capable pin."
|
|
|
|
#endif
|
2017-06-17 23:19:42 +02:00
|
|
|
attachInterrupt(digitalPinToInterrupt(X_MIN_PIN), endstop_ISR, CHANGE);
|
|
|
|
#endif
|
|
|
|
#if HAS_Y_MAX
|
2018-07-05 00:51:45 +02:00
|
|
|
#if !LPC1768_PIN_INTERRUPT_M(Y_MAX_PIN)
|
|
|
|
#error "Y_MAX_PIN is not an INTERRUPT capable pin."
|
|
|
|
#endif
|
2017-06-17 23:19:42 +02:00
|
|
|
attachInterrupt(digitalPinToInterrupt(Y_MAX_PIN), endstop_ISR, CHANGE);
|
|
|
|
#endif
|
|
|
|
#if HAS_Y_MIN
|
2018-07-05 00:51:45 +02:00
|
|
|
#if !LPC1768_PIN_INTERRUPT_M(Y_MIN_PIN)
|
|
|
|
#error "Y_MIN_PIN is not an INTERRUPT capable pin."
|
|
|
|
#endif
|
2017-06-17 23:19:42 +02:00
|
|
|
attachInterrupt(digitalPinToInterrupt(Y_MIN_PIN), endstop_ISR, CHANGE);
|
|
|
|
#endif
|
|
|
|
#if HAS_Z_MAX
|
2018-07-05 00:51:45 +02:00
|
|
|
#if !LPC1768_PIN_INTERRUPT_M(Z_MAX_PIN)
|
|
|
|
#error "Z_MAX_PIN is not an INTERRUPT capable pin."
|
|
|
|
#endif
|
2017-06-17 23:19:42 +02:00
|
|
|
attachInterrupt(digitalPinToInterrupt(Z_MAX_PIN), endstop_ISR, CHANGE);
|
|
|
|
#endif
|
|
|
|
#if HAS_Z_MIN
|
2018-07-05 00:51:45 +02:00
|
|
|
#if !LPC1768_PIN_INTERRUPT_M(Z_MIN_PIN)
|
|
|
|
#error "Z_MIN_PIN is not an INTERRUPT capable pin."
|
|
|
|
#endif
|
2017-06-17 23:19:42 +02:00
|
|
|
attachInterrupt(digitalPinToInterrupt(Z_MIN_PIN), endstop_ISR, CHANGE);
|
|
|
|
#endif
|
|
|
|
#if HAS_Z2_MAX
|
2018-07-05 00:51:45 +02:00
|
|
|
#if !LPC1768_PIN_INTERRUPT_M(Z2_MAX_PIN)
|
|
|
|
#error "Z2_MAX_PIN is not an INTERRUPT capable pin."
|
|
|
|
#endif
|
2017-06-17 23:19:42 +02:00
|
|
|
attachInterrupt(digitalPinToInterrupt(Z2_MAX_PIN), endstop_ISR, CHANGE);
|
|
|
|
#endif
|
|
|
|
#if HAS_Z2_MIN
|
2018-07-05 00:51:45 +02:00
|
|
|
#if !LPC1768_PIN_INTERRUPT_M(Z2_MIN_PIN)
|
|
|
|
#error "Z2_MIN_PIN is not an INTERRUPT capable pin."
|
|
|
|
#endif
|
2017-06-17 23:19:42 +02:00
|
|
|
attachInterrupt(digitalPinToInterrupt(Z2_MIN_PIN), endstop_ISR, CHANGE);
|
|
|
|
#endif
|
2018-06-19 18:55:49 +02:00
|
|
|
#if HAS_Z3_MAX
|
2018-11-05 13:11:34 +01:00
|
|
|
#if !LPC1768_PIN_INTERRUPT_M(Z3_MIN_PIN)
|
|
|
|
#error "Z3_MIN_PIN is not an INTERRUPT capable pin."
|
|
|
|
#endif
|
2018-06-19 18:55:49 +02:00
|
|
|
attachInterrupt(digitalPinToInterrupt(Z3_MAX_PIN), endstop_ISR, CHANGE);
|
|
|
|
#endif
|
|
|
|
#if HAS_Z3_MIN
|
2018-11-05 13:11:34 +01:00
|
|
|
#if !LPC1768_PIN_INTERRUPT_M(Z3_MIN_PIN)
|
|
|
|
#error "Z3_MIN_PIN is not an INTERRUPT capable pin."
|
|
|
|
#endif
|
2018-06-19 18:55:49 +02:00
|
|
|
attachInterrupt(digitalPinToInterrupt(Z3_MIN_PIN), endstop_ISR, CHANGE);
|
|
|
|
#endif
|
2017-06-17 23:19:42 +02:00
|
|
|
#if HAS_Z_MIN_PROBE_PIN
|
2018-07-05 00:51:45 +02:00
|
|
|
#if !LPC1768_PIN_INTERRUPT_M(Z_MIN_PROBE_PIN)
|
|
|
|
#error "Z_MIN_PROBE_PIN is not an INTERRUPT capable pin."
|
|
|
|
#endif
|
2017-06-17 23:19:42 +02:00
|
|
|
attachInterrupt(digitalPinToInterrupt(Z_MIN_PROBE_PIN), endstop_ISR, CHANGE);
|
|
|
|
#endif
|
|
|
|
}
|