dda.c: allow protected re-entry for time based stepper calculations.
This becomes more important when acceleration is calculated there, too.
This commit is contained in:
parent
c7ee530c62
commit
ccec75d9f8
11
dda.c
11
dda.c
|
|
@ -717,6 +717,7 @@ void dda_step(DDA *dda) {
|
|||
Updating speed 500 times a second is easily enough for smooth acceleration!
|
||||
*/
|
||||
void dda_clock() {
|
||||
static volatile uint8_t busy = 0;
|
||||
DDA *dda;
|
||||
static DDA *last_dda = NULL;
|
||||
static uint8_t endstop_stop = 0; ///< Stop due to endstop trigger
|
||||
|
|
@ -732,6 +733,13 @@ void dda_clock() {
|
|||
if (dda == NULL)
|
||||
return;
|
||||
|
||||
// Lengthy calculations ahead!
|
||||
// Make sure we didn't re-enter, then allow nested interrupts.
|
||||
if (busy)
|
||||
return;
|
||||
busy = 1;
|
||||
sei();
|
||||
|
||||
// Caution: we mangle step counters here without locking interrupts. This
|
||||
// means, we trust dda isn't changed behind our back, which could
|
||||
// in principle (but rarely) happen if endstops are checked not as
|
||||
|
|
@ -808,6 +816,9 @@ void dda_clock() {
|
|||
} /* if (endstop_stop == 0) */
|
||||
|
||||
last_dda = dda;
|
||||
|
||||
cli(); // Compensate sei() above.
|
||||
busy = 0;
|
||||
}
|
||||
|
||||
/// update global current_position struct
|
||||
|
|
|
|||
4
timer.c
4
timer.c
|
|
@ -57,8 +57,6 @@ ISR(TIMER1_COMPB_vect) {
|
|||
/*
|
||||
clock stuff
|
||||
*/
|
||||
dda_clock();
|
||||
|
||||
clock_counter_10ms += TICK_TIME_MS;
|
||||
if (clock_counter_10ms >= 10) {
|
||||
clock_counter_10ms -= 10;
|
||||
|
|
@ -77,6 +75,8 @@ ISR(TIMER1_COMPB_vect) {
|
|||
}
|
||||
}
|
||||
|
||||
dda_clock();
|
||||
|
||||
// restore status register
|
||||
MEMORY_BARRIER();
|
||||
SREG = sreg_save;
|
||||
|
|
|
|||
Loading…
Reference in New Issue