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.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 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. /**
  23. * Endstop Interrupts
  24. *
  25. * Without endstop interrupts the endstop pins must be polled continually in
  26. * the stepper-ISR via endstops.update(), most of the time finding no change.
  27. * With this feature endstops.update() is called only when we know that at
  28. * least one endstop has changed state, saving valuable CPU cycles.
  29. *
  30. * This feature only works when all used endstop pins can generate an 'external interrupt'.
  31. *
  32. * Test whether pins issue interrupts on your board by flashing 'pin_interrupt_test.ino'.
  33. * (Located in Marlin/buildroot/share/pin_interrupt_test/pin_interrupt_test.ino)
  34. */
  35. #ifndef _ENDSTOP_INTERRUPTS_H_
  36. #define _ENDSTOP_INTERRUPTS_H_
  37. //Currently this is untested and broken
  38. #error "Please disable Endstop Interrupts LPC176x is currently an unsupported platform"
  39. volatile uint8_t e_hit = 0; // Different from 0 when the endstops should be tested in detail.
  40. // Must be reset to 0 by the test function when finished.
  41. // This is what is really done inside the interrupts.
  42. FORCE_INLINE void endstop_ISR_worker( void ) {
  43. e_hit = 2; // Because the detection of a e-stop hit has a 1 step debouncer it has to be called at least twice.
  44. }
  45. // One ISR for all EXT-Interrupts
  46. void endstop_ISR(void) { endstop_ISR_worker(); }
  47. void setup_endstop_interrupts(void) {
  48. #if HAS_X_MAX
  49. attachInterrupt(digitalPinToInterrupt(X_MAX_PIN), endstop_ISR, CHANGE); // assign it
  50. #endif
  51. #if HAS_X_MIN
  52. attachInterrupt(digitalPinToInterrupt(X_MIN_PIN), endstop_ISR, CHANGE);
  53. #endif
  54. #if HAS_Y_MAX
  55. attachInterrupt(digitalPinToInterrupt(Y_MAX_PIN), endstop_ISR, CHANGE);
  56. #endif
  57. #if HAS_Y_MIN
  58. attachInterrupt(digitalPinToInterrupt(Y_MIN_PIN), endstop_ISR, CHANGE);
  59. #endif
  60. #if HAS_Z_MAX
  61. attachInterrupt(digitalPinToInterrupt(Z_MAX_PIN), endstop_ISR, CHANGE);
  62. #endif
  63. #if HAS_Z_MIN
  64. attachInterrupt(digitalPinToInterrupt(Z_MIN_PIN), endstop_ISR, CHANGE);
  65. #endif
  66. #if HAS_Z2_MAX
  67. attachInterrupt(digitalPinToInterrupt(Z2_MAX_PIN), endstop_ISR, CHANGE);
  68. #endif
  69. #if HAS_Z2_MIN
  70. attachInterrupt(digitalPinToInterrupt(Z2_MIN_PIN), endstop_ISR, CHANGE);
  71. #endif
  72. #if HAS_Z_MIN_PROBE_PIN
  73. attachInterrupt(digitalPinToInterrupt(Z_MIN_PROBE_PIN), endstop_ISR, CHANGE);
  74. #endif
  75. }
  76. #endif //_ENDSTOP_INTERRUPTS_H_