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.
This commit is contained in:
AnHardt
2016-11-05 22:38:48 +01:00
parent 665b7f3893
commit f3eee02596
26 changed files with 329 additions and 1 deletions

View File

@ -310,6 +310,10 @@ void Stepper::set_directions() {
#endif // !ADVANCE && !LIN_ADVANCE
}
#if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
extern volatile uint8_t e_hit;
#endif
/**
* Stepper Driver Interrupt
*
@ -378,7 +382,15 @@ void Stepper::isr() {
#if HAS_BED_PROBE
|| endstops.z_probe_enabled
#endif
) endstops.update();
)
#if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
if(e_hit) {
#endif
endstops.update();
#if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
e_hit--;
}
#endif
// Take multiple steps per interrupt (For high speed moves)
bool all_steps_done = false;