mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2025-03-28 00:49:09 +00:00
🐛 Fix potential I2S buffer overwrite (#25113)
This commit is contained in:
parent
b3f65b674f
commit
f81c468f1e
1 changed files with 17 additions and 19 deletions
|
@ -149,30 +149,28 @@ void stepperTask(void *parameter) {
|
||||||
dma.rw_pos = 0;
|
dma.rw_pos = 0;
|
||||||
|
|
||||||
while (dma.rw_pos < DMA_SAMPLE_COUNT) {
|
while (dma.rw_pos < DMA_SAMPLE_COUNT) {
|
||||||
// Fill with the port data post pulse_phase until the next step
|
|
||||||
if (nextMainISR && TERN1(LIN_ADVANCE, nextAdvanceISR))
|
|
||||||
i2s_push_sample();
|
|
||||||
|
|
||||||
// i2s_push_sample() is also called from Stepper::pulse_phase_isr() and Stepper::advance_isr()
|
|
||||||
// in a rare case where both are called, we need to double decrement the counters
|
|
||||||
const uint8_t push_count = 1 + (!nextMainISR && TERN0(LIN_ADVANCE, !nextAdvanceISR));
|
|
||||||
|
|
||||||
#if ENABLED(LIN_ADVANCE)
|
|
||||||
if (!nextAdvanceISR) {
|
|
||||||
Stepper::advance_isr();
|
|
||||||
nextAdvanceISR = Stepper::la_interval;
|
|
||||||
}
|
|
||||||
else if (nextAdvanceISR == Stepper::LA_ADV_NEVER)
|
|
||||||
nextAdvanceISR = Stepper::la_interval;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!nextMainISR) {
|
if (!nextMainISR) {
|
||||||
Stepper::pulse_phase_isr();
|
Stepper::pulse_phase_isr();
|
||||||
nextMainISR = Stepper::block_phase_isr();
|
nextMainISR = Stepper::block_phase_isr();
|
||||||
}
|
}
|
||||||
|
#if ENABLED(LIN_ADVANCE)
|
||||||
|
else if (!nextAdvanceISR) {
|
||||||
|
Stepper::advance_isr();
|
||||||
|
nextAdvanceISR = Stepper::la_interval;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else
|
||||||
|
i2s_push_sample();
|
||||||
|
|
||||||
nextMainISR -= push_count;
|
nextMainISR--;
|
||||||
TERN_(LIN_ADVANCE, nextAdvanceISR -= push_count);
|
|
||||||
|
#if ENABLED(LIN_ADVANCE)
|
||||||
|
if (nextAdvanceISR == Stepper::LA_ADV_NEVER)
|
||||||
|
nextAdvanceISR = Stepper::la_interval;
|
||||||
|
|
||||||
|
if (nextAdvanceISR && nextAdvanceISR != Stepper::LA_ADV_NEVER)
|
||||||
|
nextAdvanceISR--;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue