From b23d2554913705a503f4edc66bfd4b4f858185b2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 3 Nov 2016 16:42:44 -0500 Subject: [PATCH] Move macros above Stepper::babystep --- Marlin/stepper.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 4ed9f3221..6621e1962 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -1108,25 +1108,25 @@ void Stepper::report_positions() { #if ENABLED(BABYSTEPPING) + #define _ENABLE(axis) enable_## axis() + #define _READ_DIR(AXIS) AXIS ##_DIR_READ + #define _INVERT_DIR(AXIS) INVERT_## AXIS ##_DIR + #define _APPLY_DIR(AXIS, INVERT) AXIS ##_APPLY_DIR(INVERT, true) + + #define BABYSTEP_AXIS(axis, AXIS, INVERT) { \ + _ENABLE(axis); \ + uint8_t old_pin = _READ_DIR(AXIS); \ + _APPLY_DIR(AXIS, _INVERT_DIR(AXIS)^direction^INVERT); \ + _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS), true); \ + delayMicroseconds(2); \ + _APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS), true); \ + _APPLY_DIR(AXIS, old_pin); \ + } + // MUST ONLY BE CALLED BY AN ISR, // No other ISR should ever interrupt this! void Stepper::babystep(const uint8_t axis, const bool direction) { - #define _ENABLE(axis) enable_## axis() - #define _READ_DIR(AXIS) AXIS ##_DIR_READ - #define _INVERT_DIR(AXIS) INVERT_## AXIS ##_DIR - #define _APPLY_DIR(AXIS, INVERT) AXIS ##_APPLY_DIR(INVERT, true) - - #define BABYSTEP_AXIS(axis, AXIS, INVERT) { \ - _ENABLE(axis); \ - uint8_t old_pin = _READ_DIR(AXIS); \ - _APPLY_DIR(AXIS, _INVERT_DIR(AXIS)^direction^INVERT); \ - _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS), true); \ - delayMicroseconds(2); \ - _APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS), true); \ - _APPLY_DIR(AXIS, old_pin); \ - } - switch (axis) { case X_AXIS: