Move endstop handling into a time-based procedure.

Before, endstops were checked on every step, wasting precious time.
Checking them 500 times a second should be more than sufficient.

Additionally, an endstop stop now properly decelerates the movement.
This is one important step towards handling accidental endstop hits
gracefully, as it avoids step losses in such situations.
Faster implementation of integer square root.

Implementation by Roland Brochard <zuzuf86@gmail.com>.

Note: If you wonder how code doing multiplications can be faster than
code doing just shifts and increments: I've measured it. One million
square roots in 30 seconds with the new code instead of 220 seconds
with the old code on a Gen7 20 MHz. That's just 30 microseconds or
600 CPU cycles per root.

Code used for the measurement (by a stopwatch) in mendel.c:
...
*include "dda_maths.h"
*include "delay.h"
int main (void)
{
  uint32_t i, j;

  serial_init();
  sei();
  serial_writestr_P(PSTR("start\n"));
  for (i = 0; i < 1000000; i++) {
    j = int_sqrt(i);
  }
  serial_writestr_P(PSTR("done\n"));
  delay_ms(20);
  cli();

  init();
...

--Traumflug
Silence a false positive warning.
config.h: introduce PS_MOSFET_PIN for Sanguish support.
Add config.sanguish.h.
dda.c: allow protected re-entry for time based stepper calculations.

This becomes more important when acceleration is calculated
there, too.
analog.c: use atomic macros.
timer.c/.h: make TICK_TIME macros available globally.
dda_maths.c/.h: implement an integer inverse square root algorithm.

This 1/sqrt(x) implementation is a 12 bits fixed point implementation
and a bit faster than a 32 bits divide (it takes about 11% less time
to complete) and could be even faster if one requires only 8 bits.
Also, precision starts getting poor for big values of n which are
likely to be required by small acceleration values.
dda.c: update last_dda also when idle.
dda.c: more notes on rampup_steps calculation.
According to avr-libc documentation, ISR() handles SREG its self.
timer.c: the concept of a "new move" was abandoned long time ago.

This doesn't matter much, as the timer overflows 300 times/second
worst case, so the very first step of a series of moves is
delayed never more than 30 milliseconds. Hardly recognizeable
by a human.

Saves a nice 40 bytes and improves max step rate by several percent.
dda_lookahead.c: simplify bailout condition tests.

We have the nullmove flag already and the current move can't be
a nullmove, because in this case we wouldn't enter the function.
dda.c: fix ACCELERATION_RAMPING #ifdefs.
Move the branch accel_clock into the attic.

This was a very interesting approach, but for the forseeable
future it's unlikely the code will replace the current one.

However, many parts of it were already moved to the experimental
branch. It turns out the approach with recalculating acceleration
at a constant time interval is exactly right, but works much more
precisely when keeping maths step-based.
Implement Roland Brochards' new acceleration maths clock-based.

His implementation was done on every step and as it turns out,
the very same maths works just fine in the clock interrupt.
Reason for the clock interrupt is: it allows about 3 times
higher step rates.

This strategy is not only substantially faster, but also
a bit smaller.

One funny anecdote: the acceleration initialisation value, C0,
was taken from elsewhere in the code as-is. Still it had to be
adjusted by a factor of sqrt(2) to now(!) match the physics
formulas and to get ramps reasonably matching the prediction
(and my pocket calculator). Apparently the code before
accumulated enough rounding errors to compensate for the
wrong formula.
Fix endstop stop condition for clock-based acceleration.

This required a strategy change, since move_state.n is no longer
decreasing in steps of 1.
dda.c/.h: move n and c back into the dda structure.

This is a preparation for starting a move from non-zero speeds,
which is needed for look-ahead. Keeping both variables in
move_state and doing the calculations in dda_start() is possible
in principle, but might not fit the tight time budget we have when
going from one movement to the next at high step rates.

To deal with this, we have to pre-calculate n and c, so we have
to move it back into the DDA structure. It was there a year ago
already, but moved into move_state to save RAM (move_state exists
only once, dda as often as there are movement queue entries).
Add a testcase for look-ahead (smooth curves).