|
@@ -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_
|