🧑‍💻 Move ENABLE to indirection.h

Followup to add72fd045
This commit is contained in:
Scott Lahteine 2025-03-30 14:56:55 -05:00
parent fd17cc962b
commit 73ed54308a
3 changed files with 107 additions and 137 deletions

View file

@ -1065,17 +1065,19 @@
#define HAS_X_MS_PINS 1
#endif
#if PIN_EXISTS(X2_ENABLE) || ALL(SOFTWARE_DRIVER_ENABLE, X2_IS_TRINAMIC)
#define HAS_X2_ENABLE 1
#endif
#if PIN_EXISTS(X2_DIR)
#define HAS_X2_DIR 1
#endif
#if PIN_EXISTS(X2_STEP)
#define HAS_X2_STEP 1
#endif
#if PIN_EXISTS(X2_MS1)
#define HAS_X2_MS_PINS 1
#if HAS_X2_STEPPER
#if PIN_EXISTS(X2_ENABLE) || ALL(SOFTWARE_DRIVER_ENABLE, X2_IS_TRINAMIC)
#define HAS_X2_ENABLE 1
#endif
#if PIN_EXISTS(X2_DIR)
#define HAS_X2_DIR 1
#endif
#if PIN_EXISTS(X2_STEP)
#define HAS_X2_STEP 1
#endif
#if PIN_EXISTS(X2_MS1)
#define HAS_X2_MS_PINS 1
#endif
#endif
#endif

View file

@ -2972,131 +2972,30 @@ void Stepper::init() {
TERN_(HAS_E6_DIR, E6_DIR_INIT());
TERN_(HAS_E7_DIR, E7_DIR_INIT());
// Init Enable Pins - steppers default to disabled.
#if HAS_X_ENABLE
#ifndef X_ENABLE_INIT_STATE
#define X_ENABLE_INIT_STATE !X_ENABLE_ON
#endif
X_ENABLE_INIT();
if (X_ENABLE_INIT_STATE) X_ENABLE_WRITE(X_ENABLE_INIT_STATE);
#if ALL(HAS_X2_STEPPER, HAS_X2_ENABLE)
X2_ENABLE_INIT();
if (X_ENABLE_INIT_STATE) X2_ENABLE_WRITE(X_ENABLE_INIT_STATE);
#endif
#endif
#if HAS_Y_ENABLE
#ifndef Y_ENABLE_INIT_STATE
#define Y_ENABLE_INIT_STATE !Y_ENABLE_ON
#endif
Y_ENABLE_INIT();
if (Y_ENABLE_INIT_STATE) Y_ENABLE_WRITE(Y_ENABLE_INIT_STATE);
#if ALL(HAS_Y2_STEPPER, HAS_Y2_ENABLE)
Y2_ENABLE_INIT();
if (Y_ENABLE_INIT_STATE) Y2_ENABLE_WRITE(Y_ENABLE_INIT_STATE);
#endif
#endif
#if HAS_Z_ENABLE
#ifndef Z_ENABLE_INIT_STATE
#define Z_ENABLE_INIT_STATE !Z_ENABLE_ON
#endif
Z_ENABLE_INIT();
if (Z_ENABLE_INIT_STATE) Z_ENABLE_WRITE(Z_ENABLE_INIT_STATE);
#if HAS_Z2_ENABLE
Z2_ENABLE_INIT();
if (Z_ENABLE_INIT_STATE) Z2_ENABLE_WRITE(Z_ENABLE_INIT_STATE);
#endif
#if HAS_Z3_ENABLE
Z3_ENABLE_INIT();
if (Z_ENABLE_INIT_STATE) Z3_ENABLE_WRITE(Z_ENABLE_INIT_STATE);
#endif
#if HAS_Z4_ENABLE
Z4_ENABLE_INIT();
if (Z_ENABLE_INIT_STATE) Z4_ENABLE_WRITE(Z_ENABLE_INIT_STATE);
#endif
#endif
#if HAS_I_ENABLE
I_ENABLE_INIT();
if (!I_ENABLE_ON) I_ENABLE_WRITE(HIGH);
#endif
#if HAS_J_ENABLE
J_ENABLE_INIT();
if (!J_ENABLE_ON) J_ENABLE_WRITE(HIGH);
#endif
#if HAS_K_ENABLE
K_ENABLE_INIT();
if (!K_ENABLE_ON) K_ENABLE_WRITE(HIGH);
#endif
#if HAS_U_ENABLE
U_ENABLE_INIT();
if (!U_ENABLE_ON) U_ENABLE_WRITE(HIGH);
#endif
#if HAS_V_ENABLE
V_ENABLE_INIT();
if (!V_ENABLE_ON) V_ENABLE_WRITE(HIGH);
#endif
#if HAS_W_ENABLE
W_ENABLE_INIT();
if (!W_ENABLE_ON) W_ENABLE_WRITE(HIGH);
#endif
#if HAS_E0_ENABLE
#ifndef E_ENABLE_INIT_STATE
#define E_ENABLE_INIT_STATE !E_ENABLE_ON
#endif
#ifndef E0_ENABLE_INIT_STATE
#define E0_ENABLE_INIT_STATE E_ENABLE_INIT_STATE
#endif
E0_ENABLE_INIT();
if (E0_ENABLE_INIT_STATE) E0_ENABLE_WRITE(E0_ENABLE_INIT_STATE);
#endif
#if HAS_E1_ENABLE
#ifndef E1_ENABLE_INIT_STATE
#define E1_ENABLE_INIT_STATE E_ENABLE_INIT_STATE
#endif
E1_ENABLE_INIT();
if (E1_ENABLE_INIT_STATE) E1_ENABLE_WRITE(E1_ENABLE_INIT_STATE);
#endif
#if HAS_E2_ENABLE
#ifndef E2_ENABLE_INIT_STATE
#define E2_ENABLE_INIT_STATE E_ENABLE_INIT_STATE
#endif
E2_ENABLE_INIT();
if (E2_ENABLE_INIT_STATE) E2_ENABLE_WRITE(E2_ENABLE_INIT_STATE);
#endif
#if HAS_E3_ENABLE
#ifndef E3_ENABLE_INIT_STATE
#define E3_ENABLE_INIT_STATE E_ENABLE_INIT_STATE
#endif
E3_ENABLE_INIT();
if (E3_ENABLE_INIT_STATE) E3_ENABLE_WRITE(E3_ENABLE_INIT_STATE);
#endif
#if HAS_E4_ENABLE
#ifndef E4_ENABLE_INIT_STATE
#define E4_ENABLE_INIT_STATE E_ENABLE_INIT_STATE
#endif
E4_ENABLE_INIT();
if (E4_ENABLE_INIT_STATE) E4_ENABLE_WRITE(E4_ENABLE_INIT_STATE);
#endif
#if HAS_E5_ENABLE
#ifndef E5_ENABLE_INIT_STATE
#define E5_ENABLE_INIT_STATE E_ENABLE_INIT_STATE
#endif
E5_ENABLE_INIT();
if (E5_ENABLE_INIT_STATE) E5_ENABLE_WRITE(E5_ENABLE_INIT_STATE);
#endif
#if HAS_E6_ENABLE
#ifndef E6_ENABLE_INIT_STATE
#define E6_ENABLE_INIT_STATE E_ENABLE_INIT_STATE
#endif
E6_ENABLE_INIT();
if (E6_ENABLE_INIT_STATE) E6_ENABLE_WRITE(E6_ENABLE_INIT_STATE);
#endif
#if HAS_E7_ENABLE
#ifndef E7_ENABLE_INIT_STATE
#define E7_ENABLE_INIT_STATE E_ENABLE_INIT_STATE
#endif
E7_ENABLE_INIT();
if (E7_ENABLE_INIT_STATE) E7_ENABLE_WRITE(E7_ENABLE_INIT_STATE);
#endif
// Init Enable Pins - Steppers default to disabled.
#define _INIT_CONFIG_ENABLE(A) do{ A##_ENABLE_INIT(); if (A##_ENABLE_INIT_STATE) A##_ENABLE_WRITE(HIGH); }while(0)
TERN_(HAS_X_ENABLE, _INIT_CONFIG_ENABLE(X));
TERN_(HAS_X2_ENABLE, _INIT_CONFIG_ENABLE(X2));
TERN_(HAS_Y_ENABLE, _INIT_CONFIG_ENABLE(Y));
TERN_(HAS_Y2_ENABLE, _INIT_CONFIG_ENABLE(Y2));
TERN_(HAS_Z_ENABLE, _INIT_CONFIG_ENABLE(Z));
TERN_(HAS_Z2_ENABLE, _INIT_CONFIG_ENABLE(Z2));
TERN_(HAS_Z3_ENABLE, _INIT_CONFIG_ENABLE(Z3));
TERN_(HAS_Z4_ENABLE, _INIT_CONFIG_ENABLE(Z4));
TERN_(HAS_I_ENABLE, _INIT_CONFIG_ENABLE(I));
TERN_(HAS_J_ENABLE, _INIT_CONFIG_ENABLE(J));
TERN_(HAS_K_ENABLE, _INIT_CONFIG_ENABLE(K));
TERN_(HAS_U_ENABLE, _INIT_CONFIG_ENABLE(U));
TERN_(HAS_V_ENABLE, _INIT_CONFIG_ENABLE(V));
TERN_(HAS_W_ENABLE, _INIT_CONFIG_ENABLE(W));
TERN_(HAS_E0_ENABLE, _INIT_CONFIG_ENABLE(E0));
TERN_(HAS_E1_ENABLE, _INIT_CONFIG_ENABLE(E1));
TERN_(HAS_E2_ENABLE, _INIT_CONFIG_ENABLE(E2));
TERN_(HAS_E3_ENABLE, _INIT_CONFIG_ENABLE(E3));
TERN_(HAS_E4_ENABLE, _INIT_CONFIG_ENABLE(E4));
TERN_(HAS_E5_ENABLE, _INIT_CONFIG_ENABLE(E5));
TERN_(HAS_E6_ENABLE, _INIT_CONFIG_ENABLE(E6));
TERN_(HAS_E7_ENABLE, _INIT_CONFIG_ENABLE(E7));
#define _STEP_INIT(AXIS) AXIS ##_STEP_INIT()
#define _WRITE_STEP(AXIS, HIGHLOW) AXIS ##_STEP_WRITE(HIGHLOW)

View file

@ -80,6 +80,9 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
// X Stepper
#if HAS_X_AXIS
#ifndef X_ENABLE_INIT_STATE
#define X_ENABLE_INIT_STATE !X_ENABLE_ON
#endif
#ifndef X_ENABLE_INIT
#define X_ENABLE_INIT() SET_OUTPUT(X_ENABLE_PIN)
#define X_ENABLE_WRITE(STATE) WRITE(X_ENABLE_PIN,STATE)
@ -99,6 +102,9 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
// Y Stepper
#if HAS_Y_AXIS
#ifndef Y_ENABLE_INIT_STATE
#define Y_ENABLE_INIT_STATE !Y_ENABLE_ON
#endif
#ifndef Y_ENABLE_INIT
#define Y_ENABLE_INIT() SET_OUTPUT(Y_ENABLE_PIN)
#define Y_ENABLE_WRITE(STATE) WRITE(Y_ENABLE_PIN,STATE)
@ -118,6 +124,9 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
// Z Stepper
#if HAS_Z_AXIS
#ifndef Z_ENABLE_INIT_STATE
#define Z_ENABLE_INIT_STATE !Z_ENABLE_ON
#endif
#ifndef Z_ENABLE_INIT
#define Z_ENABLE_INIT() SET_OUTPUT(Z_ENABLE_PIN)
#define Z_ENABLE_WRITE(STATE) WRITE(Z_ENABLE_PIN,STATE)
@ -137,6 +146,9 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
// X2 Stepper
#if HAS_X2_ENABLE
#ifndef X2_ENABLE_INIT_STATE
#define X2_ENABLE_INIT_STATE X_ENABLE_INIT_STATE
#endif
#ifndef X2_ENABLE_INIT
#define X2_ENABLE_INIT() SET_OUTPUT(X2_ENABLE_PIN)
#define X2_ENABLE_WRITE(STATE) WRITE(X2_ENABLE_PIN,STATE)
@ -156,6 +168,9 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
// Y2 Stepper
#if HAS_Y2_ENABLE
#ifndef Y2_ENABLE_INIT_STATE
#define Y2_ENABLE_INIT_STATE Y_ENABLE_INIT_STATE
#endif
#ifndef Y2_ENABLE_INIT
#define Y2_ENABLE_INIT() SET_OUTPUT(Y2_ENABLE_PIN)
#define Y2_ENABLE_WRITE(STATE) WRITE(Y2_ENABLE_PIN,STATE)
@ -177,6 +192,9 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
// Z2 Stepper
#if HAS_Z2_ENABLE
#ifndef Z2_ENABLE_INIT_STATE
#define Z2_ENABLE_INIT_STATE Z_ENABLE_INIT_STATE
#endif
#ifndef Z2_ENABLE_INIT
#define Z2_ENABLE_INIT() SET_OUTPUT(Z2_ENABLE_PIN)
#define Z2_ENABLE_WRITE(STATE) WRITE(Z2_ENABLE_PIN,STATE)
@ -198,6 +216,9 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
// Z3 Stepper
#if HAS_Z3_ENABLE
#ifndef Z3_ENABLE_INIT_STATE
#define Z3_ENABLE_INIT_STATE Z_ENABLE_INIT_STATE
#endif
#ifndef Z3_ENABLE_INIT
#define Z3_ENABLE_INIT() SET_OUTPUT(Z3_ENABLE_PIN)
#define Z3_ENABLE_WRITE(STATE) WRITE(Z3_ENABLE_PIN,STATE)
@ -219,6 +240,9 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
// Z4 Stepper
#if HAS_Z4_ENABLE
#ifndef Z4_ENABLE_INIT_STATE
#define Z4_ENABLE_INIT_STATE Z_ENABLE_INIT_STATE
#endif
#ifndef Z4_ENABLE_INIT
#define Z4_ENABLE_INIT() SET_OUTPUT(Z4_ENABLE_PIN)
#define Z4_ENABLE_WRITE(STATE) WRITE(Z4_ENABLE_PIN,STATE)
@ -240,6 +264,9 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
// I Stepper
#if HAS_I_AXIS
#ifndef I_ENABLE_INIT_STATE
#define I_ENABLE_INIT_STATE !I_ENABLE_ON
#endif
#ifndef I_ENABLE_INIT
#define I_ENABLE_INIT() SET_OUTPUT(I_ENABLE_PIN)
#define I_ENABLE_WRITE(STATE) WRITE(I_ENABLE_PIN,STATE)
@ -259,6 +286,9 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
// J Stepper
#if HAS_J_AXIS
#ifndef J_ENABLE_INIT_STATE
#define J_ENABLE_INIT_STATE !J_ENABLE_ON
#endif
#ifndef J_ENABLE_INIT
#define J_ENABLE_INIT() SET_OUTPUT(J_ENABLE_PIN)
#define J_ENABLE_WRITE(STATE) WRITE(J_ENABLE_PIN,STATE)
@ -278,6 +308,9 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
// K Stepper
#if HAS_K_AXIS
#ifndef K_ENABLE_INIT_STATE
#define K_ENABLE_INIT_STATE !K_ENABLE_ON
#endif
#ifndef K_ENABLE_INIT
#define K_ENABLE_INIT() SET_OUTPUT(K_ENABLE_PIN)
#define K_ENABLE_WRITE(STATE) WRITE(K_ENABLE_PIN,STATE)
@ -297,6 +330,9 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
// U Stepper
#if HAS_U_AXIS
#ifndef U_ENABLE_INIT_STATE
#define U_ENABLE_INIT_STATE !U_ENABLE_ON
#endif
#ifndef U_ENABLE_INIT
#define U_ENABLE_INIT() SET_OUTPUT(U_ENABLE_PIN)
#define U_ENABLE_WRITE(STATE) WRITE(U_ENABLE_PIN,STATE)
@ -316,6 +352,9 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
// V Stepper
#if HAS_V_AXIS
#ifndef V_ENABLE_INIT_STATE
#define V_ENABLE_INIT_STATE !V_ENABLE_ON
#endif
#ifndef V_ENABLE_INIT
#define V_ENABLE_INIT() SET_OUTPUT(V_ENABLE_PIN)
#define V_ENABLE_WRITE(STATE) WRITE(V_ENABLE_PIN,STATE)
@ -335,6 +374,9 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
// W Stepper
#if HAS_W_AXIS
#ifndef W_ENABLE_INIT_STATE
#define W_ENABLE_INIT_STATE !W_ENABLE_ON
#endif
#ifndef W_ENABLE_INIT
#define W_ENABLE_INIT() SET_OUTPUT(W_ENABLE_PIN)
#define W_ENABLE_WRITE(STATE) WRITE(W_ENABLE_PIN,STATE)
@ -353,7 +395,13 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
#endif
// E0 Stepper
#if E_STEPPERS > 0
#if HAS_EXTRUDERS
#ifndef E_ENABLE_INIT_STATE
#define E_ENABLE_INIT_STATE !E_ENABLE_ON
#endif
#ifndef E0_ENABLE_INIT_STATE
#define E0_ENABLE_INIT_STATE E_ENABLE_INIT_STATE
#endif
#ifndef E0_ENABLE_INIT
#define E0_ENABLE_INIT() SET_OUTPUT(E0_ENABLE_PIN)
#define E0_ENABLE_WRITE(STATE) WRITE(E0_ENABLE_PIN,STATE)
@ -373,6 +421,9 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
// E1 Stepper
#if E_STEPPERS > 1 || ENABLED(E_DUAL_STEPPER_DRIVERS)
#ifndef E1_ENABLE_INIT_STATE
#define E1_ENABLE_INIT_STATE E_ENABLE_INIT_STATE
#endif
#ifndef E1_ENABLE_INIT
#define E1_ENABLE_INIT() SET_OUTPUT(E1_ENABLE_PIN)
#define E1_ENABLE_WRITE(STATE) WRITE(E1_ENABLE_PIN,STATE)
@ -392,6 +443,9 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
// E2 Stepper
#if E_STEPPERS > 2
#ifndef E2_ENABLE_INIT_STATE
#define E2_ENABLE_INIT_STATE E_ENABLE_INIT_STATE
#endif
#ifndef E2_ENABLE_INIT
#define E2_ENABLE_INIT() SET_OUTPUT(E2_ENABLE_PIN)
#define E2_ENABLE_WRITE(STATE) WRITE(E2_ENABLE_PIN,STATE)
@ -411,6 +465,9 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
// E3 Stepper
#if E_STEPPERS > 3
#ifndef E3_ENABLE_INIT_STATE
#define E3_ENABLE_INIT_STATE E_ENABLE_INIT_STATE
#endif
#ifndef E3_ENABLE_INIT
#define E3_ENABLE_INIT() SET_OUTPUT(E3_ENABLE_PIN)
#define E3_ENABLE_WRITE(STATE) WRITE(E3_ENABLE_PIN,STATE)
@ -430,6 +487,9 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
// E4 Stepper
#if E_STEPPERS > 4
#ifndef E4_ENABLE_INIT_STATE
#define E4_ENABLE_INIT_STATE E_ENABLE_INIT_STATE
#endif
#ifndef E4_ENABLE_INIT
#define E4_ENABLE_INIT() SET_OUTPUT(E4_ENABLE_PIN)
#define E4_ENABLE_WRITE(STATE) WRITE(E4_ENABLE_PIN,STATE)
@ -449,6 +509,9 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
// E5 Stepper
#if E_STEPPERS > 5
#ifndef E5_ENABLE_INIT_STATE
#define E5_ENABLE_INIT_STATE E_ENABLE_INIT_STATE
#endif
#ifndef E5_ENABLE_INIT
#define E5_ENABLE_INIT() SET_OUTPUT(E5_ENABLE_PIN)
#define E5_ENABLE_WRITE(STATE) WRITE(E5_ENABLE_PIN,STATE)
@ -468,6 +531,9 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
// E6 Stepper
#if E_STEPPERS > 6
#ifndef E6_ENABLE_INIT_STATE
#define E6_ENABLE_INIT_STATE E_ENABLE_INIT_STATE
#endif
#ifndef E6_ENABLE_INIT
#define E6_ENABLE_INIT() SET_OUTPUT(E6_ENABLE_PIN)
#define E6_ENABLE_WRITE(STATE) WRITE(E6_ENABLE_PIN,STATE)
@ -487,6 +553,9 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
// E7 Stepper
#if E_STEPPERS > 7
#ifndef E7_ENABLE_INIT_STATE
#define E7_ENABLE_INIT_STATE E_ENABLE_INIT_STATE
#endif
#ifndef E7_ENABLE_INIT
#define E7_ENABLE_INIT() SET_OUTPUT(E7_ENABLE_PIN)
#define E7_ENABLE_WRITE(STATE) WRITE(E7_ENABLE_PIN,STATE)