My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

endstop_interrupts.h 3.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. * 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 <https://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. #define _ATTACH(P) attachInterrupt(P, endstop_ISR, CHANGE)
  52. TERN_(HAS_X_MAX, _ATTACH(X_MAX_PIN));
  53. TERN_(HAS_X_MIN, _ATTACH(X_MIN_PIN));
  54. TERN_(HAS_Y_MAX, _ATTACH(Y_MAX_PIN));
  55. TERN_(HAS_Y_MIN, _ATTACH(Y_MIN_PIN));
  56. TERN_(HAS_Z_MAX, _ATTACH(Z_MAX_PIN));
  57. TERN_(HAS_Z_MIN, _ATTACH(Z_MIN_PIN));
  58. TERN_(HAS_X2_MAX, _ATTACH(X2_MAX_PIN));
  59. TERN_(HAS_X2_MIN, _ATTACH(X2_MIN_PIN));
  60. TERN_(HAS_Y2_MAX, _ATTACH(Y2_MAX_PIN));
  61. TERN_(HAS_Y2_MIN, _ATTACH(Y2_MIN_PIN));
  62. TERN_(HAS_Z2_MAX, _ATTACH(Z2_MAX_PIN));
  63. TERN_(HAS_Z2_MIN, _ATTACH(Z2_MIN_PIN));
  64. TERN_(HAS_Z3_MAX, _ATTACH(Z3_MAX_PIN));
  65. TERN_(HAS_Z3_MIN, _ATTACH(Z3_MIN_PIN));
  66. TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
  67. TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
  68. TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
  69. TERN_(HAS_I_MAX, _ATTACH(I_MAX_PIN));
  70. TERN_(HAS_I_MIN, _ATTACH(I_MIN_PIN));
  71. TERN_(HAS_J_MAX, _ATTACH(J_MAX_PIN));
  72. TERN_(HAS_J_MIN, _ATTACH(J_MIN_PIN));
  73. TERN_(HAS_K_MAX, _ATTACH(K_MAX_PIN));
  74. TERN_(HAS_K_MIN, _ATTACH(K_MIN_PIN));
  75. TERN_(HAS_U_MAX, _ATTACH(U_MAX_PIN));
  76. TERN_(HAS_U_MIN, _ATTACH(U_MIN_PIN));
  77. TERN_(HAS_V_MAX, _ATTACH(V_MAX_PIN));
  78. TERN_(HAS_V_MIN, _ATTACH(V_MIN_PIN));
  79. TERN_(HAS_W_MAX, _ATTACH(W_MAX_PIN));
  80. TERN_(HAS_W_MIN, _ATTACH(W_MIN_PIN));
  81. }