My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

endstop_interrupts.h 3.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. * Copyright (c) 2017 Victor Perez
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. */
  23. #pragma once
  24. /**
  25. * Endstop interrupts for Libmaple STM32F1 based targets.
  26. *
  27. * On STM32F, all pins support external interrupt capability.
  28. * Any pin can be used for external interrupts, but there are some restrictions.
  29. * At most 16 different external interrupts can be used at one time.
  30. * Further, you can’t just pick any 16 pins to use. This is because every pin on the STM32
  31. * connects to what is called an EXTI line, and only one pin per EXTI line can be used for external interrupts at a time
  32. * Check the Reference Manual of the MCU to confirm which line is used by each pin
  33. */
  34. /**
  35. * Endstop Interrupts
  36. *
  37. * Without endstop interrupts the endstop pins must be polled continually in
  38. * the temperature-ISR via endstops.update(), most of the time finding no change.
  39. * With this feature endstops.update() is called only when we know that at
  40. * least one endstop has changed state, saving valuable CPU cycles.
  41. *
  42. * This feature only works when all used endstop pins can generate an 'external interrupt'.
  43. *
  44. * Test whether pins issue interrupts on your board by flashing 'pin_interrupt_test.ino'.
  45. * (Located in Marlin/buildroot/share/pin_interrupt_test/pin_interrupt_test.ino)
  46. */
  47. #include "../../module/endstops.h"
  48. // One ISR for all EXT-Interrupts
  49. void endstop_ISR() { endstops.update(); }
  50. void setup_endstop_interrupts() {
  51. #if HAS_X_MAX
  52. attachInterrupt(X_MAX_PIN, endstop_ISR, CHANGE); // assign it
  53. #endif
  54. #if HAS_X_MIN
  55. attachInterrupt(X_MIN_PIN, endstop_ISR, CHANGE);
  56. #endif
  57. #if HAS_Y_MAX
  58. attachInterrupt(Y_MAX_PIN, endstop_ISR, CHANGE);
  59. #endif
  60. #if HAS_Y_MIN
  61. attachInterrupt(Y_MIN_PIN, endstop_ISR, CHANGE);
  62. #endif
  63. #if HAS_Z_MAX
  64. attachInterrupt(Z_MAX_PIN, endstop_ISR, CHANGE);
  65. #endif
  66. #if HAS_Z_MIN
  67. attachInterrupt(Z_MIN_PIN, endstop_ISR, CHANGE);
  68. #endif
  69. #if HAS_Z2_MAX
  70. attachInterrupt(Z2_MAX_PIN, endstop_ISR, CHANGE);
  71. #endif
  72. #if HAS_Z2_MIN
  73. attachInterrupt(Z2_MIN_PIN, endstop_ISR, CHANGE);
  74. #endif
  75. #if HAS_Z3_MAX
  76. attachInterrupt(Z3_MAX_PIN, endstop_ISR, CHANGE);
  77. #endif
  78. #if HAS_Z3_MIN
  79. attachInterrupt(Z3_MIN_PIN, endstop_ISR, CHANGE);
  80. #endif
  81. #if HAS_Z4_MAX
  82. attachInterrupt(Z4_MAX_PIN, endstop_ISR, CHANGE);
  83. #endif
  84. #if HAS_Z4_MIN
  85. attachInterrupt(Z4_MIN_PIN, endstop_ISR, CHANGE);
  86. #endif
  87. #if HAS_Z_MIN_PROBE_PIN
  88. attachInterrupt(Z_MIN_PROBE_PIN, endstop_ISR, CHANGE);
  89. #endif
  90. }