Permit Linear Advance with I2S Streaming (#24684)

This commit is contained in:
tombrazier
2022-09-02 03:04:46 +01:00
committed by Scott Lahteine
parent 647d459a15
commit c996bfddb7
6 changed files with 48 additions and 30 deletions

View File

@ -137,6 +137,10 @@ Stepper stepper; // Singleton
#include "../lcd/extui/ui_api.h"
#endif
#if ENABLED(I2S_STEPPER_STREAM)
#include "../HAL/ESP32/i2s.h"
#endif
// public:
#if EITHER(HAS_EXTRA_ENDSTOPS, Z_STEPPER_AUTO_ALIGN)
@ -1558,14 +1562,7 @@ void Stepper::isr() {
* On AVR the ISR epilogue+prologue is estimated at 100 instructions - Give 8µs as margin
* On ARM the ISR epilogue+prologue is estimated at 20 instructions - Give 1µs as margin
*/
min_ticks = HAL_timer_get_count(MF_TIMER_STEP) + hal_timer_t(
#ifdef __AVR__
8
#else
1
#endif
* (STEPPER_TIMER_TICKS_PER_US)
);
min_ticks = HAL_timer_get_count(MF_TIMER_STEP) + hal_timer_t(TERN(__AVR__, 8, 1) * (STEPPER_TIMER_TICKS_PER_US));
/**
* NB: If for some reason the stepper monopolizes the MPU, eventually the
@ -2472,18 +2469,19 @@ uint32_t Stepper::block_phase_isr() {
// the acceleration and speed values calculated in block_phase_isr().
// This helps keep LA in sync with, for example, S_CURVE_ACCELERATION.
la_delta_error += la_dividend;
if (la_delta_error >= 0) {
const bool step_needed = la_delta_error >= 0;
if (step_needed) {
count_position.e += count_direction.e;
la_advance_steps += count_direction.e;
la_delta_error -= advance_divisor;
// Set the STEP pulse ON
#if ENABLED(MIXING_EXTRUDER)
E_STEP_WRITE(mixer.get_next_stepper(), !INVERT_E_STEP_PIN);
#else
E_STEP_WRITE(stepper_extruder, !INVERT_E_STEP_PIN);
#endif
E_STEP_WRITE(TERN(MIXING_EXTRUDER, mixer.get_next_stepper(), stepper_extruder), !INVERT_E_STEP_PIN);
}
TERN_(I2S_STEPPER_STREAM, i2s_push_sample());
if (step_needed) {
// Enforce a minimum duration for STEP pulse ON
#if ISR_PULSE_CONTROL
USING_TIMED_PULSE();
@ -2492,11 +2490,7 @@ uint32_t Stepper::block_phase_isr() {
#endif
// Set the STEP pulse OFF
#if ENABLED(MIXING_EXTRUDER)
E_STEP_WRITE(mixer.get_stepper(), INVERT_E_STEP_PIN);
#else
E_STEP_WRITE(stepper_extruder, INVERT_E_STEP_PIN);
#endif
E_STEP_WRITE(TERN(MIXING_EXTRUDER, mixer.get_stepper(), stepper_extruder), INVERT_E_STEP_PIN);
}
}

View File

@ -318,6 +318,7 @@ constexpr ena_mask_t enable_overlap[] = {
class Stepper {
friend class KinematicSystem;
friend class DeltaKinematicSystem;
friend void stepperTask(void *);
public: