My Marlin configs for Fabrikator Mini and CTC i3 Pro B
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

endstop_interrupts.h 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 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() { endstops.update(); }
  39. void setup_endstop_interrupts() {
  40. #define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE)
  41. #define LPC1768_PIN_INTERRUPT_M(pin) ((pin >> 0x5 & 0x7) == 0 || (pin >> 0x5 & 0x7) == 2)
  42. #if HAS_X_MAX
  43. #if !LPC1768_PIN_INTERRUPT_M(X_MAX_PIN)
  44. #error "X_MAX_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
  45. #endif
  46. _ATTACH(X_MAX_PIN);
  47. #endif
  48. #if HAS_X_MIN
  49. #if !LPC1768_PIN_INTERRUPT_M(X_MIN_PIN)
  50. #error "X_MIN_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
  51. #endif
  52. _ATTACH(X_MIN_PIN);
  53. #endif
  54. #if HAS_Y_MAX
  55. #if !LPC1768_PIN_INTERRUPT_M(Y_MAX_PIN)
  56. #error "Y_MAX_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
  57. #endif
  58. _ATTACH(Y_MAX_PIN);
  59. #endif
  60. #if HAS_Y_MIN
  61. #if !LPC1768_PIN_INTERRUPT_M(Y_MIN_PIN)
  62. #error "Y_MIN_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
  63. #endif
  64. _ATTACH(Y_MIN_PIN);
  65. #endif
  66. #if HAS_Z_MAX
  67. #if !LPC1768_PIN_INTERRUPT_M(Z_MAX_PIN)
  68. #error "Z_MAX_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
  69. #endif
  70. _ATTACH(Z_MAX_PIN);
  71. #endif
  72. #if HAS_Z_MIN
  73. #if !LPC1768_PIN_INTERRUPT_M(Z_MIN_PIN)
  74. #error "Z_MIN_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
  75. #endif
  76. _ATTACH(Z_MIN_PIN);
  77. #endif
  78. #if HAS_Z2_MAX
  79. #if !LPC1768_PIN_INTERRUPT_M(Z2_MAX_PIN)
  80. #error "Z2_MAX_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
  81. #endif
  82. _ATTACH(Z2_MAX_PIN);
  83. #endif
  84. #if HAS_Z2_MIN
  85. #if !LPC1768_PIN_INTERRUPT_M(Z2_MIN_PIN)
  86. #error "Z2_MIN_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
  87. #endif
  88. _ATTACH(Z2_MIN_PIN);
  89. #endif
  90. #if HAS_Z3_MAX
  91. #if !LPC1768_PIN_INTERRUPT_M(Z3_MAX_PIN)
  92. #error "Z3_MIN_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
  93. #endif
  94. _ATTACH(Z3_MAX_PIN);
  95. #endif
  96. #if HAS_Z3_MIN
  97. #if !LPC1768_PIN_INTERRUPT_M(Z3_MIN_PIN)
  98. #error "Z3_MIN_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
  99. #endif
  100. _ATTACH(Z3_MIN_PIN);
  101. #endif
  102. #if HAS_Z4_MAX
  103. #if !LPC1768_PIN_INTERRUPT_M(Z4_MAX_PIN)
  104. #error "Z4_MIN_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
  105. #endif
  106. _ATTACH(Z4_MAX_PIN);
  107. #endif
  108. #if HAS_Z4_MIN
  109. #if !LPC1768_PIN_INTERRUPT_M(Z4_MIN_PIN)
  110. #error "Z4_MIN_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
  111. #endif
  112. _ATTACH(Z4_MIN_PIN);
  113. #endif
  114. #if HAS_Z_MIN_PROBE_PIN
  115. #if !LPC1768_PIN_INTERRUPT_M(Z_MIN_PROBE_PIN)
  116. #error "Z_MIN_PROBE_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
  117. #endif
  118. _ATTACH(Z_MIN_PROBE_PIN);
  119. #endif
  120. }