Browse Source

Followup to new endstop interrupts feature

- Fix typos, verbiage
- Fix naming of `setup_endstop_interrupts`
- Some formatting, indentation, spacing
Scott Lahteine 8 years ago
parent
commit
eb120e518c
25 changed files with 215 additions and 217 deletions
  1. 2
    2
      Marlin/Configuration.h
  2. 2
    1
      Marlin/Marlin_main.cpp
  3. 158
    163
      Marlin/endstop_interrupts.h
  4. 2
    2
      Marlin/example_configurations/Cartesio/Configuration.h
  5. 2
    2
      Marlin/example_configurations/Felix/Configuration.h
  6. 2
    2
      Marlin/example_configurations/Felix/DUAL/Configuration.h
  7. 2
    2
      Marlin/example_configurations/Hephestos/Configuration.h
  8. 2
    2
      Marlin/example_configurations/Hephestos_2/Configuration.h
  9. 2
    2
      Marlin/example_configurations/K8200/Configuration.h
  10. 2
    2
      Marlin/example_configurations/K8400/Configuration.h
  11. 2
    2
      Marlin/example_configurations/K8400/Dual-head/Configuration.h
  12. 2
    2
      Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h
  13. 2
    2
      Marlin/example_configurations/RigidBot/Configuration.h
  14. 2
    2
      Marlin/example_configurations/SCARA/Configuration.h
  15. 2
    2
      Marlin/example_configurations/TAZ4/Configuration.h
  16. 2
    2
      Marlin/example_configurations/WITBOX/Configuration.h
  17. 2
    2
      Marlin/example_configurations/adafruit/ST7565/Configuration.h
  18. 2
    2
      Marlin/example_configurations/delta/biv2.5/Configuration.h
  19. 2
    2
      Marlin/example_configurations/delta/generic/Configuration.h
  20. 2
    2
      Marlin/example_configurations/delta/kossel_mini/Configuration.h
  21. 2
    2
      Marlin/example_configurations/delta/kossel_pro/Configuration.h
  22. 2
    2
      Marlin/example_configurations/delta/kossel_xl/Configuration.h
  23. 2
    2
      Marlin/example_configurations/makibox/Configuration.h
  24. 2
    2
      Marlin/example_configurations/tvrrug/Round2/Configuration.h
  25. 11
    9
      Marlin/stepper.cpp

+ 2
- 2
Marlin/Configuration.h View File

@@ -445,8 +445,8 @@
445 445
 #define Z_MAX_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
446 446
 #define Z_MIN_PROBE_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
447 447
 
448
-// If all used endstop pins are able to cause interrupts, you can enable ENDSTOP_INTERRUPTS_FEATURE.
449
-// Then the function testing the endstops will only be called, if the state of one of the endstops changed.
448
+// Enable this feature if all enabled endstop pins are interrupt-capable.
449
+// This will remove the need to poll the interrupt pins, saving many CPU cycles.
450 450
 //#define ENDSTOP_INTERRUPTS_FEATURE
451 451
 
452 452
 //=============================================================================

+ 2
- 1
Marlin/Marlin_main.cpp View File

@@ -92,6 +92,7 @@
92 92
 #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
93 93
   #include "endstop_interrupts.h"
94 94
 #endif
95
+
95 96
 /**
96 97
  * Look here for descriptions of G-codes:
97 98
  *  - http://linuxcnc.org/handbook/gcode/g-code.html
@@ -10020,7 +10021,7 @@ void setup() {
10020 10021
   #endif
10021 10022
 
10022 10023
   #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
10023
-    setup_enstop_interrupts();
10024
+    setup_endstop_interrupts();
10024 10025
   #endif
10025 10026
 }
10026 10027
 

+ 158
- 163
Marlin/endstop_interrupts.h View File

@@ -21,191 +21,186 @@
21 21
  */
22 22
 
23 23
 /**
24
- *  Endstop interrupts
25
- *  Without endstop interrups the stepper-ISR must always test all endstops when interested in their states (endstops.update()).
26
- *  Most time the test will result in finding out nothing has changed.
27
- *  With endstop interrupts endstops.update() is called only when we know that at least one endstop has changed its state.
24
+ * Endstop Interrupts
28 25
  *
29
- *  This can work only if all __used__ endstop pins can provide ether an 'external interrupt' or a 'pin change interrupt'.
30
- *  You can find out about pins issuing interrupts by running 'pin_interrupt_test.ino' (Marlin\buildroot\share\pin_interrupt_test\pin_interrupt_test.ino)
26
+ * Without endstop interrupts the endstop pins must be polled continually in
27
+ * the stepper-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 either an
32
+ * 'external interrupt' or a 'pin change interrupt'.
33
+ *
34
+ * Test whether pins issue interrupts on your board by flashing 'pin_interrupt_test.ino'.
35
+ * (Located in Marlin/buildroot/share/pin_interrupt_test/pin_interrupt_test.ino)
31 36
  */
32 37
 
33 38
  #ifndef _ENDSTOP_INTERRUPTS_H_
34
-   #define _ENDSTOP_INTERRUPTS_H_
35
-
36
-  /**
37
-   * Patch for pins_arduino.h (...\Arduino\hardware\arduino\avr\variants\mega\pins_arduino.h)  
38
-   *
39
-   * These macros for the Arduino MEGA do not include the two connected pins on Port J (D13, D14).
40
-   * So we extend them here because this are the normal pins for Y_MIN and Y_MAX on RAMPS.
41
-   * There are more PCI enabled processor pins on Port J, but they are not connected to Arduino MEGA.
42
-   */
43
-  #if defined(ARDUINO_AVR_MEGA2560) || defined(ARDUINO_AVR_MEGA)
44
-    #undef  digitalPinToPCICR
45
-    #define digitalPinToPCICR(p)    ( (((p) >= 10) && ((p) <= 15)) || \
46
-                                    (((p) >= 50) && ((p) <= 53)) || \
47
-                                    (((p) >= 62) && ((p) <= 69)) ? (&PCICR) : ((uint8_t *)0) )
48
-    #undef  digitalPinToPCICRbit
49
-    #define digitalPinToPCICRbit(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? 0 : \
50
-                                    ( (((p) >= 14) && ((p) <= 15)) ? 1 : \
51
-                                    ( (((p) >= 62) && ((p) <= 69)) ? 2 : \
52
-                                    0 ) ) )
53
-    #undef  digitalPinToPCMSK
54
-    #define digitalPinToPCMSK(p)    ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? (&PCMSK0) : \
55
-                                    ( (((p) >= 14) && ((p) <= 15)) ? (&PCMSK1) : \
56
-                                    ( (((p) >= 62) && ((p) <= 69)) ? (&PCMSK2) : \
57
-                                    ((uint8_t *)0) ) ) )
58
-    #undef  digitalPinToPCMSKbit
59
-    #define digitalPinToPCMSKbit(p) ( (((p) >= 10) && ((p) <= 13)) ? ((p) - 6) : \
60
-                                    ( ((p) == 14) ? 2 : \
61
-                                    ( ((p) == 15) ? 1 : \
62
-                                    ( ((p) == 50) ? 3 : \
63
-                                    ( ((p) == 51) ? 2 : \
64
-                                    ( ((p) == 52) ? 1 : \
65
-                                    ( ((p) == 53) ? 0 : \
66
-                                    ( (((p) >= 62) && ((p) <= 69)) ? ((p) - 62) : \
67
-                                    0 ) ) ) ) ) ) ) )
68
-  #endif
69
-
70
-  volatile uint8_t e_hit = 0; // Different from 0 when the endstops shall be tested in detail. 
71
-                              // Must be reset to 0 by the test function when the tests are finished.
72
-
73
-  // Install Pin change interrupt for a pin, can be called multiple times
74
-  void pciSetup(byte pin) {
75
-    *digitalPinToPCMSK(pin) |= bit (digitalPinToPCMSKbit(pin));  // enable pin
76
-    PCIFR  |= bit (digitalPinToPCICRbit(pin)); // clear any outstanding interrupt
77
-    PCICR  |= bit (digitalPinToPCICRbit(pin)); // enable interrupt for the group
78
-  }
79
-
80
-  // This is what is really done inside the interrupts.
81
-  FORCE_INLINE void endstop_ISR_worker( void ) {
82
-    e_hit = 2; // Because the detection of a e-stop hit has a 1 step debouncer it has to be called at least twice.
83
-  }
84
-
85
-  // Use one Routine to handle each group
86
-  // One ISR for all EXT-Interrupts
87
-  void endstop_ISR(void) {
88
-    endstop_ISR_worker();
89
-  }
90
-
91
-  #ifdef PCINT0_vect
92
-    ISR(PCINT0_vect) { // handle pin change interrupt
93
-      endstop_ISR_worker();
94
-    }
95
-  #endif
96
-
97
-  #ifdef PCINT1_vect
98
-    ISR(PCINT1_vect) { // handle pin change interrupt
99
-      endstop_ISR_worker();
100
-    }
101
-  #endif
39
+ #define _ENDSTOP_INTERRUPTS_H_
102 40
 
103
-  #ifdef PCINT2_vect
104
-    ISR(PCINT2_vect) { // handle pin change interrupt
105
-      endstop_ISR_worker();
106
-    }
107
-  #endif
108
-
109
-  #ifdef PCINT3_vect
110
-    ISR(PCINT3_vect) { // handle pin change interrupt
111
-      endstop_ISR_worker();
112
-    }
113
-  #endif
114
-
115
-  void setup_enstop_interrupts( void ) {
116
-
117
-    #if HAS_X_MAX
118
-      #if (digitalPinToInterrupt(X_MAX_PIN) != NOT_AN_INTERRUPT) // if pin has an external interrupt
119
-        attachInterrupt(digitalPinToInterrupt(X_MAX_PIN), endstop_ISR, CHANGE); // assign it
120
-      #else
121
-        // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
122
-        static_assert(digitalPinToPCICR(X_MAX_PIN) != NULL, "ENDSTOP_INTERRUPT_ERROR"); // if pin has no pin change interrupt - error
123
-        pciSetup(X_MAX_PIN);                                                            // assign it
124
-      #endif
41
+/**
42
+ * Patch for pins_arduino.h (...\Arduino\hardware\arduino\avr\variants\mega\pins_arduino.h)
43
+ *
44
+ * These macros for the Arduino MEGA do not include the two connected pins on Port J (D13, D14).
45
+ * So we extend them here because these are the normal pins for Y_MIN and Y_MAX on RAMPS.
46
+ * There are more PCI-enabled processor pins on Port J, but they are not connected to Arduino MEGA.
47
+ */
48
+#if defined(ARDUINO_AVR_MEGA2560) || defined(ARDUINO_AVR_MEGA)
49
+  #undef  digitalPinToPCICR
50
+  #define digitalPinToPCICR(p)    ( (((p) >= 10) && ((p) <= 15)) || \
51
+                                  (((p) >= 50) && ((p) <= 53)) || \
52
+                                  (((p) >= 62) && ((p) <= 69)) ? (&PCICR) : ((uint8_t *)0) )
53
+  #undef  digitalPinToPCICRbit
54
+  #define digitalPinToPCICRbit(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? 0 : \
55
+                                  ( (((p) >= 14) && ((p) <= 15)) ? 1 : \
56
+                                  ( (((p) >= 62) && ((p) <= 69)) ? 2 : \
57
+                                  0 ) ) )
58
+  #undef  digitalPinToPCMSK
59
+  #define digitalPinToPCMSK(p)    ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? (&PCMSK0) : \
60
+                                  ( (((p) >= 14) && ((p) <= 15)) ? (&PCMSK1) : \
61
+                                  ( (((p) >= 62) && ((p) <= 69)) ? (&PCMSK2) : \
62
+                                  ((uint8_t *)0) ) ) )
63
+  #undef  digitalPinToPCMSKbit
64
+  #define digitalPinToPCMSKbit(p) ( (((p) >= 10) && ((p) <= 13)) ? ((p) - 6) : \
65
+                                  ( ((p) == 14) ? 2 : \
66
+                                  ( ((p) == 15) ? 1 : \
67
+                                  ( ((p) == 50) ? 3 : \
68
+                                  ( ((p) == 51) ? 2 : \
69
+                                  ( ((p) == 52) ? 1 : \
70
+                                  ( ((p) == 53) ? 0 : \
71
+                                  ( (((p) >= 62) && ((p) <= 69)) ? ((p) - 62) : \
72
+                                  0 ) ) ) ) ) ) ) )
73
+#endif
74
+
75
+volatile uint8_t e_hit = 0; // Different from 0 when the endstops shall be tested in detail.
76
+                            // Must be reset to 0 by the test function when the tests are finished.
77
+
78
+// Install Pin change interrupt for a pin. Can be called multiple times.
79
+void pciSetup(byte pin) {
80
+  *digitalPinToPCMSK(pin) |= bit (digitalPinToPCMSKbit(pin));  // enable pin
81
+  PCIFR  |= bit (digitalPinToPCICRbit(pin)); // clear any outstanding interrupt
82
+  PCICR  |= bit (digitalPinToPCICRbit(pin)); // enable interrupt for the group
83
+}
84
+
85
+// This is what is really done inside the interrupts.
86
+FORCE_INLINE void endstop_ISR_worker( void ) {
87
+  e_hit = 2; // Because the detection of a e-stop hit has a 1 step debouncer it has to be called at least twice.
88
+}
89
+
90
+// Use one Routine to handle each group
91
+// One ISR for all EXT-Interrupts
92
+void endstop_ISR(void) { endstop_ISR_worker(); }
93
+
94
+// Handlers for pin change interrupts
95
+#ifdef PCINT0_vect
96
+  ISR(PCINT0_vect) { endstop_ISR_worker(); }
97
+#endif
98
+
99
+#ifdef PCINT1_vect
100
+  ISR(PCINT1_vect) { endstop_ISR_worker(); }
101
+#endif
102
+
103
+#ifdef PCINT2_vect
104
+  ISR(PCINT2_vect) { endstop_ISR_worker(); }
105
+#endif
106
+
107
+#ifdef PCINT3_vect
108
+  ISR(PCINT3_vect) { endstop_ISR_worker(); }
109
+#endif
110
+
111
+void setup_endstop_interrupts( void ) {
112
+
113
+  #if HAS_X_MAX
114
+    #if (digitalPinToInterrupt(X_MAX_PIN) != NOT_AN_INTERRUPT) // if pin has an external interrupt
115
+      attachInterrupt(digitalPinToInterrupt(X_MAX_PIN), endstop_ISR, CHANGE); // assign it
116
+    #else
117
+      // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
118
+      static_assert(digitalPinToPCICR(X_MAX_PIN) != NULL, "ENDSTOP_INTERRUPT_ERROR"); // if pin has no pin change interrupt - error
119
+      pciSetup(X_MAX_PIN);                                                            // assign it
125 120
     #endif
121
+  #endif
126 122
 
127
-    #if HAS_X_MIN
128
-      #if (digitalPinToInterrupt(X_MIN_PIN) != NOT_AN_INTERRUPT)
129
-        attachInterrupt(digitalPinToInterrupt(X_MIN_PIN), endstop_ISR, CHANGE);
130
-      #else
131
-        // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
132
-        static_assert(digitalPinToPCICR(X_MIN_PIN) != NULL, "ENDSTOP_INTERRUPT_ERROR");
133
-        pciSetup(X_MIN_PIN);
134
-      #endif
123
+  #if HAS_X_MIN
124
+    #if (digitalPinToInterrupt(X_MIN_PIN) != NOT_AN_INTERRUPT)
125
+      attachInterrupt(digitalPinToInterrupt(X_MIN_PIN), endstop_ISR, CHANGE);
126
+    #else
127
+      // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
128
+      static_assert(digitalPinToPCICR(X_MIN_PIN) != NULL, "ENDSTOP_INTERRUPT_ERROR");
129
+      pciSetup(X_MIN_PIN);
135 130
     #endif
131
+  #endif
136 132
 
137
-    #if HAS_Y_MAX
138
-      #if (digitalPinToInterrupt(Y_MAX_PIN) != NOT_AN_INTERRUPT)
139
-        attachInterrupt(digitalPinToInterrupt(Y_MAX_PIN), endstop_ISR, CHANGE);
140
-      #else
141
-        // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
142
-        static_assert(digitalPinToPCICR(Y_MAX_PIN) != NULL, "ENDSTOP_INTERRUPT_ERROR");
143
-        pciSetup(Y_MAX_PIN);
144
-      #endif
133
+  #if HAS_Y_MAX
134
+    #if (digitalPinToInterrupt(Y_MAX_PIN) != NOT_AN_INTERRUPT)
135
+      attachInterrupt(digitalPinToInterrupt(Y_MAX_PIN), endstop_ISR, CHANGE);
136
+    #else
137
+      // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
138
+      static_assert(digitalPinToPCICR(Y_MAX_PIN) != NULL, "ENDSTOP_INTERRUPT_ERROR");
139
+      pciSetup(Y_MAX_PIN);
145 140
     #endif
141
+  #endif
146 142
 
147
-    #if HAS_Y_MIN
148
-      #if (digitalPinToInterrupt(Y_MIN_PIN) != NOT_AN_INTERRUPT)
149
-        attachInterrupt(digitalPinToInterrupt(Y_MIN_PIN), endstop_ISR, CHANGE);
150
-      #else
151
-        // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
152
-        static_assert(digitalPinToPCICR(Y_MIN_PIN) != NULL, "ENDSTOP_INTERRUPT_ERROR");
153
-        pciSetup(Y_MIN_PIN);
154
-      #endif
143
+  #if HAS_Y_MIN
144
+    #if (digitalPinToInterrupt(Y_MIN_PIN) != NOT_AN_INTERRUPT)
145
+      attachInterrupt(digitalPinToInterrupt(Y_MIN_PIN), endstop_ISR, CHANGE);
146
+    #else
147
+      // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
148
+      static_assert(digitalPinToPCICR(Y_MIN_PIN) != NULL, "ENDSTOP_INTERRUPT_ERROR");
149
+      pciSetup(Y_MIN_PIN);
155 150
     #endif
151
+  #endif
156 152
 
157
-    #if HAS_Z_MAX
158
-      #if (digitalPinToInterrupt(Z_MAX_PIN) != NOT_AN_INTERRUPT)
159
-        attachInterrupt(digitalPinToInterrupt(Z_MAX_PIN), endstop_ISR, CHANGE);
160
-      #else
161
-        // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
162
-        static_assert(digitalPinToPCICR(Z_MAX_PIN) != NULL, "ENDSTOP_INTERRUPT_ERROR");
163
-        pciSetup(Z_MAX_PIN);
164
-      #endif
153
+  #if HAS_Z_MAX
154
+    #if (digitalPinToInterrupt(Z_MAX_PIN) != NOT_AN_INTERRUPT)
155
+      attachInterrupt(digitalPinToInterrupt(Z_MAX_PIN), endstop_ISR, CHANGE);
156
+    #else
157
+      // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
158
+      static_assert(digitalPinToPCICR(Z_MAX_PIN) != NULL, "ENDSTOP_INTERRUPT_ERROR");
159
+      pciSetup(Z_MAX_PIN);
165 160
     #endif
161
+  #endif
166 162
 
167
-    #if HAS_Z_MIN
168
-      #if (digitalPinToInterrupt(Z_MIN_PIN) != NOT_AN_INTERRUPT)
169
-        attachInterrupt(digitalPinToInterrupt(Z_MIN_PIN), endstop_ISR, CHANGE);
170
-      #else
171
-        // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
172
-        static_assert(digitalPinToPCICR(Z_MIN_PIN) != NULL, "ENDSTOP_INTERRUPT_ERROR");
173
-        pciSetup(Z_MIN_PIN);
174
-      #endif
163
+  #if HAS_Z_MIN
164
+    #if (digitalPinToInterrupt(Z_MIN_PIN) != NOT_AN_INTERRUPT)
165
+      attachInterrupt(digitalPinToInterrupt(Z_MIN_PIN), endstop_ISR, CHANGE);
166
+    #else
167
+      // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
168
+      static_assert(digitalPinToPCICR(Z_MIN_PIN) != NULL, "ENDSTOP_INTERRUPT_ERROR");
169
+      pciSetup(Z_MIN_PIN);
175 170
     #endif
171
+  #endif
176 172
 
177
-    #if HAS_Z2_MAX
178
-      #if (digitalPinToInterrupt(Z2_MAX_PIN) != NOT_AN_INTERRUPT)
179
-        attachInterrupt(digitalPinToInterrupt(Z2_MAX_PIN), endstop_ISR, CHANGE);
180
-      #else
181
-        // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
182
-        static_assert(digitalPinToPCICR(Z2_MAX_PIN) != NULL, "ENDSTOP_INTERRUPT_ERROR");
183
-        pciSetup(Z2_MAX_PIN);
184
-      #endif
173
+  #if HAS_Z2_MAX
174
+    #if (digitalPinToInterrupt(Z2_MAX_PIN) != NOT_AN_INTERRUPT)
175
+      attachInterrupt(digitalPinToInterrupt(Z2_MAX_PIN), endstop_ISR, CHANGE);
176
+    #else
177
+      // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
178
+      static_assert(digitalPinToPCICR(Z2_MAX_PIN) != NULL, "ENDSTOP_INTERRUPT_ERROR");
179
+      pciSetup(Z2_MAX_PIN);
185 180
     #endif
181
+  #endif
186 182
 
187
-    #if HAS_Z2_MIN
188
-      #if (digitalPinToInterrupt(Z2_MIN_PIN) != NOT_AN_INTERRUPT)
189
-        attachInterrupt(digitalPinToInterrupt(Z2_MIN_PIN), endstop_ISR, CHANGE);
190
-      #else
191
-        // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
192
-        static_assert(digitalPinToPCICR(Z2_MIN_PIN) != NULL, "ENDSTOP_INTERRUPT_ERROR");
193
-        pciSetup(Z2_MIN_PIN);
194
-      #endif
183
+  #if HAS_Z2_MIN
184
+    #if (digitalPinToInterrupt(Z2_MIN_PIN) != NOT_AN_INTERRUPT)
185
+      attachInterrupt(digitalPinToInterrupt(Z2_MIN_PIN), endstop_ISR, CHANGE);
186
+    #else
187
+      // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
188
+      static_assert(digitalPinToPCICR(Z2_MIN_PIN) != NULL, "ENDSTOP_INTERRUPT_ERROR");
189
+      pciSetup(Z2_MIN_PIN);
195 190
     #endif
191
+  #endif
196 192
 
197
-    #if HAS_Z_MIN_PROBE_PIN
198
-      #if (digitalPinToInterrupt(Z_MIN_PROBE_PIN) != NOT_AN_INTERRUPT)
199
-        attachInterrupt(digitalPinToInterrupt(Z_MIN_PROBE_PIN), endstop_ISR, CHANGE);
200
-      #else
201
-        // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
202
-        static_assert(digitalPinToPCICR(Z_MIN_PROBE_PIN) != NULL, "ENDSTOP_INTERRUPT_ERROR");
203
-        pciSetup(Z_MIN_PROBE_PIN);
204
-      #endif
193
+  #if HAS_Z_MIN_PROBE_PIN
194
+    #if (digitalPinToInterrupt(Z_MIN_PROBE_PIN) != NOT_AN_INTERRUPT)
195
+      attachInterrupt(digitalPinToInterrupt(Z_MIN_PROBE_PIN), endstop_ISR, CHANGE);
196
+    #else
197
+      // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
198
+      static_assert(digitalPinToPCICR(Z_MIN_PROBE_PIN) != NULL, "ENDSTOP_INTERRUPT_ERROR");
199
+      pciSetup(Z_MIN_PROBE_PIN);
205 200
     #endif
201
+  #endif
206 202
 
207
-    // When we arive here without error each pin has ether a EXT-interrupt or a PCI.
208
-  }
209
-
203
+  // If we arrive here without raising an assertion, each pin has either an EXT-interrupt or a PCI.
204
+}
210 205
 
211 206
 #endif //_ENDSTOP_INTERRUPTS_H_

+ 2
- 2
Marlin/example_configurations/Cartesio/Configuration.h View File

@@ -445,8 +445,8 @@
445 445
 #define Z_MAX_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
446 446
 #define Z_MIN_PROBE_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
447 447
 
448
-// If all used endstop pins are able to cause interrupts, you can enable ENDSTOP_INTERRUPTS_FEATURE.
449
-// Then the function testing the endstops will only be called, if the state of one of the endstops changed.
448
+// Enable this feature if all enabled endstop pins are interrupt-capable.
449
+// This will remove the need to poll the interrupt pins, saving many CPU cycles.
450 450
 //#define ENDSTOP_INTERRUPTS_FEATURE
451 451
 
452 452
 //=============================================================================

+ 2
- 2
Marlin/example_configurations/Felix/Configuration.h View File

@@ -427,8 +427,8 @@
427 427
 #define Z_MAX_ENDSTOP_INVERTING true  // set to true to invert the logic of the endstop.
428 428
 #define Z_MIN_PROBE_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
429 429
 
430
-// If all used endstop pins are able to cause interrupts, you can enable ENDSTOP_INTERRUPTS_FEATURE.
431
-// Then the function testing the endstops will only be called, if the state of one of the endstops changed.
430
+// Enable this feature if all enabled endstop pins are interrupt-capable.
431
+// This will remove the need to poll the interrupt pins, saving many CPU cycles.
432 432
 //#define ENDSTOP_INTERRUPTS_FEATURE
433 433
 
434 434
 //=============================================================================

+ 2
- 2
Marlin/example_configurations/Felix/DUAL/Configuration.h View File

@@ -427,8 +427,8 @@
427 427
 #define Z_MAX_ENDSTOP_INVERTING true  // set to true to invert the logic of the endstop.
428 428
 #define Z_MIN_PROBE_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
429 429
 
430
-// If all used endstop pins are able to cause interrupts, you can enable ENDSTOP_INTERRUPTS_FEATURE.
431
-// Then the function testing the endstops will only be called, if the state of one of the endstops changed.
430
+// Enable this feature if all enabled endstop pins are interrupt-capable.
431
+// This will remove the need to poll the interrupt pins, saving many CPU cycles.
432 432
 //#define ENDSTOP_INTERRUPTS_FEATURE
433 433
 
434 434
 //=============================================================================

+ 2
- 2
Marlin/example_configurations/Hephestos/Configuration.h View File

@@ -437,8 +437,8 @@
437 437
 #define Z_MAX_ENDSTOP_INVERTING true  // set to true to invert the logic of the endstop.
438 438
 #define Z_MIN_PROBE_ENDSTOP_INVERTING true  // set to true to invert the logic of the endstop.
439 439
 
440
-// If all used endstop pins are able to cause interrupts, you can enable ENDSTOP_INTERRUPTS_FEATURE.
441
-// Then the function testing the endstops will only be called, if the state of one of the endstops changed.
440
+// Enable this feature if all enabled endstop pins are interrupt-capable.
441
+// This will remove the need to poll the interrupt pins, saving many CPU cycles.
442 442
 //#define ENDSTOP_INTERRUPTS_FEATURE
443 443
 
444 444
 //=============================================================================

+ 2
- 2
Marlin/example_configurations/Hephestos_2/Configuration.h View File

@@ -439,8 +439,8 @@
439 439
 #define Z_MAX_ENDSTOP_INVERTING true  // set to true to invert the logic of the endstop.
440 440
 #define Z_MIN_PROBE_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
441 441
 
442
-// If all used endstop pins are able to cause interrupts, you can enable ENDSTOP_INTERRUPTS_FEATURE.
443
-// Then the function testing the endstops will only be called, if the state of one of the endstops changed.
442
+// Enable this feature if all enabled endstop pins are interrupt-capable.
443
+// This will remove the need to poll the interrupt pins, saving many CPU cycles.
444 444
 //#define ENDSTOP_INTERRUPTS_FEATURE
445 445
 
446 446
 //=============================================================================

+ 2
- 2
Marlin/example_configurations/K8200/Configuration.h View File

@@ -462,8 +462,8 @@
462 462
 #define Z_MAX_ENDSTOP_INVERTING true  // set to true to invert the logic of the endstop.
463 463
 #define Z_MIN_PROBE_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
464 464
 
465
-// If all used endstop pins are able to cause interrupts, you can enable ENDSTOP_INTERRUPTS_FEATURE.
466
-// Then the function testing the endstops will only be called, if the state of one of the endstops changed.
465
+// Enable this feature if all enabled endstop pins are interrupt-capable.
466
+// This will remove the need to poll the interrupt pins, saving many CPU cycles.
467 467
 //#define ENDSTOP_INTERRUPTS_FEATURE
468 468
 
469 469
 //=============================================================================

+ 2
- 2
Marlin/example_configurations/K8400/Configuration.h View File

@@ -445,8 +445,8 @@
445 445
 #define Z_MAX_ENDSTOP_INVERTING true  // set to true to invert the logic of the endstop.
446 446
 #define Z_MIN_PROBE_ENDSTOP_INVERTING true  // set to true to invert the logic of the endstop.
447 447
 
448
-// If all used endstop pins are able to cause interrupts, you can enable ENDSTOP_INTERRUPTS_FEATURE.
449
-// Then the function testing the endstops will only be called, if the state of one of the endstops changed.
448
+// Enable this feature if all enabled endstop pins are interrupt-capable.
449
+// This will remove the need to poll the interrupt pins, saving many CPU cycles.
450 450
 //#define ENDSTOP_INTERRUPTS_FEATURE
451 451
 
452 452
 //=============================================================================

+ 2
- 2
Marlin/example_configurations/K8400/Dual-head/Configuration.h View File

@@ -445,8 +445,8 @@
445 445
 #define Z_MAX_ENDSTOP_INVERTING true  // set to true to invert the logic of the endstop.
446 446
 #define Z_MIN_PROBE_ENDSTOP_INVERTING true  // set to true to invert the logic of the endstop.
447 447
 
448
-// If all used endstop pins are able to cause interrupts, you can enable ENDSTOP_INTERRUPTS_FEATURE.
449
-// Then the function testing the endstops will only be called, if the state of one of the endstops changed.
448
+// Enable this feature if all enabled endstop pins are interrupt-capable.
449
+// This will remove the need to poll the interrupt pins, saving many CPU cycles.
450 450
 //#define ENDSTOP_INTERRUPTS_FEATURE
451 451
 
452 452
 //=============================================================================

+ 2
- 2
Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h View File

@@ -445,8 +445,8 @@
445 445
 #define Z_MAX_ENDSTOP_INVERTING true  // set to true to invert the logic of the endstop.
446 446
 #define Z_MIN_PROBE_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
447 447
 
448
-// If all used endstop pins are able to cause interrupts, you can enable ENDSTOP_INTERRUPTS_FEATURE.
449
-// Then the function testing the endstops will only be called, if the state of one of the endstops changed.
448
+// Enable this feature if all enabled endstop pins are interrupt-capable.
449
+// This will remove the need to poll the interrupt pins, saving many CPU cycles.
450 450
 //#define ENDSTOP_INTERRUPTS_FEATURE
451 451
 
452 452
 //=============================================================================

+ 2
- 2
Marlin/example_configurations/RigidBot/Configuration.h View File

@@ -442,8 +442,8 @@
442 442
 #define Z_MAX_ENDSTOP_INVERTING true  // set to true to invert the logic of the endstop.
443 443
 #define Z_MIN_PROBE_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
444 444
 
445
-// If all used endstop pins are able to cause interrupts, you can enable ENDSTOP_INTERRUPTS_FEATURE.
446
-// Then the function testing the endstops will only be called, if the state of one of the endstops changed.
445
+// Enable this feature if all enabled endstop pins are interrupt-capable.
446
+// This will remove the need to poll the interrupt pins, saving many CPU cycles.
447 447
 //#define ENDSTOP_INTERRUPTS_FEATURE
448 448
 
449 449
 //=============================================================================

+ 2
- 2
Marlin/example_configurations/SCARA/Configuration.h View File

@@ -460,8 +460,8 @@
460 460
 #define Z_MAX_ENDSTOP_INVERTING true  // set to true to invert the logic of the endstop.
461 461
 #define Z_MIN_PROBE_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
462 462
 
463
-// If all used endstop pins are able to cause interrupts, you can enable ENDSTOP_INTERRUPTS_FEATURE.
464
-// Then the function testing the endstops will only be called, if the state of one of the endstops changed.
463
+// Enable this feature if all enabled endstop pins are interrupt-capable.
464
+// This will remove the need to poll the interrupt pins, saving many CPU cycles.
465 465
 //#define ENDSTOP_INTERRUPTS_FEATURE
466 466
 
467 467
 //=============================================================================

+ 2
- 2
Marlin/example_configurations/TAZ4/Configuration.h View File

@@ -466,8 +466,8 @@
466 466
 #define Z_MAX_ENDSTOP_INVERTING true  // set to true to invert the logic of the endstop.
467 467
 #define Z_MIN_PROBE_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
468 468
 
469
-// If all used endstop pins are able to cause interrupts, you can enable ENDSTOP_INTERRUPTS_FEATURE.
470
-// Then the function testing the endstops will only be called, if the state of one of the endstops changed.
469
+// Enable this feature if all enabled endstop pins are interrupt-capable.
470
+// This will remove the need to poll the interrupt pins, saving many CPU cycles.
471 471
 //#define ENDSTOP_INTERRUPTS_FEATURE
472 472
 
473 473
 //=============================================================================

+ 2
- 2
Marlin/example_configurations/WITBOX/Configuration.h View File

@@ -437,8 +437,8 @@
437 437
 #define Z_MAX_ENDSTOP_INVERTING true  // set to true to invert the logic of the endstop.
438 438
 #define Z_MIN_PROBE_ENDSTOP_INVERTING true  // set to true to invert the logic of the endstop.
439 439
 
440
-// If all used endstop pins are able to cause interrupts, you can enable ENDSTOP_INTERRUPTS_FEATURE.
441
-// Then the function testing the endstops will only be called, if the state of one of the endstops changed.
440
+// Enable this feature if all enabled endstop pins are interrupt-capable.
441
+// This will remove the need to poll the interrupt pins, saving many CPU cycles.
442 442
 //#define ENDSTOP_INTERRUPTS_FEATURE
443 443
 
444 444
 //=============================================================================

+ 2
- 2
Marlin/example_configurations/adafruit/ST7565/Configuration.h View File

@@ -445,8 +445,8 @@
445 445
 #define Z_MAX_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
446 446
 #define Z_MIN_PROBE_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
447 447
 
448
-// If all used endstop pins are able to cause interrupts, you can enable ENDSTOP_INTERRUPTS_FEATURE.
449
-// Then the function testing the endstops will only be called, if the state of one of the endstops changed.
448
+// Enable this feature if all enabled endstop pins are interrupt-capable.
449
+// This will remove the need to poll the interrupt pins, saving many CPU cycles.
450 450
 //#define ENDSTOP_INTERRUPTS_FEATURE
451 451
 
452 452
 //=============================================================================

+ 2
- 2
Marlin/example_configurations/delta/biv2.5/Configuration.h View File

@@ -489,8 +489,8 @@
489 489
 #define Z_MAX_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
490 490
 #define Z_MIN_PROBE_ENDSTOP_INVERTING true  // set to true to invert the logic of the endstop.
491 491
 
492
-// If all used endstop pins are able to cause interrupts, you can enable ENDSTOP_INTERRUPTS_FEATURE.
493
-// Then the function testing the endstops will only be called, if the state of one of the endstops changed.
492
+// Enable this feature if all enabled endstop pins are interrupt-capable.
493
+// This will remove the need to poll the interrupt pins, saving many CPU cycles.
494 494
 //#define ENDSTOP_INTERRUPTS_FEATURE
495 495
 
496 496
 //=============================================================================

+ 2
- 2
Marlin/example_configurations/delta/generic/Configuration.h View File

@@ -489,8 +489,8 @@
489 489
 #define Z_MAX_ENDSTOP_INVERTING true  // set to true to invert the logic of the endstop.
490 490
 #define Z_MIN_PROBE_ENDSTOP_INVERTING true  // set to true to invert the logic of the endstop.
491 491
 
492
-// If all used endstop pins are able to cause interrupts, you can enable ENDSTOP_INTERRUPTS_FEATURE.
493
-// Then the function testing the endstops will only be called, if the state of one of the endstops changed.
492
+// Enable this feature if all enabled endstop pins are interrupt-capable.
493
+// This will remove the need to poll the interrupt pins, saving many CPU cycles.
494 494
 //#define ENDSTOP_INTERRUPTS_FEATURE
495 495
 
496 496
 //=============================================================================

+ 2
- 2
Marlin/example_configurations/delta/kossel_mini/Configuration.h View File

@@ -489,8 +489,8 @@
489 489
 #define Z_MAX_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
490 490
 #define Z_MIN_PROBE_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
491 491
 
492
-// If all used endstop pins are able to cause interrupts, you can enable ENDSTOP_INTERRUPTS_FEATURE.
493
-// Then the function testing the endstops will only be called, if the state of one of the endstops changed.
492
+// Enable this feature if all enabled endstop pins are interrupt-capable.
493
+// This will remove the need to poll the interrupt pins, saving many CPU cycles.
494 494
 //#define ENDSTOP_INTERRUPTS_FEATURE
495 495
 
496 496
 //=============================================================================

+ 2
- 2
Marlin/example_configurations/delta/kossel_pro/Configuration.h View File

@@ -478,8 +478,8 @@
478 478
 #define Z_MAX_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
479 479
 #define Z_MIN_PROBE_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
480 480
 
481
-// If all used endstop pins are able to cause interrupts, you can enable ENDSTOP_INTERRUPTS_FEATURE.
482
-// Then the function testing the endstops will only be called, if the state of one of the endstops changed.
481
+// Enable this feature if all enabled endstop pins are interrupt-capable.
482
+// This will remove the need to poll the interrupt pins, saving many CPU cycles.
483 483
 //#define ENDSTOP_INTERRUPTS_FEATURE
484 484
 
485 485
 //=============================================================================

+ 2
- 2
Marlin/example_configurations/delta/kossel_xl/Configuration.h View File

@@ -487,8 +487,8 @@
487 487
 #define Z_MAX_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
488 488
 #define Z_MIN_PROBE_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
489 489
 
490
-// If all used endstop pins are able to cause interrupts, you can enable ENDSTOP_INTERRUPTS_FEATURE.
491
-// Then the function testing the endstops will only be called, if the state of one of the endstops changed.
490
+// Enable this feature if all enabled endstop pins are interrupt-capable.
491
+// This will remove the need to poll the interrupt pins, saving many CPU cycles.
492 492
 //#define ENDSTOP_INTERRUPTS_FEATURE
493 493
 
494 494
 //=============================================================================

+ 2
- 2
Marlin/example_configurations/makibox/Configuration.h View File

@@ -448,8 +448,8 @@
448 448
 #define Z_MAX_ENDSTOP_INVERTING true  // set to true to invert the logic of the endstop.
449 449
 #define Z_MIN_PROBE_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
450 450
 
451
-// If all used endstop pins are able to cause interrupts, you can enable ENDSTOP_INTERRUPTS_FEATURE.
452
-// Then the function testing the endstops will only be called, if the state of one of the endstops changed.
451
+// Enable this feature if all enabled endstop pins are interrupt-capable.
452
+// This will remove the need to poll the interrupt pins, saving many CPU cycles.
453 453
 //#define ENDSTOP_INTERRUPTS_FEATURE
454 454
 
455 455
 //=============================================================================

+ 2
- 2
Marlin/example_configurations/tvrrug/Round2/Configuration.h View File

@@ -435,8 +435,8 @@
435 435
 #define Z_MAX_ENDSTOP_INVERTING true  // set to true to invert the logic of the endstop.
436 436
 #define Z_MIN_PROBE_ENDSTOP_INVERTING true  // set to true to invert the logic of the endstop.
437 437
 
438
-// If all used endstop pins are able to cause interrupts, you can enable ENDSTOP_INTERRUPTS_FEATURE.
439
-// Then the function testing the endstops will only be called, if the state of one of the endstops changed.
438
+// Enable this feature if all enabled endstop pins are interrupt-capable.
439
+// This will remove the need to poll the interrupt pins, saving many CPU cycles.
440 440
 //#define ENDSTOP_INTERRUPTS_FEATURE
441 441
 
442 442
 //=============================================================================

+ 11
- 9
Marlin/stepper.cpp View File

@@ -378,19 +378,21 @@ void Stepper::isr() {
378 378
   }
379 379
 
380 380
   // Update endstops state, if enabled
381
-  if (endstops.enabled
381
+  if ((endstops.enabled
382 382
     #if HAS_BED_PROBE
383 383
       || endstops.z_probe_enabled
384 384
     #endif
385
-  )
386
-  #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
387
-    if(e_hit) {
388
-  #endif
389
-      endstops.update();
390
-  #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
385
+    )
386
+    #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
387
+      && e_hit
388
+    #endif
389
+  ) {
390
+    endstops.update();
391
+
392
+    #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
391 393
       e_hit--;
392
-    }
393
-  #endif
394
+    #endif
395
+  }
394 396
 
395 397
   // Take multiple steps per interrupt (For high speed moves)
396 398
   bool all_steps_done = false;

Loading…
Cancel
Save