mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2025-06-30 10:50:44 +00:00
Better handling of DELAY_NS and DELAY_US (#10716)
Co-Authored-By: ejtagle <ejtagle@hotmail.com>
This commit is contained in:
parent
f5aaa2d6c0
commit
a1062eec5b
21 changed files with 273 additions and 268 deletions
Marlin/src/module
|
@ -41,15 +41,18 @@
|
|||
* along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* The timer calculations of this module informed by the 'RepRap cartesian firmware' by Zack Smith
|
||||
and Philipp Tiefenbacher. */
|
||||
/**
|
||||
* Timer calculations informed by the 'RepRap cartesian firmware' by Zack Smith
|
||||
* and Philipp Tiefenbacher.
|
||||
*/
|
||||
|
||||
/* Jerk controlled movements planner added by Eduardo José Tagle in April
|
||||
2018, Equations based on Synthethos TinyG2 sources, but the fixed-point
|
||||
implementation is a complete new one, as we are running the ISR with a
|
||||
variable period.
|
||||
Also implemented the Bézier velocity curve evaluation in ARM assembler,
|
||||
to avoid impacting ISR speed. */
|
||||
/**
|
||||
* Jerk controlled movements planner added Apr 2018 by Eduardo José Tagle.
|
||||
* Equations based on Synthethos TinyG2 sources, but the fixed-point
|
||||
* implementation is new, as we are running the ISR with a variable period.
|
||||
* Also implemented the Bézier velocity curve evaluation in ARM assembler,
|
||||
* to avoid impacting ISR speed.
|
||||
*/
|
||||
|
||||
#include "stepper.h"
|
||||
|
||||
|
@ -67,6 +70,7 @@
|
|||
#include "../gcode/queue.h"
|
||||
#include "../sd/cardreader.h"
|
||||
#include "../Marlin.h"
|
||||
#include "../HAL/Delay.h"
|
||||
|
||||
#if MB(ALLIGATOR)
|
||||
#include "../feature/dac/dac_dac084s085.h"
|
||||
|
@ -1471,7 +1475,7 @@ void Stepper::isr() {
|
|||
while (EXTRA_CYCLES_XYZE > (uint32_t)(HAL_timer_get_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
|
||||
pulse_start = HAL_timer_get_count(PULSE_TIMER_NUM);
|
||||
#elif EXTRA_CYCLES_XYZE > 0
|
||||
DELAY_NOPS(EXTRA_CYCLES_XYZE);
|
||||
DELAY_NS(EXTRA_CYCLES_XYZE * NANOSECONDS_PER_CYCLE);
|
||||
#endif
|
||||
|
||||
#if HAS_X_STEP
|
||||
|
@ -1506,7 +1510,7 @@ void Stepper::isr() {
|
|||
#if EXTRA_CYCLES_XYZE > 20
|
||||
if (i) while (EXTRA_CYCLES_XYZE > (uint32_t)(HAL_timer_get_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
|
||||
#elif EXTRA_CYCLES_XYZE > 0
|
||||
if (i) DELAY_NOPS(EXTRA_CYCLES_XYZE);
|
||||
if (i) DELAY_NS(EXTRA_CYCLES_XYZE * NANOSECONDS_PER_CYCLE);
|
||||
#endif
|
||||
|
||||
} // steps_loop
|
||||
|
@ -1739,7 +1743,7 @@ void Stepper::isr() {
|
|||
while (EXTRA_CYCLES_E > (hal_timer_t)(HAL_timer_get_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
|
||||
pulse_start = HAL_timer_get_count(PULSE_TIMER_NUM);
|
||||
#elif EXTRA_CYCLES_E > 0
|
||||
DELAY_NOPS(EXTRA_CYCLES_E);
|
||||
DELAY_NS(EXTRA_CYCLES_E * NANOSECONDS_PER_CYCLE);
|
||||
#endif
|
||||
|
||||
switch (LA_active_extruder) {
|
||||
|
@ -1762,7 +1766,7 @@ void Stepper::isr() {
|
|||
#if EXTRA_CYCLES_E > 20
|
||||
if (e_steps) while (EXTRA_CYCLES_E > (hal_timer_t)(HAL_timer_get_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
|
||||
#elif EXTRA_CYCLES_E > 0
|
||||
if (e_steps) DELAY_NOPS(EXTRA_CYCLES_E);
|
||||
if (e_steps) DELAY_NS(EXTRA_CYCLES_E * NANOSECONDS_PER_CYCLE);
|
||||
#endif
|
||||
|
||||
} // e_steps
|
||||
|
@ -2146,13 +2150,13 @@ void Stepper::report_positions() {
|
|||
#else
|
||||
#define _SAVE_START NOOP
|
||||
#if EXTRA_CYCLES_BABYSTEP > 0
|
||||
#define _PULSE_WAIT DELAY_NOPS(EXTRA_CYCLES_BABYSTEP)
|
||||
#define _PULSE_WAIT DELAY_NS(EXTRA_CYCLES_BABYSTEP * NANOSECONDS_PER_CYCLE)
|
||||
#elif STEP_PULSE_CYCLES > 0
|
||||
#define _PULSE_WAIT NOOP
|
||||
#elif ENABLED(DELTA)
|
||||
#define _PULSE_WAIT delayMicroseconds(2);
|
||||
#define _PULSE_WAIT DELAY_US(2);
|
||||
#else
|
||||
#define _PULSE_WAIT delayMicroseconds(4);
|
||||
#define _PULSE_WAIT DELAY_US(4);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue