My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

endstop_interrupts.h 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #pragma once
  23. /**
  24. * Endstop Interrupts
  25. *
  26. * Without endstop interrupts the endstop pins must be polled continually in
  27. * the stepper-ISR via endstops.update(), most of the time finding no change.
  28. * With this feature endstops.update() is called only when we know that at
  29. * least one endstop has changed state, saving valuable CPU cycles.
  30. *
  31. * This feature only works when all used endstop pins can generate an 'external interrupt'.
  32. *
  33. * Test whether pins issue interrupts on your board by flashing 'pin_interrupt_test.ino'.
  34. * (Located in Marlin/buildroot/share/pin_interrupt_test/pin_interrupt_test.ino)
  35. */
  36. #include "../../module/endstops.h"
  37. // One ISR for all EXT-Interrupts
  38. void ICACHE_RAM_ATTR endstop_ISR() { endstops.update(); }
  39. void setup_endstop_interrupts() {
  40. #define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE)
  41. TERN_(HAS_X_MAX, _ATTACH(X_MAX_PIN));
  42. TERN_(HAS_X_MIN, _ATTACH(X_MIN_PIN));
  43. TERN_(HAS_Y_MAX, _ATTACH(Y_MAX_PIN));
  44. TERN_(HAS_Y_MIN, _ATTACH(Y_MIN_PIN));
  45. TERN_(HAS_Z_MAX, _ATTACH(Z_MAX_PIN));
  46. TERN_(HAS_Z_MIN, _ATTACH(Z_MIN_PIN));
  47. TERN_(HAS_X2_MAX, _ATTACH(X2_MAX_PIN));
  48. TERN_(HAS_X2_MIN, _ATTACH(X2_MIN_PIN));
  49. TERN_(HAS_Y2_MAX, _ATTACH(Y2_MAX_PIN));
  50. TERN_(HAS_Y2_MIN, _ATTACH(Y2_MIN_PIN));
  51. TERN_(HAS_Z2_MAX, _ATTACH(Z2_MAX_PIN));
  52. TERN_(HAS_Z2_MIN, _ATTACH(Z2_MIN_PIN));
  53. TERN_(HAS_Z3_MAX, _ATTACH(Z3_MAX_PIN));
  54. TERN_(HAS_Z3_MIN, _ATTACH(Z3_MIN_PIN));
  55. TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
  56. TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
  57. TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
  58. }