Firmware2/buildroot/share/pin_interrupt_test/pin_interrupt_test.ino
AnHardt f3eee02596 Introduce endstop interrupts
If ENDSTOP_INTERRUPTS_FEATURE is enabled this tries to set up interrupt routines
for all used endstop pins. If this worked without errors, `endstops.update()` is called
only if one of the endstops changed its state.

The new interrupt routines do not really check the endstops and react upon them. All what they
do, is to set a flag if it makes sense to call the endstop test we are used to.

This can be used on:
* ARM (DUE) based boards - all pins can raise interrupts,
* RAMPS - all 6 endstop pins plus some other on EXT-2 can raise interrupts,
* RAMPS based boards - as long the designers did not change the pins for the endstops or at least left enough,
* all boards, if there are enough pins that can raise interrupts, and you are willing/able to swap with pins dedicated to other purpose.
2016-11-15 12:07:41 +01:00

33 lines
1019 B
C++

// Search pins uasable for endstop-interupts
// Compile with the same settings you'd use with Marlin.
#if defined(ARDUINO_AVR_MEGA2560) || defined(ARDUINO_AVR_MEGA)
#undef digitalPinToPCICR
#define digitalPinToPCICR(p) ( (((p) >= 10) && ((p) <= 15)) || \
(((p) >= 50) && ((p) <= 53)) || \
(((p) >= 62) && ((p) <= 69)) ? (&PCICR) : ((uint8_t *)0) )
#endif
void setup() {
Serial.begin(9600);
Serial.println("PINs causing interrups are:");
for(int i=2; i<NUM_DIGITAL_PINS; i++){
if( digitalPinToPCICR(i) != NULL || (int)digitalPinToInterrupt(i) != -1 ) {
for (int j= 0; j<NUM_ANALOG_INPUTS; j++){
if(analogInputToDigitalPin(j) == i) {
Serial.print("A");
Serial.print(j);
Serial.print(" = ");
}
}
Serial.print("D");
Serial.println(i);
}
}
Serial.println("Arduino pin numbering!");
}
void loop() {
// put your main code here, to run repeatedly:
}