From 0737b1673b8a3cb1274cf78794fa9117ecb669f2 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Fri, 27 Dec 2019 18:55:45 -0800 Subject: [PATCH 1/3] Fix unused variable warnings in stepper.cpp when minimum pulse time is not used --- Marlin/src/module/stepper.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index c651a24d302b..bcfad24bc554 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -1435,9 +1435,11 @@ void Stepper::stepper_pulse_phase_isr() { step_events_completed += events_to_do; // Take multiple steps per interrupt (For high speed moves) - bool firstStep = true; + #if (MINIMUM_STEPPER_PULSE || MAXIMUM_STEPPER_RATE) && DISABLED(I2S_STEPPER_STREAM) + bool firstStep = true; + hal_timer_t end_tick_count = 0; + #endif xyze_bool_t step_needed{0}; - hal_timer_t end_tick_count = 0; do { #define _APPLY_STEP(AXIS) AXIS ##_APPLY_STEP @@ -1947,8 +1949,10 @@ uint32_t Stepper::stepper_block_phase_isr() { //const hal_timer_t added_step_ticks = hal_timer_t(ADDED_STEP_TICKS); // Step E stepper if we have steps - bool firstStep = true; - hal_timer_t end_tick_count = 0; + #if (MINIMUM_STEPPER_PULSE || MAXIMUM_STEPPER_RATE) && DISABLED(I2S_STEPPER_STREAM) + bool firstStep = true; + hal_timer_t end_tick_count = 0; + #endif while (LA_steps) { #if (MINIMUM_STEPPER_PULSE || MAXIMUM_STEPPER_RATE) && DISABLED(I2S_STEPPER_STREAM) From 319cad458ab13a1521cdfea16bcae460f4e85e4c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 1 Jan 2020 22:04:53 -0600 Subject: [PATCH 2/3] Add shortcut macros --- Marlin/src/module/stepper.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index bcfad24bc554..546dd017cd41 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -1405,6 +1405,9 @@ void Stepper::isr() { ENABLE_ISRS(); } +#define ISR_PULSE_CONTROL (MINIMUM_STEPPER_PULSE || MAXIMUM_STEPPER_RATE) +#define ISR_MULTI_STEPS (ISR_PULSE_CONTROL && DISABLED(I2S_STEPPER_STREAM)) + /** * This phase of the ISR should ONLY create the pulses for the steppers. * This prevents jitter caused by the interval between the start of the @@ -1433,9 +1436,9 @@ void Stepper::stepper_pulse_phase_isr() { // Just update the value we will get at the end of the loop step_events_completed += events_to_do; - + // Take multiple steps per interrupt (For high speed moves) - #if (MINIMUM_STEPPER_PULSE || MAXIMUM_STEPPER_RATE) && DISABLED(I2S_STEPPER_STREAM) + #if ISR_MULTI_STEPS bool firstStep = true; hal_timer_t end_tick_count = 0; #endif @@ -1496,7 +1499,7 @@ void Stepper::stepper_pulse_phase_isr() { PULSE_PREP(E); #endif - #if (MINIMUM_STEPPER_PULSE || MAXIMUM_STEPPER_RATE) && DISABLED(I2S_STEPPER_STREAM) + #if ISR_MULTI_STEPS if (firstStep) firstStep = false; else @@ -1527,7 +1530,7 @@ void Stepper::stepper_pulse_phase_isr() { #endif // TODO: need to deal with MINIMUM_STEPPER_PULSE over i2s - #if (MINIMUM_STEPPER_PULSE || MAXIMUM_STEPPER_RATE) && DISABLED(I2S_STEPPER_STREAM) + #if ISR_MULTI_STEPS START_HIGH_PULSE(); AWAIT_HIGH_PULSE(); #endif @@ -1560,7 +1563,7 @@ void Stepper::stepper_pulse_phase_isr() { #endif // !MIXING_EXTRUDER #endif // !LIN_ADVANCE - #if (MINIMUM_STEPPER_PULSE || MAXIMUM_STEPPER_RATE) && DISABLED(I2S_STEPPER_STREAM) + #if ISR_MULTI_STEPS if (events_to_do) START_LOW_PULSE(); #endif @@ -1949,13 +1952,13 @@ uint32_t Stepper::stepper_block_phase_isr() { //const hal_timer_t added_step_ticks = hal_timer_t(ADDED_STEP_TICKS); // Step E stepper if we have steps - #if (MINIMUM_STEPPER_PULSE || MAXIMUM_STEPPER_RATE) && DISABLED(I2S_STEPPER_STREAM) + #if ISR_MULTI_STEPS bool firstStep = true; hal_timer_t end_tick_count = 0; #endif while (LA_steps) { - #if (MINIMUM_STEPPER_PULSE || MAXIMUM_STEPPER_RATE) && DISABLED(I2S_STEPPER_STREAM) + #if ISR_MULTI_STEPS if (firstStep) firstStep = false; else @@ -1970,13 +1973,13 @@ uint32_t Stepper::stepper_block_phase_isr() { #endif // Enforce a minimum duration for STEP pulse ON - #if (MINIMUM_STEPPER_PULSE || MAXIMUM_STEPPER_RATE) + #if ISR_PULSE_CONTROL START_HIGH_PULSE(); #endif LA_steps < 0 ? ++LA_steps : --LA_steps; - #if (MINIMUM_STEPPER_PULSE || MAXIMUM_STEPPER_RATE) + #if ISR_PULSE_CONTROL AWAIT_HIGH_PULSE(); #endif @@ -1989,7 +1992,7 @@ uint32_t Stepper::stepper_block_phase_isr() { // For minimum pulse time wait before looping // Just wait for the requested pulse duration - #if (MINIMUM_STEPPER_PULSE || MAXIMUM_STEPPER_RATE) + #if ISR_PULSE_CONTROL if (LA_steps) START_LOW_PULSE(); #endif } // LA_steps From a9746ee980a693e9860f93fcf058fb597a33dda3 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 1 Jan 2020 22:05:16 -0600 Subject: [PATCH 3/3] Update stepper.cpp --- Marlin/src/module/stepper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 546dd017cd41..31bda4c517f2 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -1436,7 +1436,7 @@ void Stepper::stepper_pulse_phase_isr() { // Just update the value we will get at the end of the loop step_events_completed += events_to_do; - + // Take multiple steps per interrupt (For high speed moves) #if ISR_MULTI_STEPS bool firstStep = true;