2017-09-27 00:30:23 -05:00
|
|
|
|
/**
|
|
|
|
|
* Marlin 3D Printer Firmware
|
2019-06-27 23:57:50 -05:00
|
|
|
|
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2017-09-27 00:30:23 -05:00
|
|
|
|
*
|
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-27 23:57:50 -05:00
|
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
|
|
|
* Copyright (c) 2017 Victor Perez
|
2017-09-27 00:30:23 -05: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 02:25:55 -06:00
|
|
|
|
#pragma once
|
2017-09-27 00:30:23 -05:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Endstop interrupts for Libmaple STM32F1 based targets.
|
|
|
|
|
*
|
|
|
|
|
* On STM32F, all pins support external interrupt capability.
|
|
|
|
|
* Any pin can be used for external interrupts, but there are some restrictions.
|
|
|
|
|
* At most 16 different external interrupts can be used at one time.
|
|
|
|
|
* Further, you can’t just pick any 16 pins to use. This is because every pin on the STM32
|
|
|
|
|
* connects to what is called an EXTI line, and only one pin per EXTI line can be used for external interrupts at a time
|
|
|
|
|
* Check the Reference Manual of the MCU to confirm which line is used by each pin
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Endstop Interrupts
|
|
|
|
|
*
|
|
|
|
|
* Without endstop interrupts the endstop pins must be polled continually in
|
2018-05-16 02:08:43 -05:00
|
|
|
|
* the temperature-ISR via endstops.update(), most of the time finding no change.
|
2017-09-27 00:30:23 -05: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 02:08:43 -05:00
|
|
|
|
#include "../../module/endstops.h"
|
2018-04-12 20:25:08 -05:00
|
|
|
|
|
|
|
|
|
// One ISR for all EXT-Interrupts
|
2019-09-16 20:31:08 -05:00
|
|
|
|
void endstop_ISR() { endstops.update(); }
|
2018-04-12 20:25:08 -05:00
|
|
|
|
|
2019-09-16 20:31:08 -05:00
|
|
|
|
void setup_endstop_interrupts() {
|
2017-09-27 00:30:23 -05:00
|
|
|
|
#if HAS_X_MAX
|
|
|
|
|
attachInterrupt(X_MAX_PIN, endstop_ISR, CHANGE); // assign it
|
|
|
|
|
#endif
|
|
|
|
|
#if HAS_X_MIN
|
|
|
|
|
attachInterrupt(X_MIN_PIN, endstop_ISR, CHANGE);
|
|
|
|
|
#endif
|
|
|
|
|
#if HAS_Y_MAX
|
|
|
|
|
attachInterrupt(Y_MAX_PIN, endstop_ISR, CHANGE);
|
|
|
|
|
#endif
|
|
|
|
|
#if HAS_Y_MIN
|
|
|
|
|
attachInterrupt(Y_MIN_PIN, endstop_ISR, CHANGE);
|
|
|
|
|
#endif
|
|
|
|
|
#if HAS_Z_MAX
|
|
|
|
|
attachInterrupt(Z_MAX_PIN, endstop_ISR, CHANGE);
|
|
|
|
|
#endif
|
|
|
|
|
#if HAS_Z_MIN
|
|
|
|
|
attachInterrupt(Z_MIN_PIN, endstop_ISR, CHANGE);
|
|
|
|
|
#endif
|
|
|
|
|
#if HAS_Z2_MAX
|
|
|
|
|
attachInterrupt(Z2_MAX_PIN, endstop_ISR, CHANGE);
|
|
|
|
|
#endif
|
|
|
|
|
#if HAS_Z2_MIN
|
|
|
|
|
attachInterrupt(Z2_MIN_PIN, endstop_ISR, CHANGE);
|
|
|
|
|
#endif
|
2018-06-19 11:55:49 -05:00
|
|
|
|
#if HAS_Z3_MAX
|
|
|
|
|
attachInterrupt(Z3_MAX_PIN, endstop_ISR, CHANGE);
|
|
|
|
|
#endif
|
|
|
|
|
#if HAS_Z3_MIN
|
|
|
|
|
attachInterrupt(Z3_MIN_PIN, endstop_ISR, CHANGE);
|
|
|
|
|
#endif
|
2017-09-27 00:30:23 -05:00
|
|
|
|
#if HAS_Z_MIN_PROBE_PIN
|
|
|
|
|
attachInterrupt(Z_MIN_PROBE_PIN, endstop_ISR, CHANGE);
|
|
|
|
|
#endif
|
|
|
|
|
}
|