Skip to content

Commit

Permalink
Move TMC standby init to a custom method
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Sep 25, 2020
1 parent 207448b commit 6771dc1
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 65 deletions.
69 changes: 52 additions & 17 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,57 @@ void stop() {
}
}

inline void tmc_standby_setup() {
#if PIN_EXISTS(X_STDBY)
SET_INPUT_PULLDOWN(X_STDBY_PIN);
#endif
#if PIN_EXISTS(X2_STDBY)
SET_INPUT_PULLDOWN(X2_STDBY_PIN);
#endif
#if PIN_EXISTS(Y_STDBY)
SET_INPUT_PULLDOWN(Y_STDBY_PIN);
#endif
#if PIN_EXISTS(Y2_STDBY)
SET_INPUT_PULLDOWN(Y2_STDBY_PIN);
#endif
#if PIN_EXISTS(Z_STDBY)
SET_INPUT_PULLDOWN(Z_STDBY_PIN);
#endif
#if PIN_EXISTS(Z2_STDBY)
SET_INPUT_PULLDOWN(Z2_STDBY_PIN);
#endif
#if PIN_EXISTS(Z3_STDBY)
SET_INPUT_PULLDOWN(Z3_STDBY_PIN);
#endif
#if PIN_EXISTS(Z4_STDBY)
SET_INPUT_PULLDOWN(Z4_STDBY_PIN);
#endif
#if PIN_EXISTS(E0_STDBY)
SET_INPUT_PULLDOWN(E0_STDBY_PIN);
#endif
#if PIN_EXISTS(E1_STDBY)
SET_INPUT_PULLDOWN(E1_STDBY_PIN);
#endif
#if PIN_EXISTS(E2_STDBY)
SET_INPUT_PULLDOWN(E2_STDBY_PIN);
#endif
#if PIN_EXISTS(E3_STDBY)
SET_INPUT_PULLDOWN(E3_STDBY_PIN);
#endif
#if PIN_EXISTS(E4_STDBY)
SET_INPUT_PULLDOWN(E4_STDBY_PIN);
#endif
#if PIN_EXISTS(E5_STDBY)
SET_INPUT_PULLDOWN(E5_STDBY_PIN);
#endif
#if PIN_EXISTS(E6_STDBY)
SET_INPUT_PULLDOWN(E6_STDBY_PIN);
#endif
#if PIN_EXISTS(E7_STDBY)
SET_INPUT_PULLDOWN(E7_STDBY_PIN);
#endif
}

/**
* Marlin entry-point: Set up before the program loop
* - Set up the kill pin, filament runout, power hold
Expand All @@ -888,23 +939,7 @@ void stop() {
*/
void setup() {

// TMC Low Power Standby pins need to be set as early as possible or they won't be usable
TERN_(HAS_X_TMC_STDBY,SET_INPUT_PULLDOWN(X_STDBY_PIN));
TERN_(HAS_X2_TMC_STDBY,SET_INPUT_PULLDOWN(X2_STDBY_PIN));
TERN_(HAS_Y_TMC_STDBY,SET_INPUT_PULLDOWN(Y_STDBY_PIN));
TERN_(HAS_Y2_TMC_STDBY,SET_INPUT_PULLDOWN(Y2_STDBY_PIN));
TERN_(HAS_Z_TMC_STDBY,SET_INPUT_PULLDOWN(Z_STDBY_PIN));
TERN_(HAS_Z2_TMC_STDBY,SET_INPUT_PULLDOWN(Z2_STDBY_PIN));
TERN_(HAS_Z3_TMC_STDBY,SET_INPUT_PULLDOWN(Z3_STDBY_PIN));
TERN_(HAS_Z4_TMC_STDBY,SET_INPUT_PULLDOWN(Z4_STDBY_PIN));
TERN_(HAS_E0_TMC_STDBY,SET_INPUT_PULLDOWN(E0_STDBY_PIN));
TERN_(HAS_E1_TMC_STDBY,SET_INPUT_PULLDOWN(E1_STDBY_PIN));
TERN_(HAS_E2_TMC_STDBY,SET_INPUT_PULLDOWN(E2_STDBY_PIN));
TERN_(HAS_E3_TMC_STDBY,SET_INPUT_PULLDOWN(E3_STDBY_PIN));
TERN_(HAS_E4_TMC_STDBY,SET_INPUT_PULLDOWN(E4_STDBY_PIN));
TERN_(HAS_E5_TMC_STDBY,SET_INPUT_PULLDOWN(E5_STDBY_PIN));
TERN_(HAS_E6_TMC_STDBY,SET_INPUT_PULLDOWN(E6_STDBY_PIN));
TERN_(HAS_E7_TMC_STDBY,SET_INPUT_PULLDOWN(E7_STDBY_PIN));
tmc_standby_setup(); // TMC Low Power Standby pins must be set early or they're not usable

#if ENABLED(MARLIN_DEV_MODE)
auto log_current_ms = [&](PGM_P const msg) {
Expand Down
48 changes: 0 additions & 48 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -1336,9 +1336,6 @@
#if PIN_EXISTS(X_MS1)
#define HAS_X_MS_PINS 1
#endif
#if PIN_EXISTS(X_STDBY)
#define HAS_X_TMC_STDBY 1
#endif

#if PIN_EXISTS(X2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(X2))
#define HAS_X2_ENABLE 1
Expand All @@ -1352,9 +1349,6 @@
#if PIN_EXISTS(X2_MS1)
#define HAS_X2_MS_PINS 1
#endif
#if PIN_EXISTS(X2_STDBY)
#define HAS_X2_TMC_STDBY 1
#endif

#if PIN_EXISTS(Y_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y))
#define HAS_Y_ENABLE 1
Expand All @@ -1368,9 +1362,6 @@
#if PIN_EXISTS(Y_MS1)
#define HAS_Y_MS_PINS 1
#endif
#if PIN_EXISTS(Y_STDBY)
#define HAS_Y_TMC_STDBY 1
#endif

#if PIN_EXISTS(Y2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y2))
#define HAS_Y2_ENABLE 1
Expand All @@ -1384,9 +1375,6 @@
#if PIN_EXISTS(Y2_MS1)
#define HAS_Y2_MS_PINS 1
#endif
#if PIN_EXISTS(Y2_STDBY)
#define HAS_Y2_TMC_STDBY 1
#endif

#if PIN_EXISTS(Z_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z))
#define HAS_Z_ENABLE 1
Expand All @@ -1400,9 +1388,6 @@
#if PIN_EXISTS(Z_MS1)
#define HAS_Z_MS_PINS 1
#endif
#if PIN_EXISTS(Z_STDBY)
#define HAS_Z_TMC_STDBY 1
#endif

#if PIN_EXISTS(Z2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z2))
#define HAS_Z2_ENABLE 1
Expand All @@ -1416,9 +1401,6 @@
#if PIN_EXISTS(Z2_MS1)
#define HAS_Z2_MS_PINS 1
#endif
#if PIN_EXISTS(Z2_STDBY)
#define HAS_Z2_TMC_STDBY 1
#endif

#if PIN_EXISTS(Z3_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z3))
#define HAS_Z3_ENABLE 1
Expand All @@ -1432,9 +1414,6 @@
#if PIN_EXISTS(Z3_MS1)
#define HAS_Z3_MS_PINS 1
#endif
#if PIN_EXISTS(Z3_STDBY)
#define HAS_Z3_TMC_STDBY 1
#endif

#if PIN_EXISTS(Z4_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z4))
#define HAS_Z4_ENABLE 1
Expand All @@ -1448,9 +1427,6 @@
#if PIN_EXISTS(Z4_MS1)
#define HAS_Z4_MS_PINS 1
#endif
#if PIN_EXISTS(Z4_STDBY)
#define HAS_Z4_TMC_STDBY 1
#endif

// Extruder steppers and solenoids
#if PIN_EXISTS(E0_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E0))
Expand All @@ -1468,9 +1444,6 @@
#if PIN_EXISTS(SOL0)
#define HAS_SOLENOID_0 1
#endif
#if PIN_EXISTS(E0_STDBY)
#define HAS_E0_TMC_STDBY 1
#endif

#if PIN_EXISTS(E1_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E1))
#define HAS_E1_ENABLE 1
Expand All @@ -1487,9 +1460,6 @@
#if PIN_EXISTS(SOL1)
#define HAS_SOLENOID_1 1
#endif
#if PIN_EXISTS(E1_STDBY)
#define HAS_E1_TMC_STDBY 1
#endif

#if PIN_EXISTS(E2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E2))
#define HAS_E2_ENABLE 1
Expand All @@ -1506,9 +1476,6 @@
#if PIN_EXISTS(SOL2)
#define HAS_SOLENOID_2 1
#endif
#if PIN_EXISTS(E2_STDBY)
#define HAS_E2_TMC_STDBY 1
#endif

#if PIN_EXISTS(E3_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E3))
#define HAS_E3_ENABLE 1
Expand All @@ -1525,9 +1492,6 @@
#if PIN_EXISTS(SOL3)
#define HAS_SOLENOID_3 1
#endif
#if PIN_EXISTS(E3_STDBY)
#define HAS_E3_TMC_STDBY 1
#endif

#if PIN_EXISTS(E4_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E4))
#define HAS_E4_ENABLE 1
Expand All @@ -1544,9 +1508,6 @@
#if PIN_EXISTS(SOL4)
#define HAS_SOLENOID_4 1
#endif
#if PIN_EXISTS(E4_STDBY)
#define HAS_E4_TMC_STDBY 1
#endif

#if PIN_EXISTS(E5_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E5))
#define HAS_E5_ENABLE 1
Expand All @@ -1563,9 +1524,6 @@
#if PIN_EXISTS(SOL5)
#define HAS_SOLENOID_5 1
#endif
#if PIN_EXISTS(E5_STDBY)
#define HAS_E5_TMC_STDBY 1
#endif

#if PIN_EXISTS(E6_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E6))
#define HAS_E6_ENABLE 1
Expand All @@ -1582,9 +1540,6 @@
#if PIN_EXISTS(SOL6)
#define HAS_SOLENOID_6 1
#endif
#if PIN_EXISTS(E6_STDBY)
#define HAS_E6_TMC_STDBY 1
#endif

#if PIN_EXISTS(E7_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E7))
#define HAS_E7_ENABLE 1
Expand All @@ -1601,9 +1556,6 @@
#if PIN_EXISTS(SOL7)
#define HAS_SOLENOID_7 1
#endif
#if PIN_EXISTS(E7_STDBY)
#define HAS_E7_TMC_STDBY 1
#endif

//
// Trinamic Stepper Drivers
Expand Down

0 comments on commit 6771dc1

Please sign in to comment.