dda_lookahead.c: reduce size of ATOMIC section.

We calculate a safe join speed in dda_join_moves using data from
two source DDA movements. We ensure the DDA values we use are sane
by atomically copying them to local variables before beginning our
calculation. But later we discard all our results if the DDA went
live in the meantime, as evidenced by changes in `DDA->live` or
`DDA->id`.

Since we will not use the results of our calculations if either of
these change, we can safely reference all the other DDA values
non-atomically. Change the ATOMIC section to protect only the
`DDA->id` values at the start.

Added by Traumflug: this costs a negligible 4 bytes binary size:

  ATmega sizes               '168   '328(P)   '644(P)     '1280
  Program:  18082 bytes      127%       59%       29%       15%
     Data:   2176 bytes      213%      107%       54%       27%
   EEPROM:     32 bytes        4%        2%        2%        1%
This commit is contained in:
Phil Hord 2016-11-16 10:42:04 -08:00 committed by Markus Hitter
parent c33791333c
commit f0fa5f9f3e
1 changed files with 8 additions and 7 deletions

View File

@ -190,18 +190,19 @@ void dda_join_moves(DDA *prev, DDA *current) {
// Make sure we have 2 moves and the previous move is not already active // Make sure we have 2 moves and the previous move is not already active
if (prev->live == 0) { if (prev->live == 0) {
// Perform an atomic copy to preserve volatile parameters during the calculations // Copy DDA ids to verify later that nothing changed during calculations
ATOMIC_START ATOMIC_START
prev_id = prev->id; prev_id = prev->id;
prev_F = prev->endpoint.F;
prev_F_start_in_steps = prev->start_steps;
prev_total_steps = prev->total_steps;
crossF = current->crossF;
this_id = current->id; this_id = current->id;
this_total_steps = current->total_steps;
this_fast_axis = current->fast_axis;
ATOMIC_END ATOMIC_END
prev_F = prev->endpoint.F;
prev_F_start_in_steps = prev->start_steps;
prev_total_steps = prev->total_steps;
crossF = current->crossF;
this_total_steps = current->total_steps;
this_fast_axis = current->fast_axis;
// Here we have to distinguish between feedrate along the movement // Here we have to distinguish between feedrate along the movement
// direction and feedrate of the fast axis. They can differ by a factor // direction and feedrate of the fast axis. They can differ by a factor
// of 2. // of 2.