File tree Expand file tree Collapse file tree 1 file changed +15
-17
lines changed
Expand file tree Collapse file tree 1 file changed +15
-17
lines changed Original file line number Diff line number Diff line change @@ -149,30 +149,28 @@ void stepperTask(void *parameter) {
149149 dma.rw_pos = 0 ;
150150
151151 while (dma.rw_pos < DMA_SAMPLE_COUNT) {
152- // Fill with the port data post pulse_phase until the next step
153- if (nextMainISR && TERN1 (LIN_ADVANCE, nextAdvanceISR))
154- i2s_push_sample ();
155-
156- // i2s_push_sample() is also called from Stepper::pulse_phase_isr() and Stepper::advance_isr()
157- // in a rare case where both are called, we need to double decrement the counters
158- const uint8_t push_count = 1 + (!nextMainISR && TERN0 (LIN_ADVANCE, !nextAdvanceISR));
159-
152+ if (!nextMainISR) {
153+ Stepper::pulse_phase_isr ();
154+ nextMainISR = Stepper::block_phase_isr ();
155+ }
160156 #if ENABLED(LIN_ADVANCE)
161- if (!nextAdvanceISR) {
157+ else if (!nextAdvanceISR) {
162158 Stepper::advance_isr ();
163159 nextAdvanceISR = Stepper::la_interval;
164160 }
165- else if (nextAdvanceISR == Stepper::LA_ADV_NEVER)
166- nextAdvanceISR = Stepper::la_interval;
167161 #endif
162+ else
163+ i2s_push_sample ();
168164
169- if (!nextMainISR) {
170- Stepper::pulse_phase_isr ();
171- nextMainISR = Stepper::block_phase_isr ();
172- }
165+ nextMainISR--;
173166
174- nextMainISR -= push_count;
175- TERN_ (LIN_ADVANCE, nextAdvanceISR -= push_count);
167+ #if ENABLED(LIN_ADVANCE)
168+ if (nextAdvanceISR == Stepper::LA_ADV_NEVER)
169+ nextAdvanceISR = Stepper::la_interval;
170+
171+ if (nextAdvanceISR && nextAdvanceISR != Stepper::LA_ADV_NEVER)
172+ nextAdvanceISR--;
173+ #endif
176174 }
177175 }
178176}
You can’t perform that action at this time.
0 commit comments