|
|
|
@ -22,14 +22,51 @@
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* stepper/indirection.h
|
|
|
|
|
* stepper/indirection.h - Stepper Indirection Macros
|
|
|
|
|
*
|
|
|
|
|
* Stepper motor driver indirection to allow some stepper functions to
|
|
|
|
|
* be done via SPI/I2c instead of direct pin manipulation.
|
|
|
|
|
* Each axis in a machine may have between 1 and 4 stepper motors.
|
|
|
|
|
* Currently X and Y allow for 1 or 2 steppers. Z can have up to 4.
|
|
|
|
|
* Extruders usually have one E stepper per nozzle.
|
|
|
|
|
*
|
|
|
|
|
* XYZ Special Cases
|
|
|
|
|
* - Delta: 3 steppers contribute to X, Y, and Z.
|
|
|
|
|
* - SCARA: A and B steppers contribute to X and Y by angular transformation.
|
|
|
|
|
* - CoreXY: A and B steppers contribute to X and Y in combination.
|
|
|
|
|
* - CoreXZ: A and B steppers contribute to X and Z in combination.
|
|
|
|
|
* - CoreYZ: A and B steppers contribute to Y and Z in combination.
|
|
|
|
|
*
|
|
|
|
|
* E Special Cases
|
|
|
|
|
* - SINGLENOZZLE: All Extruders have a single nozzle so there is one heater and no XYZ offset.
|
|
|
|
|
* - Switching Extruder: One stepper is used for each pair of nozzles with a switching mechanism.
|
|
|
|
|
* - Duplication Mode: Two or more steppers move in sync when `extruder_duplication_enabled` is set.
|
|
|
|
|
* With MULTI_NOZZLE_DUPLICATION a `duplication_e_mask` is also used.
|
|
|
|
|
* - Průša MMU1: One stepper is used with a switching mechanism. Odd numbered E indexes are reversed.
|
|
|
|
|
* - Průša MMU2: One stepper is used with a switching mechanism.
|
|
|
|
|
* - E_DUAL_STEPPER_DRIVERS: Two steppers always move in sync, possibly with opposite DIR states.
|
|
|
|
|
*
|
|
|
|
|
* Direct Stepper Control
|
|
|
|
|
* Where "Q" represents X Y Z I J K U V W / X2 Y2 Z2 Z3 Z4 / E0 E1 E2 E3 E4 E5 E6 E7
|
|
|
|
|
* Here each E index corresponds to a single E stepper driver.
|
|
|
|
|
*
|
|
|
|
|
* Q_ENABLE_INIT() Q_ENABLE_WRITE(S) Q_ENABLE_READ()
|
|
|
|
|
* Q_DIR_INIT() Q_DIR_WRITE(S) Q_DIR_READ()
|
|
|
|
|
* Q_STEP_INIT() Q_STEP_WRITE(S) Q_STEP_READ()
|
|
|
|
|
*
|
|
|
|
|
* Steppers may not have an enable state or may be enabled by other methods
|
|
|
|
|
* beyond a single pin (SOFTWARE_DRIVER_ENABLE) so these can be overriden:
|
|
|
|
|
* ENABLE_STEPPER_Q() DISABLE_STEPPER_Q()
|
|
|
|
|
*
|
|
|
|
|
* Axis Stepper Control (X Y Z I J K U V W)
|
|
|
|
|
* SOFTWARE_DRIVER_ENABLE gives all axes a status flag, so these macros will
|
|
|
|
|
* skip sending commands to steppers that are already in the desired state:
|
|
|
|
|
* ENABLE_AXIS_Q() DISABLE_AXIS_Q()
|
|
|
|
|
*
|
|
|
|
|
* E-Axis Stepper Control (0..n)
|
|
|
|
|
* For these macros the E index indicates a logical extruder (e.g., active_extruder).
|
|
|
|
|
*
|
|
|
|
|
* E_STEP_WRITE(E,V) FWD_E_DIR(E) REV_E_DIR(E)
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 2015 Dominik Wenger
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "../../inc/MarlinConfig.h"
|
|
|
|
|
|
|
|
|
|
#if HAS_TMC26X
|
|
|
|
@ -43,6 +80,8 @@
|
|
|
|
|
void restore_stepper_drivers(); // Called by powerManager.power_on()
|
|
|
|
|
void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
|
|
|
|
|
#define INVERT_DIR(AXIS, D) (TERN_(INVERT_## AXIS ##_DIR, !)(D))
|
|
|
|
|
|
|
|
|
|
// X Stepper
|
|
|
|
|
#ifndef X_ENABLE_INIT
|
|
|
|
|
#define X_ENABLE_INIT() SET_OUTPUT(X_ENABLE_PIN)
|
|
|
|
@ -51,7 +90,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef X_DIR_INIT
|
|
|
|
|
#define X_DIR_INIT() SET_OUTPUT(X_DIR_PIN)
|
|
|
|
|
#define X_DIR_WRITE(STATE) WRITE(X_DIR_PIN,STATE)
|
|
|
|
|
#define X_DIR_WRITE(STATE) WRITE(X_DIR_PIN,INVERT_DIR(X, STATE))
|
|
|
|
|
#define X_DIR_READ() bool(READ(X_DIR_PIN))
|
|
|
|
|
#endif
|
|
|
|
|
#define X_STEP_INIT() SET_OUTPUT(X_STEP_PIN)
|
|
|
|
@ -69,7 +108,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef Y_DIR_INIT
|
|
|
|
|
#define Y_DIR_INIT() SET_OUTPUT(Y_DIR_PIN)
|
|
|
|
|
#define Y_DIR_WRITE(STATE) WRITE(Y_DIR_PIN,STATE)
|
|
|
|
|
#define Y_DIR_WRITE(STATE) WRITE(Y_DIR_PIN,INVERT_DIR(Y, STATE))
|
|
|
|
|
#define Y_DIR_READ() bool(READ(Y_DIR_PIN))
|
|
|
|
|
#endif
|
|
|
|
|
#define Y_STEP_INIT() SET_OUTPUT(Y_STEP_PIN)
|
|
|
|
@ -88,7 +127,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef Z_DIR_INIT
|
|
|
|
|
#define Z_DIR_INIT() SET_OUTPUT(Z_DIR_PIN)
|
|
|
|
|
#define Z_DIR_WRITE(STATE) WRITE(Z_DIR_PIN,STATE)
|
|
|
|
|
#define Z_DIR_WRITE(STATE) WRITE(Z_DIR_PIN,INVERT_DIR(Z, STATE))
|
|
|
|
|
#define Z_DIR_READ() bool(READ(Z_DIR_PIN))
|
|
|
|
|
#endif
|
|
|
|
|
#define Z_STEP_INIT() SET_OUTPUT(Z_STEP_PIN)
|
|
|
|
@ -107,7 +146,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef X2_DIR_INIT
|
|
|
|
|
#define X2_DIR_INIT() SET_OUTPUT(X2_DIR_PIN)
|
|
|
|
|
#define X2_DIR_WRITE(STATE) WRITE(X2_DIR_PIN,STATE)
|
|
|
|
|
#define X2_DIR_WRITE(STATE) WRITE(X2_DIR_PIN,INVERT_DIR(X2, STATE))
|
|
|
|
|
#define X2_DIR_READ() bool(READ(X2_DIR_PIN))
|
|
|
|
|
#endif
|
|
|
|
|
#define X2_STEP_INIT() SET_OUTPUT(X2_STEP_PIN)
|
|
|
|
@ -126,7 +165,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef Y2_DIR_INIT
|
|
|
|
|
#define Y2_DIR_INIT() SET_OUTPUT(Y2_DIR_PIN)
|
|
|
|
|
#define Y2_DIR_WRITE(STATE) WRITE(Y2_DIR_PIN,STATE)
|
|
|
|
|
#define Y2_DIR_WRITE(STATE) WRITE(Y2_DIR_PIN,INVERT_DIR(Y2, STATE))
|
|
|
|
|
#define Y2_DIR_READ() bool(READ(Y2_DIR_PIN))
|
|
|
|
|
#endif
|
|
|
|
|
#define Y2_STEP_INIT() SET_OUTPUT(Y2_STEP_PIN)
|
|
|
|
@ -147,7 +186,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef Z2_DIR_INIT
|
|
|
|
|
#define Z2_DIR_INIT() SET_OUTPUT(Z2_DIR_PIN)
|
|
|
|
|
#define Z2_DIR_WRITE(STATE) WRITE(Z2_DIR_PIN,STATE)
|
|
|
|
|
#define Z2_DIR_WRITE(STATE) WRITE(Z2_DIR_PIN,INVERT_DIR(Z2, STATE))
|
|
|
|
|
#define Z2_DIR_READ() bool(READ(Z2_DIR_PIN))
|
|
|
|
|
#endif
|
|
|
|
|
#define Z2_STEP_INIT() SET_OUTPUT(Z2_STEP_PIN)
|
|
|
|
@ -168,7 +207,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef Z3_DIR_INIT
|
|
|
|
|
#define Z3_DIR_INIT() SET_OUTPUT(Z3_DIR_PIN)
|
|
|
|
|
#define Z3_DIR_WRITE(STATE) WRITE(Z3_DIR_PIN,STATE)
|
|
|
|
|
#define Z3_DIR_WRITE(STATE) WRITE(Z3_DIR_PIN,INVERT_DIR(Z3, STATE))
|
|
|
|
|
#define Z3_DIR_READ() bool(READ(Z3_DIR_PIN))
|
|
|
|
|
#endif
|
|
|
|
|
#define Z3_STEP_INIT() SET_OUTPUT(Z3_STEP_PIN)
|
|
|
|
@ -189,7 +228,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef Z4_DIR_INIT
|
|
|
|
|
#define Z4_DIR_INIT() SET_OUTPUT(Z4_DIR_PIN)
|
|
|
|
|
#define Z4_DIR_WRITE(STATE) WRITE(Z4_DIR_PIN,STATE)
|
|
|
|
|
#define Z4_DIR_WRITE(STATE) WRITE(Z4_DIR_PIN,INVERT_DIR(Z4, STATE))
|
|
|
|
|
#define Z4_DIR_READ() bool(READ(Z4_DIR_PIN))
|
|
|
|
|
#endif
|
|
|
|
|
#define Z4_STEP_INIT() SET_OUTPUT(Z4_STEP_PIN)
|
|
|
|
@ -210,7 +249,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef I_DIR_INIT
|
|
|
|
|
#define I_DIR_INIT() SET_OUTPUT(I_DIR_PIN)
|
|
|
|
|
#define I_DIR_WRITE(STATE) WRITE(I_DIR_PIN,STATE)
|
|
|
|
|
#define I_DIR_WRITE(STATE) WRITE(I_DIR_PIN,INVERT_DIR(I, STATE))
|
|
|
|
|
#define I_DIR_READ() bool(READ(I_DIR_PIN))
|
|
|
|
|
#endif
|
|
|
|
|
#define I_STEP_INIT() SET_OUTPUT(I_STEP_PIN)
|
|
|
|
@ -229,7 +268,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef J_DIR_INIT
|
|
|
|
|
#define J_DIR_INIT() SET_OUTPUT(J_DIR_PIN)
|
|
|
|
|
#define J_DIR_WRITE(STATE) WRITE(J_DIR_PIN,STATE)
|
|
|
|
|
#define J_DIR_WRITE(STATE) WRITE(J_DIR_PIN,INVERT_DIR(J, STATE))
|
|
|
|
|
#define J_DIR_READ() bool(READ(J_DIR_PIN))
|
|
|
|
|
#endif
|
|
|
|
|
#define J_STEP_INIT() SET_OUTPUT(J_STEP_PIN)
|
|
|
|
@ -248,7 +287,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef K_DIR_INIT
|
|
|
|
|
#define K_DIR_INIT() SET_OUTPUT(K_DIR_PIN)
|
|
|
|
|
#define K_DIR_WRITE(STATE) WRITE(K_DIR_PIN,STATE)
|
|
|
|
|
#define K_DIR_WRITE(STATE) WRITE(K_DIR_PIN,INVERT_DIR(K, STATE))
|
|
|
|
|
#define K_DIR_READ() bool(READ(K_DIR_PIN))
|
|
|
|
|
#endif
|
|
|
|
|
#define K_STEP_INIT() SET_OUTPUT(K_STEP_PIN)
|
|
|
|
@ -267,7 +306,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef U_DIR_INIT
|
|
|
|
|
#define U_DIR_INIT() SET_OUTPUT(U_DIR_PIN)
|
|
|
|
|
#define U_DIR_WRITE(STATE) WRITE(U_DIR_PIN,STATE)
|
|
|
|
|
#define U_DIR_WRITE(STATE) WRITE(U_DIR_PIN,INVERT_DIR(U, STATE))
|
|
|
|
|
#define U_DIR_READ() bool(READ(U_DIR_PIN))
|
|
|
|
|
#endif
|
|
|
|
|
#define U_STEP_INIT() SET_OUTPUT(U_STEP_PIN)
|
|
|
|
@ -286,7 +325,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef V_DIR_INIT
|
|
|
|
|
#define V_DIR_INIT() SET_OUTPUT(V_DIR_PIN)
|
|
|
|
|
#define V_DIR_WRITE(STATE) WRITE(V_DIR_PIN,STATE)
|
|
|
|
|
#define V_DIR_WRITE(STATE) WRITE(V_DIR_PIN,INVERT_DIR(V, STATE))
|
|
|
|
|
#define V_DIR_READ() bool(READ(V_DIR_PIN))
|
|
|
|
|
#endif
|
|
|
|
|
#define V_STEP_INIT() SET_OUTPUT(V_STEP_PIN)
|
|
|
|
@ -305,7 +344,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef W_DIR_INIT
|
|
|
|
|
#define W_DIR_INIT() SET_OUTPUT(W_DIR_PIN)
|
|
|
|
|
#define W_DIR_WRITE(STATE) WRITE(W_DIR_PIN,STATE)
|
|
|
|
|
#define W_DIR_WRITE(STATE) WRITE(W_DIR_PIN,INVERT_DIR(W, STATE))
|
|
|
|
|
#define W_DIR_READ() bool(READ(W_DIR_PIN))
|
|
|
|
|
#endif
|
|
|
|
|
#define W_STEP_INIT() SET_OUTPUT(W_STEP_PIN)
|
|
|
|
@ -323,7 +362,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef E0_DIR_INIT
|
|
|
|
|
#define E0_DIR_INIT() SET_OUTPUT(E0_DIR_PIN)
|
|
|
|
|
#define E0_DIR_WRITE(STATE) WRITE(E0_DIR_PIN,STATE)
|
|
|
|
|
#define E0_DIR_WRITE(STATE) WRITE(E0_DIR_PIN,INVERT_DIR(E0, STATE))
|
|
|
|
|
#define E0_DIR_READ() bool(READ(E0_DIR_PIN))
|
|
|
|
|
#endif
|
|
|
|
|
#define E0_STEP_INIT() SET_OUTPUT(E0_STEP_PIN)
|
|
|
|
@ -340,7 +379,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef E1_DIR_INIT
|
|
|
|
|
#define E1_DIR_INIT() SET_OUTPUT(E1_DIR_PIN)
|
|
|
|
|
#define E1_DIR_WRITE(STATE) WRITE(E1_DIR_PIN,STATE)
|
|
|
|
|
#define E1_DIR_WRITE(STATE) WRITE(E1_DIR_PIN,INVERT_DIR(E1, STATE))
|
|
|
|
|
#define E1_DIR_READ() bool(READ(E1_DIR_PIN))
|
|
|
|
|
#endif
|
|
|
|
|
#define E1_STEP_INIT() SET_OUTPUT(E1_STEP_PIN)
|
|
|
|
@ -357,7 +396,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef E2_DIR_INIT
|
|
|
|
|
#define E2_DIR_INIT() SET_OUTPUT(E2_DIR_PIN)
|
|
|
|
|
#define E2_DIR_WRITE(STATE) WRITE(E2_DIR_PIN,STATE)
|
|
|
|
|
#define E2_DIR_WRITE(STATE) WRITE(E2_DIR_PIN,INVERT_DIR(E2, STATE))
|
|
|
|
|
#define E2_DIR_READ() bool(READ(E2_DIR_PIN))
|
|
|
|
|
#endif
|
|
|
|
|
#define E2_STEP_INIT() SET_OUTPUT(E2_STEP_PIN)
|
|
|
|
@ -374,7 +413,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef E3_DIR_INIT
|
|
|
|
|
#define E3_DIR_INIT() SET_OUTPUT(E3_DIR_PIN)
|
|
|
|
|
#define E3_DIR_WRITE(STATE) WRITE(E3_DIR_PIN,STATE)
|
|
|
|
|
#define E3_DIR_WRITE(STATE) WRITE(E3_DIR_PIN,INVERT_DIR(E3, STATE))
|
|
|
|
|
#define E3_DIR_READ() bool(READ(E3_DIR_PIN))
|
|
|
|
|
#endif
|
|
|
|
|
#define E3_STEP_INIT() SET_OUTPUT(E3_STEP_PIN)
|
|
|
|
@ -391,7 +430,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef E4_DIR_INIT
|
|
|
|
|
#define E4_DIR_INIT() SET_OUTPUT(E4_DIR_PIN)
|
|
|
|
|
#define E4_DIR_WRITE(STATE) WRITE(E4_DIR_PIN,STATE)
|
|
|
|
|
#define E4_DIR_WRITE(STATE) WRITE(E4_DIR_PIN,INVERT_DIR(E4, STATE))
|
|
|
|
|
#define E4_DIR_READ() bool(READ(E4_DIR_PIN))
|
|
|
|
|
#endif
|
|
|
|
|
#define E4_STEP_INIT() SET_OUTPUT(E4_STEP_PIN)
|
|
|
|
@ -408,7 +447,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef E5_DIR_INIT
|
|
|
|
|
#define E5_DIR_INIT() SET_OUTPUT(E5_DIR_PIN)
|
|
|
|
|
#define E5_DIR_WRITE(STATE) WRITE(E5_DIR_PIN,STATE)
|
|
|
|
|
#define E5_DIR_WRITE(STATE) WRITE(E5_DIR_PIN,INVERT_DIR(E5, STATE))
|
|
|
|
|
#define E5_DIR_READ() bool(READ(E5_DIR_PIN))
|
|
|
|
|
#endif
|
|
|
|
|
#define E5_STEP_INIT() SET_OUTPUT(E5_STEP_PIN)
|
|
|
|
@ -425,7 +464,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef E6_DIR_INIT
|
|
|
|
|
#define E6_DIR_INIT() SET_OUTPUT(E6_DIR_PIN)
|
|
|
|
|
#define E6_DIR_WRITE(STATE) WRITE(E6_DIR_PIN,STATE)
|
|
|
|
|
#define E6_DIR_WRITE(STATE) WRITE(E6_DIR_PIN,INVERT_DIR(E6, STATE))
|
|
|
|
|
#define E6_DIR_READ() bool(READ(E6_DIR_PIN))
|
|
|
|
|
#endif
|
|
|
|
|
#define E6_STEP_INIT() SET_OUTPUT(E6_STEP_PIN)
|
|
|
|
@ -442,7 +481,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef E7_DIR_INIT
|
|
|
|
|
#define E7_DIR_INIT() SET_OUTPUT(E7_DIR_PIN)
|
|
|
|
|
#define E7_DIR_WRITE(STATE) WRITE(E7_DIR_PIN,STATE)
|
|
|
|
|
#define E7_DIR_WRITE(STATE) WRITE(E7_DIR_PIN,INVERT_DIR(E7, STATE))
|
|
|
|
|
#define E7_DIR_READ() bool(READ(E7_DIR_PIN))
|
|
|
|
|
#endif
|
|
|
|
|
#define E7_STEP_INIT() SET_OUTPUT(E7_STEP_PIN)
|
|
|
|
@ -451,8 +490,6 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
#endif
|
|
|
|
|
#define E7_STEP_READ() bool(READ(E7_STEP_PIN))
|
|
|
|
|
|
|
|
|
|
#define INVERT_DIR(AXIS, D) (TERN_(INVERT_## AXIS ##_DIR, !)(D))
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Extruder indirection for the single E axis
|
|
|
|
|
*/
|
|
|
|
@ -460,91 +497,91 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
#if EXTRUDERS > 7
|
|
|
|
|
#define E_STEP_WRITE(E,V) do{ if (E < 2) { E0_STEP_WRITE(V); } else if (E < 4) { E1_STEP_WRITE(V); } else if (E < 6) { E2_STEP_WRITE(V); } else { E3_STEP_WRITE(V); } }while(0)
|
|
|
|
|
#define FWD_E_DIR(E) do{ switch (E) { \
|
|
|
|
|
case 0: E0_DIR_WRITE(INVERT_DIR(E0, HIGH)); break; case 1: E0_DIR_WRITE(INVERT_DIR(E0, LOW )); break; \
|
|
|
|
|
case 2: E1_DIR_WRITE(INVERT_DIR(E1, HIGH)); break; case 3: E1_DIR_WRITE(INVERT_DIR(E1, LOW )); break; \
|
|
|
|
|
case 4: E2_DIR_WRITE(INVERT_DIR(E2, HIGH)); break; case 5: E2_DIR_WRITE(INVERT_DIR(E2, LOW )); break; \
|
|
|
|
|
case 6: E3_DIR_WRITE(INVERT_DIR(E3, HIGH)); break; case 7: E3_DIR_WRITE(INVERT_DIR(E3, LOW )); break; \
|
|
|
|
|
case 0: E0_DIR_WRITE(HIGH); break; case 1: E0_DIR_WRITE(LOW ); break; \
|
|
|
|
|
case 2: E1_DIR_WRITE(HIGH); break; case 3: E1_DIR_WRITE(LOW ); break; \
|
|
|
|
|
case 4: E2_DIR_WRITE(HIGH); break; case 5: E2_DIR_WRITE(LOW ); break; \
|
|
|
|
|
case 6: E3_DIR_WRITE(HIGH); break; case 7: E3_DIR_WRITE(LOW ); break; \
|
|
|
|
|
} }while(0)
|
|
|
|
|
#define REV_E_DIR(E) do{ switch (E) { \
|
|
|
|
|
case 0: E0_DIR_WRITE(INVERT_DIR(E0, LOW )); break; case 1: E0_DIR_WRITE(INVERT_DIR(E0, HIGH)); break; \
|
|
|
|
|
case 2: E1_DIR_WRITE(INVERT_DIR(E1, LOW )); break; case 3: E1_DIR_WRITE(INVERT_DIR(E1, HIGH)); break; \
|
|
|
|
|
case 4: E2_DIR_WRITE(INVERT_DIR(E2, LOW )); break; case 5: E2_DIR_WRITE(INVERT_DIR(E2, HIGH)); break; \
|
|
|
|
|
case 6: E3_DIR_WRITE(INVERT_DIR(E3, LOW )); break; case 7: E3_DIR_WRITE(INVERT_DIR(E3, HIGH)); break; \
|
|
|
|
|
case 0: E0_DIR_WRITE(LOW ); break; case 1: E0_DIR_WRITE(HIGH); break; \
|
|
|
|
|
case 2: E1_DIR_WRITE(LOW ); break; case 3: E1_DIR_WRITE(HIGH); break; \
|
|
|
|
|
case 4: E2_DIR_WRITE(LOW ); break; case 5: E2_DIR_WRITE(HIGH); break; \
|
|
|
|
|
case 6: E3_DIR_WRITE(LOW ); break; case 7: E3_DIR_WRITE(HIGH); break; \
|
|
|
|
|
} }while(0)
|
|
|
|
|
#elif EXTRUDERS > 6
|
|
|
|
|
#define E_STEP_WRITE(E,V) do{ if (E < 2) { E0_STEP_WRITE(V); } else if (E < 4) { E1_STEP_WRITE(V); } else if (E < 6) { E2_STEP_WRITE(V); } else { E3_STEP_WRITE(V); } }while(0)
|
|
|
|
|
#define FWD_E_DIR(E) do{ switch (E) { \
|
|
|
|
|
case 0: E0_DIR_WRITE(INVERT_DIR(E0, HIGH)); break; case 1: E0_DIR_WRITE(INVERT_DIR(E0, LOW )); break; \
|
|
|
|
|
case 2: E1_DIR_WRITE(INVERT_DIR(E1, HIGH)); break; case 3: E1_DIR_WRITE(INVERT_DIR(E1, LOW )); break; \
|
|
|
|
|
case 4: E2_DIR_WRITE(INVERT_DIR(E2, HIGH)); break; case 5: E2_DIR_WRITE(INVERT_DIR(E2, LOW )); break; \
|
|
|
|
|
case 6: E3_DIR_WRITE(INVERT_DIR(E3, HIGH)); break; \
|
|
|
|
|
case 0: E0_DIR_WRITE(HIGH); break; case 1: E0_DIR_WRITE(LOW ); break; \
|
|
|
|
|
case 2: E1_DIR_WRITE(HIGH); break; case 3: E1_DIR_WRITE(LOW ); break; \
|
|
|
|
|
case 4: E2_DIR_WRITE(HIGH); break; case 5: E2_DIR_WRITE(LOW ); break; \
|
|
|
|
|
case 6: E3_DIR_WRITE(HIGH); break; \
|
|
|
|
|
} }while(0)
|
|
|
|
|
#define REV_E_DIR(E) do{ switch (E) { \
|
|
|
|
|
case 0: E0_DIR_WRITE(INVERT_DIR(E0, LOW )); break; case 1: E0_DIR_WRITE(INVERT_DIR(E0, HIGH)); break; \
|
|
|
|
|
case 2: E1_DIR_WRITE(INVERT_DIR(E1, LOW )); break; case 3: E1_DIR_WRITE(INVERT_DIR(E1, HIGH)); break; \
|
|
|
|
|
case 4: E2_DIR_WRITE(INVERT_DIR(E2, LOW )); break; case 5: E2_DIR_WRITE(INVERT_DIR(E2, HIGH)); break; \
|
|
|
|
|
case 6: E3_DIR_WRITE(INVERT_DIR(E3, LOW )); } }while(0)
|
|
|
|
|
case 0: E0_DIR_WRITE(LOW ); break; case 1: E0_DIR_WRITE(HIGH); break; \
|
|
|
|
|
case 2: E1_DIR_WRITE(LOW ); break; case 3: E1_DIR_WRITE(HIGH); break; \
|
|
|
|
|
case 4: E2_DIR_WRITE(LOW ); break; case 5: E2_DIR_WRITE(HIGH); break; \
|
|
|
|
|
case 6: E3_DIR_WRITE(LOW ); } }while(0)
|
|
|
|
|
#elif EXTRUDERS > 5
|
|
|
|
|
#define E_STEP_WRITE(E,V) do{ if (E < 2) { E0_STEP_WRITE(V); } else if (E < 4) { E1_STEP_WRITE(V); } else { E2_STEP_WRITE(V); } }while(0)
|
|
|
|
|
#define FWD_E_DIR(E) do{ switch (E) { \
|
|
|
|
|
case 0: E0_DIR_WRITE(INVERT_DIR(E0, HIGH)); break; case 1: E0_DIR_WRITE(INVERT_DIR(E0, LOW )); break; \
|
|
|
|
|
case 2: E1_DIR_WRITE(INVERT_DIR(E1, HIGH)); break; case 3: E1_DIR_WRITE(INVERT_DIR(E1, LOW )); break; \
|
|
|
|
|
case 4: E2_DIR_WRITE(INVERT_DIR(E2, HIGH)); break; case 5: E2_DIR_WRITE(INVERT_DIR(E2, LOW )); break; \
|
|
|
|
|
case 0: E0_DIR_WRITE(HIGH); break; case 1: E0_DIR_WRITE(LOW ); break; \
|
|
|
|
|
case 2: E1_DIR_WRITE(HIGH); break; case 3: E1_DIR_WRITE(LOW ); break; \
|
|
|
|
|
case 4: E2_DIR_WRITE(HIGH); break; case 5: E2_DIR_WRITE(LOW ); break; \
|
|
|
|
|
} }while(0)
|
|
|
|
|
#define REV_E_DIR(E) do{ switch (E) { \
|
|
|
|
|
case 0: E0_DIR_WRITE(INVERT_DIR(E0, LOW )); break; case 1: E0_DIR_WRITE(INVERT_DIR(E0, HIGH)); break; \
|
|
|
|
|
case 2: E1_DIR_WRITE(INVERT_DIR(E1, LOW )); break; case 3: E1_DIR_WRITE(INVERT_DIR(E1, HIGH)); break; \
|
|
|
|
|
case 4: E2_DIR_WRITE(INVERT_DIR(E2, LOW )); break; case 5: E2_DIR_WRITE(INVERT_DIR(E2, HIGH)); break; \
|
|
|
|
|
case 0: E0_DIR_WRITE(LOW ); break; case 1: E0_DIR_WRITE(HIGH); break; \
|
|
|
|
|
case 2: E1_DIR_WRITE(LOW ); break; case 3: E1_DIR_WRITE(HIGH); break; \
|
|
|
|
|
case 4: E2_DIR_WRITE(LOW ); break; case 5: E2_DIR_WRITE(HIGH); break; \
|
|
|
|
|
} }while(0)
|
|
|
|
|
#elif EXTRUDERS > 4
|
|
|
|
|
#define E_STEP_WRITE(E,V) do{ if (E < 2) { E0_STEP_WRITE(V); } else if (E < 4) { E1_STEP_WRITE(V); } else { E2_STEP_WRITE(V); } }while(0)
|
|
|
|
|
#define FWD_E_DIR(E) do{ switch (E) { \
|
|
|
|
|
case 0: E0_DIR_WRITE(INVERT_DIR(E0, HIGH)); break; case 1: E0_DIR_WRITE(INVERT_DIR(E0, LOW )); break; \
|
|
|
|
|
case 2: E1_DIR_WRITE(INVERT_DIR(E1, HIGH)); break; case 3: E1_DIR_WRITE(INVERT_DIR(E1, LOW )); break; \
|
|
|
|
|
case 4: E2_DIR_WRITE(INVERT_DIR(E2, HIGH)); break; \
|
|
|
|
|
case 0: E0_DIR_WRITE(HIGH); break; case 1: E0_DIR_WRITE(LOW ); break; \
|
|
|
|
|
case 2: E1_DIR_WRITE(HIGH); break; case 3: E1_DIR_WRITE(LOW ); break; \
|
|
|
|
|
case 4: E2_DIR_WRITE(HIGH); break; \
|
|
|
|
|
} }while(0)
|
|
|
|
|
#define REV_E_DIR(E) do{ switch (E) { \
|
|
|
|
|
case 0: E0_DIR_WRITE(INVERT_DIR(E0, LOW )); break; case 1: E0_DIR_WRITE(INVERT_DIR(E0, HIGH)); break; \
|
|
|
|
|
case 2: E1_DIR_WRITE(INVERT_DIR(E1, LOW )); break; case 3: E1_DIR_WRITE(INVERT_DIR(E1, HIGH)); break; \
|
|
|
|
|
case 4: E2_DIR_WRITE(INVERT_DIR(E2, LOW )); break; \
|
|
|
|
|
case 0: E0_DIR_WRITE(LOW ); break; case 1: E0_DIR_WRITE(HIGH); break; \
|
|
|
|
|
case 2: E1_DIR_WRITE(LOW ); break; case 3: E1_DIR_WRITE(HIGH); break; \
|
|
|
|
|
case 4: E2_DIR_WRITE(LOW ); break; \
|
|
|
|
|
} }while(0)
|
|
|
|
|
#elif EXTRUDERS > 3
|
|
|
|
|
#define E_STEP_WRITE(E,V) do{ if (E < 2) { E0_STEP_WRITE(V); } else { E1_STEP_WRITE(V); } }while(0)
|
|
|
|
|
#define FWD_E_DIR(E) do{ switch (E) { \
|
|
|
|
|
case 0: E0_DIR_WRITE(INVERT_DIR(E0, HIGH)); break; case 1: E0_DIR_WRITE(INVERT_DIR(E0, LOW )); break; \
|
|
|
|
|
case 2: E1_DIR_WRITE(INVERT_DIR(E1, HIGH)); break; case 3: E1_DIR_WRITE(INVERT_DIR(E1, LOW )); break; \
|
|
|
|
|
case 0: E0_DIR_WRITE(HIGH); break; case 1: E0_DIR_WRITE(LOW ); break; \
|
|
|
|
|
case 2: E1_DIR_WRITE(HIGH); break; case 3: E1_DIR_WRITE(LOW ); break; \
|
|
|
|
|
} }while(0)
|
|
|
|
|
#define REV_E_DIR(E) do{ switch (E) { \
|
|
|
|
|
case 0: E0_DIR_WRITE(INVERT_DIR(E0, LOW )); break; case 1: E0_DIR_WRITE(INVERT_DIR(E0, HIGH)); break; \
|
|
|
|
|
case 2: E1_DIR_WRITE(INVERT_DIR(E1, LOW )); break; case 3: E1_DIR_WRITE(INVERT_DIR(E1, HIGH)); break; \
|
|
|
|
|
case 0: E0_DIR_WRITE(LOW ); break; case 1: E0_DIR_WRITE(HIGH); break; \
|
|
|
|
|
case 2: E1_DIR_WRITE(LOW ); break; case 3: E1_DIR_WRITE(HIGH); break; \
|
|
|
|
|
} }while(0)
|
|
|
|
|
#elif EXTRUDERS > 2
|
|
|
|
|
#define E_STEP_WRITE(E,V) do{ if (E < 2) { E0_STEP_WRITE(V); } else { E1_STEP_WRITE(V); } }while(0)
|
|
|
|
|
#define FWD_E_DIR(E) do{ switch (E) { \
|
|
|
|
|
case 0: E0_DIR_WRITE(INVERT_DIR(E0, HIGH)); break; case 1: E0_DIR_WRITE(INVERT_DIR(E0, LOW )); break; \
|
|
|
|
|
case 2: E1_DIR_WRITE(INVERT_DIR(E1, HIGH)); break; \
|
|
|
|
|
case 0: E0_DIR_WRITE(HIGH); break; case 1: E0_DIR_WRITE(LOW ); break; \
|
|
|
|
|
case 2: E1_DIR_WRITE(HIGH); break; \
|
|
|
|
|
} }while(0)
|
|
|
|
|
#define REV_E_DIR(E) do{ switch (E) { \
|
|
|
|
|
case 0: E0_DIR_WRITE(INVERT_DIR(E0, LOW )); break; case 1: E0_DIR_WRITE(INVERT_DIR(E0, HIGH)); break; \
|
|
|
|
|
case 2: E1_DIR_WRITE(INVERT_DIR(E1, LOW )); break; \
|
|
|
|
|
case 0: E0_DIR_WRITE(LOW ); break; case 1: E0_DIR_WRITE(HIGH); break; \
|
|
|
|
|
case 2: E1_DIR_WRITE(LOW ); break; \
|
|
|
|
|
} }while(0)
|
|
|
|
|
#else
|
|
|
|
|
#define E_STEP_WRITE(E,V) E0_STEP_WRITE(V)
|
|
|
|
|
#define FWD_E_DIR(E) do{ E0_DIR_WRITE(INVERT_DIR(E0, (E) ? LOW : HIGH)); }while(0)
|
|
|
|
|
#define REV_E_DIR(E) do{ E0_DIR_WRITE(INVERT_DIR(E0, (E) ? HIGH : LOW )); }while(0)
|
|
|
|
|
#define FWD_E_DIR(E) do{ E0_DIR_WRITE((E) ? LOW : HIGH); }while(0)
|
|
|
|
|
#define REV_E_DIR(E) do{ E0_DIR_WRITE((E) ? HIGH : LOW ); }while(0)
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#elif HAS_PRUSA_MMU2 // One multiplexed stepper driver
|
|
|
|
|
|
|
|
|
|
#define E_STEP_WRITE(E,V) E0_STEP_WRITE(V)
|
|
|
|
|
#define FWD_E_DIR(E) E0_DIR_WRITE(INVERT_DIR(E0, HIGH))
|
|
|
|
|
#define REV_E_DIR(E) E0_DIR_WRITE(INVERT_DIR(E0, LOW ))
|
|
|
|
|
#define FWD_E_DIR(E) E0_DIR_WRITE(HIGH)
|
|
|
|
|
#define REV_E_DIR(E) E0_DIR_WRITE(LOW )
|
|
|
|
|
|
|
|
|
|
#elif HAS_PRUSA_MMU1 // One multiplexed stepper driver, reversed on odd index
|
|
|
|
|
|
|
|
|
|
#define E_STEP_WRITE(E,V) E0_STEP_WRITE(V)
|
|
|
|
|
#define FWD_E_DIR(E) do{ E0_DIR_WRITE(INVERT_DIR(E0, TEST(E, 0) ? HIGH : LOW )); }while(0)
|
|
|
|
|
#define REV_E_DIR(E) do{ E0_DIR_WRITE(INVERT_DIR(E0, TEST(E, 0) ? LOW : HIGH)); }while(0)
|
|
|
|
|
#define FWD_E_DIR(E) do{ E0_DIR_WRITE(TEST(E, 0) ? HIGH : LOW ); }while(0)
|
|
|
|
|
#define REV_E_DIR(E) do{ E0_DIR_WRITE(TEST(E, 0) ? LOW : HIGH); }while(0)
|
|
|
|
|
|
|
|
|
|
#elif E_STEPPERS > 1
|
|
|
|
|
|
|
|
|
@ -555,16 +592,16 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
case 4: E4_STEP_WRITE(V); break; case 5: E5_STEP_WRITE(V); break; case 6: E6_STEP_WRITE(V); break; case 7: E7_STEP_WRITE(V); break; \
|
|
|
|
|
} }while(0)
|
|
|
|
|
#define _FWD_E_DIR(E) do{ switch (E) { \
|
|
|
|
|
case 0: E0_DIR_WRITE(INVERT_DIR(E0, HIGH)); break; case 1: E1_DIR_WRITE(INVERT_DIR(E1, HIGH)); break; \
|
|
|
|
|
case 2: E2_DIR_WRITE(INVERT_DIR(E2, HIGH)); break; case 3: E3_DIR_WRITE(INVERT_DIR(E3, HIGH)); break; \
|
|
|
|
|
case 4: E4_DIR_WRITE(INVERT_DIR(E4, HIGH)); break; case 5: E5_DIR_WRITE(INVERT_DIR(E5, HIGH)); break; \
|
|
|
|
|
case 6: E6_DIR_WRITE(INVERT_DIR(E6, HIGH)); break; case 7: E7_DIR_WRITE(INVERT_DIR(E7, HIGH)); break; \
|
|
|
|
|
case 0: E0_DIR_WRITE(HIGH); break; case 1: E1_DIR_WRITE(HIGH); break; \
|
|
|
|
|
case 2: E2_DIR_WRITE(HIGH); break; case 3: E3_DIR_WRITE(HIGH); break; \
|
|
|
|
|
case 4: E4_DIR_WRITE(HIGH); break; case 5: E5_DIR_WRITE(HIGH); break; \
|
|
|
|
|
case 6: E6_DIR_WRITE(HIGH); break; case 7: E7_DIR_WRITE(HIGH); break; \
|
|
|
|
|
} }while(0)
|
|
|
|
|
#define _REV_E_DIR(E) do{ switch (E) { \
|
|
|
|
|
case 0: E0_DIR_WRITE(INVERT_DIR(E0, LOW )); break; case 1: E1_DIR_WRITE(INVERT_DIR(E1, LOW )); break; \
|
|
|
|
|
case 2: E2_DIR_WRITE(INVERT_DIR(E2, LOW )); break; case 3: E3_DIR_WRITE(INVERT_DIR(E3, LOW )); break; \
|
|
|
|
|
case 4: E4_DIR_WRITE(INVERT_DIR(E4, LOW )); break; case 5: E5_DIR_WRITE(INVERT_DIR(E5, LOW )); break; \
|
|
|
|
|
case 6: E6_DIR_WRITE(INVERT_DIR(E6, LOW )); break; case 7: E7_DIR_WRITE(INVERT_DIR(E7, LOW )); break; \
|
|
|
|
|
case 0: E0_DIR_WRITE(LOW ); break; case 1: E1_DIR_WRITE(LOW ); break; \
|
|
|
|
|
case 2: E2_DIR_WRITE(LOW ); break; case 3: E3_DIR_WRITE(LOW ); break; \
|
|
|
|
|
case 4: E4_DIR_WRITE(LOW ); break; case 5: E5_DIR_WRITE(LOW ); break; \
|
|
|
|
|
case 6: E6_DIR_WRITE(LOW ); break; case 7: E7_DIR_WRITE(LOW ); break; \
|
|
|
|
|
} }while(0)
|
|
|
|
|
|
|
|
|
|
#elif E_STEPPERS > 6
|
|
|
|
@ -574,16 +611,16 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
case 4: E4_STEP_WRITE(V); break; case 5: E5_STEP_WRITE(V); break; case 6: E6_STEP_WRITE(V); break; \
|
|
|
|
|
} }while(0)
|
|
|
|
|
#define _FWD_E_DIR(E) do{ switch (E) { \
|
|
|
|
|
case 0: E0_DIR_WRITE(INVERT_DIR(E0, HIGH)); break; case 1: E1_DIR_WRITE(INVERT_DIR(E1, HIGH)); break; \
|
|
|
|
|
case 2: E2_DIR_WRITE(INVERT_DIR(E2, HIGH)); break; case 3: E3_DIR_WRITE(INVERT_DIR(E3, HIGH)); break; \
|
|
|
|
|
case 4: E4_DIR_WRITE(INVERT_DIR(E4, HIGH)); break; case 5: E5_DIR_WRITE(INVERT_DIR(E5, HIGH)); break; \
|
|
|
|
|
case 6: E6_DIR_WRITE(INVERT_DIR(E6, HIGH)); break; \
|
|
|
|
|
case 0: E0_DIR_WRITE(HIGH); break; case 1: E1_DIR_WRITE(HIGH); break; \
|
|
|
|
|
case 2: E2_DIR_WRITE(HIGH); break; case 3: E3_DIR_WRITE(HIGH); break; \
|
|
|
|
|
case 4: E4_DIR_WRITE(HIGH); break; case 5: E5_DIR_WRITE(HIGH); break; \
|
|
|
|
|
case 6: E6_DIR_WRITE(HIGH); break; \
|
|
|
|
|
} }while(0)
|
|
|
|
|
#define _REV_E_DIR(E) do{ switch (E) { \
|
|
|
|
|
case 0: E0_DIR_WRITE(INVERT_DIR(E0, LOW )); break; case 1: E1_DIR_WRITE(INVERT_DIR(E1, LOW )); break; \
|
|
|
|
|
case 2: E2_DIR_WRITE(INVERT_DIR(E2, LOW )); break; case 3: E3_DIR_WRITE(INVERT_DIR(E3, LOW )); break; \
|
|
|
|
|
case 4: E4_DIR_WRITE(INVERT_DIR(E4, LOW )); break; case 5: E5_DIR_WRITE(INVERT_DIR(E5, LOW )); break; \
|
|
|
|
|
case 6: E6_DIR_WRITE(INVERT_DIR(E6, LOW )); break; \
|
|
|
|
|
case 0: E0_DIR_WRITE(LOW ); break; case 1: E1_DIR_WRITE(LOW ); break; \
|
|
|
|
|
case 2: E2_DIR_WRITE(LOW ); break; case 3: E3_DIR_WRITE(LOW ); break; \
|
|
|
|
|
case 4: E4_DIR_WRITE(LOW ); break; case 5: E5_DIR_WRITE(LOW ); break; \
|
|
|
|
|
case 6: E6_DIR_WRITE(LOW ); break; \
|
|
|
|
|
} }while(0)
|
|
|
|
|
|
|
|
|
|
#elif E_STEPPERS > 5
|
|
|
|
@ -593,14 +630,14 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
case 4: E4_STEP_WRITE(V); break; case 5: E5_STEP_WRITE(V); break; \
|
|
|
|
|
} }while(0)
|
|
|
|
|
#define _FWD_E_DIR(E) do{ switch (E) { \
|
|
|
|
|
case 0: E0_DIR_WRITE(INVERT_DIR(E0, HIGH)); break; case 1: E1_DIR_WRITE(INVERT_DIR(E1, HIGH)); break; \
|
|
|
|
|
case 2: E2_DIR_WRITE(INVERT_DIR(E2, HIGH)); break; case 3: E3_DIR_WRITE(INVERT_DIR(E3, HIGH)); break; \
|
|
|
|
|
case 4: E4_DIR_WRITE(INVERT_DIR(E4, HIGH)); break; case 5: E5_DIR_WRITE(INVERT_DIR(E5, HIGH)); break; \
|
|
|
|
|
case 0: E0_DIR_WRITE(HIGH); break; case 1: E1_DIR_WRITE(HIGH); break; \
|
|
|
|
|
case 2: E2_DIR_WRITE(HIGH); break; case 3: E3_DIR_WRITE(HIGH); break; \
|
|
|
|
|
case 4: E4_DIR_WRITE(HIGH); break; case 5: E5_DIR_WRITE(HIGH); break; \
|
|
|
|
|
} }while(0)
|
|
|
|
|
#define _REV_E_DIR(E) do{ switch (E) { \
|
|
|
|
|
case 0: E0_DIR_WRITE(INVERT_DIR(E0, LOW )); break; case 1: E1_DIR_WRITE(INVERT_DIR(E1, LOW )); break; \
|
|
|
|
|
case 2: E2_DIR_WRITE(INVERT_DIR(E2, LOW )); break; case 3: E3_DIR_WRITE(INVERT_DIR(E3, LOW )); break; \
|
|
|
|
|
case 4: E4_DIR_WRITE(INVERT_DIR(E4, LOW )); break; case 5: E5_DIR_WRITE(INVERT_DIR(E5, LOW )); break; \
|
|
|
|
|
case 0: E0_DIR_WRITE(LOW ); break; case 1: E1_DIR_WRITE(LOW ); break; \
|
|
|
|
|
case 2: E2_DIR_WRITE(LOW ); break; case 3: E3_DIR_WRITE(LOW ); break; \
|
|
|
|
|
case 4: E4_DIR_WRITE(LOW ); break; case 5: E5_DIR_WRITE(LOW ); break; \
|
|
|
|
|
} }while(0)
|
|
|
|
|
|
|
|
|
|
#elif E_STEPPERS > 4
|
|
|
|
@ -610,14 +647,14 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
case 4: E4_STEP_WRITE(V); break; \
|
|
|
|
|
} }while(0)
|
|
|
|
|
#define _FWD_E_DIR(E) do{ switch (E) { \
|
|
|
|
|
case 0: E0_DIR_WRITE(INVERT_DIR(E0, HIGH)); break; case 1: E1_DIR_WRITE(INVERT_DIR(E1, HIGH)); break; \
|
|
|
|
|
case 2: E2_DIR_WRITE(INVERT_DIR(E2, HIGH)); break; case 3: E3_DIR_WRITE(INVERT_DIR(E3, HIGH)); break; \
|
|
|
|
|
case 4: E4_DIR_WRITE(INVERT_DIR(E4, HIGH)); break; \
|
|
|
|
|
case 0: E0_DIR_WRITE(HIGH); break; case 1: E1_DIR_WRITE(HIGH); break; \
|
|
|
|
|
case 2: E2_DIR_WRITE(HIGH); break; case 3: E3_DIR_WRITE(HIGH); break; \
|
|
|
|
|
case 4: E4_DIR_WRITE(HIGH); break; \
|
|
|
|
|
} }while(0)
|
|
|
|
|
#define _REV_E_DIR(E) do{ switch (E) { \
|
|
|
|
|
case 0: E0_DIR_WRITE(INVERT_DIR(E0, LOW )); break; case 1: E1_DIR_WRITE(INVERT_DIR(E1, LOW )); break; \
|
|
|
|
|
case 2: E2_DIR_WRITE(INVERT_DIR(E2, LOW )); break; case 3: E3_DIR_WRITE(INVERT_DIR(E3, LOW )); break; \
|
|
|
|
|
case 4: E4_DIR_WRITE(INVERT_DIR(E4, LOW )); break; \
|
|
|
|
|
case 0: E0_DIR_WRITE(LOW ); break; case 1: E1_DIR_WRITE(LOW ); break; \
|
|
|
|
|
case 2: E2_DIR_WRITE(LOW ); break; case 3: E3_DIR_WRITE(LOW ); break; \
|
|
|
|
|
case 4: E4_DIR_WRITE(LOW ); break; \
|
|
|
|
|
} }while(0)
|
|
|
|
|
|
|
|
|
|
#elif E_STEPPERS > 3
|
|
|
|
@ -626,25 +663,25 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
case 0: E0_STEP_WRITE(V); break; case 1: E1_STEP_WRITE(V); break; case 2: E2_STEP_WRITE(V); break; case 3: E3_STEP_WRITE(V); break; \
|
|
|
|
|
} }while(0)
|
|
|
|
|
#define _FWD_E_DIR(E) do{ switch (E) { \
|
|
|
|
|
case 0: E0_DIR_WRITE(INVERT_DIR(E0, HIGH)); break; case 1: E1_DIR_WRITE(INVERT_DIR(E1, HIGH)); break; \
|
|
|
|
|
case 2: E2_DIR_WRITE(INVERT_DIR(E2, HIGH)); break; case 3: E3_DIR_WRITE(INVERT_DIR(E3, HIGH)); break; \
|
|
|
|
|
case 0: E0_DIR_WRITE(HIGH); break; case 1: E1_DIR_WRITE(HIGH); break; \
|
|
|
|
|
case 2: E2_DIR_WRITE(HIGH); break; case 3: E3_DIR_WRITE(HIGH); break; \
|
|
|
|
|
} }while(0)
|
|
|
|
|
#define _REV_E_DIR(E) do{ switch (E) { \
|
|
|
|
|
case 0: E0_DIR_WRITE(INVERT_DIR(E0, LOW )); break; case 1: E1_DIR_WRITE(INVERT_DIR(E1, LOW )); break; \
|
|
|
|
|
case 2: E2_DIR_WRITE(INVERT_DIR(E2, LOW )); break; case 3: E3_DIR_WRITE(INVERT_DIR(E3, LOW )); break; \
|
|
|
|
|
case 0: E0_DIR_WRITE(LOW ); break; case 1: E1_DIR_WRITE(LOW ); break; \
|
|
|
|
|
case 2: E2_DIR_WRITE(LOW ); break; case 3: E3_DIR_WRITE(LOW ); break; \
|
|
|
|
|
} }while(0)
|
|
|
|
|
|
|
|
|
|
#elif E_STEPPERS > 2
|
|
|
|
|
|
|
|
|
|
#define _E_STEP_WRITE(E,V) do{ switch (E) { case 0: E0_STEP_WRITE(V); break; case 1: E1_STEP_WRITE(V); break; case 2: E2_STEP_WRITE(V); } }while(0)
|
|
|
|
|
#define _FWD_E_DIR(E) do{ switch (E) { case 0: E0_DIR_WRITE(INVERT_DIR(E0, HIGH)); break; case 1: E1_DIR_WRITE(INVERT_DIR(E1, HIGH)); break; case 2: E2_DIR_WRITE(INVERT_DIR(E2, HIGH)); } }while(0)
|
|
|
|
|
#define _REV_E_DIR(E) do{ switch (E) { case 0: E0_DIR_WRITE(INVERT_DIR(E0, LOW )); break; case 1: E1_DIR_WRITE(INVERT_DIR(E1, LOW )); break; case 2: E2_DIR_WRITE(INVERT_DIR(E2, LOW )); } }while(0)
|
|
|
|
|
#define _FWD_E_DIR(E) do{ switch (E) { case 0: E0_DIR_WRITE(HIGH); break; case 1: E1_DIR_WRITE(HIGH); break; case 2: E2_DIR_WRITE(HIGH); } }while(0)
|
|
|
|
|
#define _REV_E_DIR(E) do{ switch (E) { case 0: E0_DIR_WRITE(LOW ); break; case 1: E1_DIR_WRITE(LOW ); break; case 2: E2_DIR_WRITE(LOW ); } }while(0)
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
#define _E_STEP_WRITE(E,V) do{ if (E == 0) { E0_STEP_WRITE(V); } else { E1_STEP_WRITE(V); } }while(0)
|
|
|
|
|
#define _FWD_E_DIR(E) do{ if (E == 0) { E0_DIR_WRITE(INVERT_DIR(E0, HIGH)); } else { E1_DIR_WRITE(INVERT_DIR(E1, HIGH)); } }while(0)
|
|
|
|
|
#define _REV_E_DIR(E) do{ if (E == 0) { E0_DIR_WRITE(INVERT_DIR(E0, LOW )); } else { E1_DIR_WRITE(INVERT_DIR(E1, LOW )); } }while(0)
|
|
|
|
|
#define _FWD_E_DIR(E) do{ if (E == 0) { E0_DIR_WRITE(HIGH); } else { E1_DIR_WRITE(HIGH); } }while(0)
|
|
|
|
|
#define _REV_E_DIR(E) do{ if (E == 0) { E0_DIR_WRITE(LOW ); } else { E1_DIR_WRITE(LOW ); } }while(0)
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if HAS_DUPLICATION_MODE
|
|
|
|
@ -655,8 +692,8 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
#define DUPE(N,T,V) E##N##_##T##_WRITE(V);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define NDIR(N) DUPE(N,DIR,INVERT_DIR(E, HIGH));
|
|
|
|
|
#define RDIR(N) DUPE(N,DIR,INVERT_DIR(E, LOW ));
|
|
|
|
|
#define NDIR(N) DUPE(N,DIR,HIGH);
|
|
|
|
|
#define RDIR(N) DUPE(N,DIR,LOW );
|
|
|
|
|
|
|
|
|
|
#define E_STEP_WRITE(E,V) do{ if (extruder_duplication_enabled) { REPEAT2(E_STEPPERS, DUPE, STEP, V); } else _E_STEP_WRITE(E,V); }while(0)
|
|
|
|
|
#define FWD_E_DIR(E) do{ if (extruder_duplication_enabled) { REPEAT(E_STEPPERS, NDIR); } else _FWD_E_DIR(E); }while(0)
|
|
|
|
@ -672,13 +709,13 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
|
|
|
|
|
|
|
|
|
#elif ENABLED(E_DUAL_STEPPER_DRIVERS)
|
|
|
|
|
#define E_STEP_WRITE(E,V) do{ E0_STEP_WRITE(V); E1_STEP_WRITE(V); }while(0)
|
|
|
|
|
#define FWD_E_DIR(E) do{ constexpr bool d = INVERT_DIR(E0, HIGH); E0_DIR_WRITE(d); E1_DIR_WRITE(INVERT_DIR(E1_VS_E0, d)); }while(0)
|
|
|
|
|
#define REV_E_DIR(E) do{ constexpr bool d = INVERT_DIR(E0, LOW ); E0_DIR_WRITE(d); E1_DIR_WRITE(INVERT_DIR(E1_VS_E0, d)); }while(0)
|
|
|
|
|
#define FWD_E_DIR(E) do{ E0_DIR_WRITE(HIGH); E1_DIR_WRITE(INVERT_DIR(E1_VS_E0, HIGH)); }while(0)
|
|
|
|
|
#define REV_E_DIR(E) do{ E0_DIR_WRITE(LOW ); E1_DIR_WRITE(INVERT_DIR(E1_VS_E0, LOW )); }while(0)
|
|
|
|
|
|
|
|
|
|
#elif E_STEPPERS
|
|
|
|
|
#elif E_STEPPERS == 1
|
|
|
|
|
#define E_STEP_WRITE(E,V) E0_STEP_WRITE(V)
|
|
|
|
|
#define FWD_E_DIR(E) E0_DIR_WRITE(INVERT_DIR(E0, HIGH))
|
|
|
|
|
#define REV_E_DIR(E) E0_DIR_WRITE(INVERT_DIR(E0, LOW ))
|
|
|
|
|
#define FWD_E_DIR(E) E0_DIR_WRITE(HIGH)
|
|
|
|
|
#define REV_E_DIR(E) E0_DIR_WRITE(LOW )
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
#define E_STEP_WRITE(E,V) NOOP
|
|
|
|
|