This repository has been archived on 2022-01-28. You can view files and clone it, but cannot push or open issues or pull requests.
Marlin-Artillery-M600/Marlin/src/HAL/ESP32/endstop_interrupts.h

85 lines
2.3 KiB
C
Raw Normal View History

2017-10-08 18:38:10 +02:00
/**
* Marlin 3D Printer Firmware
2020-02-03 15:00:57 +01:00
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
2017-10-08 18:38:10 +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-10-08 18:38:10 +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/>.
*
*/
#pragma once
2017-10-08 18:38:10 +02:00
/**
* Endstop Interrupts
*
* Without endstop interrupts the endstop pins must be polled continually in
* the stepper-ISR via endstops.update(), most of the time finding no change.
* 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)
*/
#include "../../module/endstops.h"
// One ISR for all EXT-Interrupts
2019-09-17 03:31:08 +02:00
void ICACHE_RAM_ATTR endstop_ISR() { endstops.update(); }
2017-10-08 18:38:10 +02:00
2019-09-17 03:31:08 +02:00
void setup_endstop_interrupts() {
2019-09-17 03:18:02 +02:00
#define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE)
2017-10-08 18:38:10 +02:00
#if HAS_X_MAX
2019-09-17 03:18:02 +02:00
_ATTACH(X_MAX_PIN);
2017-10-08 18:38:10 +02:00
#endif
#if HAS_X_MIN
2019-09-17 03:18:02 +02:00
_ATTACH(X_MIN_PIN);
2017-10-08 18:38:10 +02:00
#endif
#if HAS_Y_MAX
2019-09-17 03:18:02 +02:00
_ATTACH(Y_MAX_PIN);
2017-10-08 18:38:10 +02:00
#endif
#if HAS_Y_MIN
2019-09-17 03:18:02 +02:00
_ATTACH(Y_MIN_PIN);
2017-10-08 18:38:10 +02:00
#endif
#if HAS_Z_MAX
2019-09-17 03:18:02 +02:00
_ATTACH(Z_MAX_PIN);
2017-10-08 18:38:10 +02:00
#endif
#if HAS_Z_MIN
2019-09-17 03:18:02 +02:00
_ATTACH(Z_MIN_PIN);
2017-10-08 18:38:10 +02:00
#endif
#if HAS_Z2_MAX
2019-09-17 03:18:02 +02:00
_ATTACH(Z2_MAX_PIN);
2017-10-08 18:38:10 +02:00
#endif
#if HAS_Z2_MIN
2019-09-17 03:18:02 +02:00
_ATTACH(Z2_MIN_PIN);
2017-10-08 18:38:10 +02:00
#endif
#if HAS_Z3_MAX
2019-09-17 03:18:02 +02:00
_ATTACH(Z3_MAX_PIN);
#endif
#if HAS_Z3_MIN
2019-09-17 03:18:02 +02:00
_ATTACH(Z3_MIN_PIN);
#endif
2020-01-20 06:35:07 +01:00
#if HAS_Z4_MAX
_ATTACH(Z4_MAX_PIN);
#endif
#if HAS_Z4_MIN
_ATTACH(Z4_MIN_PIN);
#endif
2017-10-08 18:38:10 +02:00
#if HAS_Z_MIN_PROBE_PIN
2019-09-17 03:18:02 +02:00
_ATTACH(Z_MIN_PROBE_PIN);
2017-10-08 18:38:10 +02:00
#endif
}