dda.c: deal with endstop hits while still accelerating.

Also, move_state.step_no must be read atomically.
This commit is contained in:
Markus Hitter 2013-10-30 20:09:00 +01:00
parent 5ee9a0bd3c
commit fa1a7d4ef7
1 changed files with 7 additions and 3 deletions

10
dda.c
View File

@ -765,11 +765,15 @@ void dda_clock() {
// but start deceleration here.
ATOMIC_START
move_state.endstop_stop = 1;
// A "-=" would cause an overflow.
dda->total_steps = dda->total_steps - dda->rampdown_steps + move_state.step_no;
if (move_state.step_no < dda->rampup_steps) // still accelerating
dda->total_steps = move_state.step_no * 2;
else
// A "-=" would overflow earlier.
dda->total_steps = dda->total_steps - dda->rampdown_steps +
move_state.step_no;
dda->rampdown_steps = move_state.step_no;
ATOMIC_END
// Not atomic, because not used in dda_step().
dda->rampdown_steps = move_state.step_no;
dda->rampup_steps = 0; // in case we're still accelerating
#else
dda->live = 0;