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 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2019 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 <http://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 temperature-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 endstop_ISR(void) { endstops.update(); }
  39. void setup_endstop_interrupts(void) {
  40. #if HAS_X_MAX
  41. #if !LPC1768_PIN_INTERRUPT_M(X_MAX_PIN)
  42. #error "X_MAX_PIN is not an INTERRUPT capable pin."
  43. #endif
  44. attachInterrupt(digitalPinToInterrupt(X_MAX_PIN), endstop_ISR, CHANGE);
  45. #endif
  46. #if HAS_X_MIN
  47. #if !LPC1768_PIN_INTERRUPT_M(X_MIN_PIN)
  48. #error "X_MIN_PIN is not an INTERRUPT capable pin."
  49. #endif
  50. attachInterrupt(digitalPinToInterrupt(X_MIN_PIN), endstop_ISR, CHANGE);
  51. #endif
  52. #if HAS_Y_MAX
  53. #if !LPC1768_PIN_INTERRUPT_M(Y_MAX_PIN)
  54. #error "Y_MAX_PIN is not an INTERRUPT capable pin."
  55. #endif
  56. attachInterrupt(digitalPinToInterrupt(Y_MAX_PIN), endstop_ISR, CHANGE);
  57. #endif
  58. #if HAS_Y_MIN
  59. #if !LPC1768_PIN_INTERRUPT_M(Y_MIN_PIN)
  60. #error "Y_MIN_PIN is not an INTERRUPT capable pin."
  61. #endif
  62. attachInterrupt(digitalPinToInterrupt(Y_MIN_PIN), endstop_ISR, CHANGE);
  63. #endif
  64. #if HAS_Z_MAX
  65. #if !LPC1768_PIN_INTERRUPT_M(Z_MAX_PIN)
  66. #error "Z_MAX_PIN is not an INTERRUPT capable pin."
  67. #endif
  68. attachInterrupt(digitalPinToInterrupt(Z_MAX_PIN), endstop_ISR, CHANGE);
  69. #endif
  70. #if HAS_Z_MIN
  71. #if !LPC1768_PIN_INTERRUPT_M(Z_MIN_PIN)
  72. #error "Z_MIN_PIN is not an INTERRUPT capable pin."
  73. #endif
  74. attachInterrupt(digitalPinToInterrupt(Z_MIN_PIN), endstop_ISR, CHANGE);
  75. #endif
  76. #if HAS_Z2_MAX
  77. #if !LPC1768_PIN_INTERRUPT_M(Z2_MAX_PIN)
  78. #error "Z2_MAX_PIN is not an INTERRUPT capable pin."
  79. #endif
  80. attachInterrupt(digitalPinToInterrupt(Z2_MAX_PIN), endstop_ISR, CHANGE);
  81. #endif
  82. #if HAS_Z2_MIN
  83. #if !LPC1768_PIN_INTERRUPT_M(Z2_MIN_PIN)
  84. #error "Z2_MIN_PIN is not an INTERRUPT capable pin."
  85. #endif
  86. attachInterrupt(digitalPinToInterrupt(Z2_MIN_PIN), endstop_ISR, CHANGE);
  87. #endif
  88. #if HAS_Z3_MAX
  89. #if !LPC1768_PIN_INTERRUPT_M(Z3_MIN_PIN)
  90. #error "Z3_MIN_PIN is not an INTERRUPT capable pin."
  91. #endif
  92. attachInterrupt(digitalPinToInterrupt(Z3_MAX_PIN), endstop_ISR, CHANGE);
  93. #endif
  94. #if HAS_Z3_MIN
  95. #if !LPC1768_PIN_INTERRUPT_M(Z3_MIN_PIN)
  96. #error "Z3_MIN_PIN is not an INTERRUPT capable pin."
  97. #endif
  98. attachInterrupt(digitalPinToInterrupt(Z3_MIN_PIN), endstop_ISR, CHANGE);
  99. #endif
  100. #if HAS_Z_MIN_PROBE_PIN
  101. #if !LPC1768_PIN_INTERRUPT_M(Z_MIN_PROBE_PIN)
  102. #error "Z_MIN_PROBE_PIN is not an INTERRUPT capable pin."
  103. #endif
  104. attachInterrupt(digitalPinToInterrupt(Z_MIN_PROBE_PIN), endstop_ISR, CHANGE);
  105. #endif
  106. }