2017-07-11 20:59:27 +00:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2020-02-03 14:00:57 +00:00
|
|
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2017-07-11 20:59:27 +00:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-28 04:57:50 +00:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2017-07-11 20:59:27 +00: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
|
2020-07-23 03:20:14 +00:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2017-07-11 20:59:27 +00:00
|
|
|
*
|
|
|
|
*/
|
2018-11-04 08:25:55 +00:00
|
|
|
#pragma once
|
2017-07-11 20:59:27 +00:00
|
|
|
|
|
|
|
/**
|
2020-10-02 22:05:45 +00:00
|
|
|
* HAL Endstop Interrupts for Teensy 3.5 (MK64FX512) and Teensy 3.6 (MK66FX1M0)
|
2017-07-11 20:59:27 +00:00
|
|
|
*
|
|
|
|
* Without endstop interrupts the endstop pins must be polled continually in
|
2018-05-16 07:08:43 +00:00
|
|
|
* the temperature-ISR via endstops.update(), most of the time finding no change.
|
2017-07-11 20:59:27 +00: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 07:08:43 +00:00
|
|
|
#include "../../module/endstops.h"
|
2018-04-13 01:25:08 +00:00
|
|
|
|
|
|
|
// One ISR for all EXT-Interrupts
|
2019-09-17 01:31:08 +00:00
|
|
|
void endstop_ISR() { endstops.update(); }
|
2017-07-11 20:59:27 +00:00
|
|
|
|
|
|
|
/**
|
2018-06-19 16:55:49 +00:00
|
|
|
* Endstop interrupts for Due based targets.
|
|
|
|
* On Due, all pins support external interrupt capability.
|
2017-07-11 20:59:27 +00:00
|
|
|
*/
|
2019-09-17 01:31:08 +00:00
|
|
|
void setup_endstop_interrupts() {
|
2019-09-17 01:18:02 +00:00
|
|
|
#define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE)
|
2020-04-22 21:35:03 +00:00
|
|
|
TERN_(HAS_X_MAX, _ATTACH(X_MAX_PIN));
|
|
|
|
TERN_(HAS_X_MIN, _ATTACH(X_MIN_PIN));
|
|
|
|
TERN_(HAS_Y_MAX, _ATTACH(Y_MAX_PIN));
|
|
|
|
TERN_(HAS_Y_MIN, _ATTACH(Y_MIN_PIN));
|
|
|
|
TERN_(HAS_Z_MAX, _ATTACH(Z_MAX_PIN));
|
|
|
|
TERN_(HAS_Z_MIN, _ATTACH(Z_MIN_PIN));
|
|
|
|
TERN_(HAS_X2_MAX, _ATTACH(X2_MAX_PIN));
|
|
|
|
TERN_(HAS_X2_MIN, _ATTACH(X2_MIN_PIN));
|
|
|
|
TERN_(HAS_Y2_MAX, _ATTACH(Y2_MAX_PIN));
|
|
|
|
TERN_(HAS_Y2_MIN, _ATTACH(Y2_MIN_PIN));
|
|
|
|
TERN_(HAS_Z2_MAX, _ATTACH(Z2_MAX_PIN));
|
|
|
|
TERN_(HAS_Z2_MIN, _ATTACH(Z2_MIN_PIN));
|
|
|
|
TERN_(HAS_Z3_MAX, _ATTACH(Z3_MAX_PIN));
|
|
|
|
TERN_(HAS_Z3_MIN, _ATTACH(Z3_MIN_PIN));
|
|
|
|
TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
|
|
|
|
TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
|
|
|
|
TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
|
2017-07-11 20:59:27 +00:00
|
|
|
}
|