Move interrupt busy detection from dda_clock() to clock tick ISR.
The reason is, interrupts can't be re-entered on ARM, so we need a different mechanism.
This commit is contained in:
parent
a171a0c57f
commit
5d8e866501
11
dda.c
11
dda.c
|
|
@ -749,7 +749,6 @@ void dda_step(DDA *dda) {
|
|||
accurate curves!
|
||||
*/
|
||||
void dda_clock() {
|
||||
static volatile uint8_t busy = 0;
|
||||
DDA *dda;
|
||||
static DDA *last_dda = NULL;
|
||||
uint8_t endstop_trigger = 0;
|
||||
|
|
@ -769,13 +768,6 @@ 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
|
||||
|
|
@ -923,9 +915,6 @@ void dda_clock() {
|
|||
ATOMIC_END
|
||||
}
|
||||
#endif
|
||||
|
||||
cli(); // Compensate sei() above.
|
||||
busy = 0;
|
||||
}
|
||||
|
||||
/// update global current_position struct
|
||||
|
|
|
|||
16
timer-avr.c
16
timer-avr.c
|
|
@ -41,11 +41,25 @@ uint32_t step_extra_time = 0;
|
|||
Comparator B is the system clock, happens every TICK_TIME.
|
||||
*/
|
||||
ISR(TIMER1_COMPB_vect) {
|
||||
static volatile uint8_t busy = 0;
|
||||
|
||||
// set output compare register to the next clock tick
|
||||
OCR1B = (OCR1B + TICK_TIME) & 0xFFFF;
|
||||
|
||||
clock_tick();
|
||||
dda_clock();
|
||||
|
||||
/**
|
||||
Lengthy calculations ahead! Make sure we didn't re-enter, then allow
|
||||
nested interrupts.
|
||||
*/
|
||||
if ( ! busy) {
|
||||
busy = 1;
|
||||
sei();
|
||||
|
||||
dda_clock();
|
||||
|
||||
busy = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MOTHERBOARD
|
||||
|
|
|
|||
Loading…
Reference in New Issue