diff --git a/Marlin/src/feature/stepper_driver_safety.cpp b/Marlin/src/feature/stepper_driver_safety.cpp index 991f5a5906b4..c7da5d2ff7f6 100644 --- a/Marlin/src/feature/stepper_driver_safety.cpp +++ b/Marlin/src/feature/stepper_driver_safety.cpp @@ -39,7 +39,7 @@ void stepper_driver_backward_check() { OUT_WRITE(SAFE_POWER_PIN, LOW); - #define TEST_BACKWARD(AXIS, BIT) do { \ + #define _TEST_BACKWARD(AXIS, BIT) do { \ SET_INPUT(AXIS##_ENABLE_PIN); \ OUT_WRITE(AXIS##_STEP_PIN, false); \ delay(20); \ @@ -49,57 +49,31 @@ void stepper_driver_backward_check() { } \ }while(0) - #if HAS_X_ENABLE - TEST_BACKWARD(X, 0); - #endif - #if HAS_X2_ENABLE - TEST_BACKWARD(X2, 1); - #endif - - #if HAS_Y_ENABLE - TEST_BACKWARD(Y, 2); - #endif - #if HAS_Y2_ENABLE - TEST_BACKWARD(Y2, 3); - #endif - - #if HAS_Z_ENABLE - TEST_BACKWARD(Z, 4); - #endif - #if HAS_Z2_ENABLE - TEST_BACKWARD(Z2, 5); - #endif - #if HAS_Z3_ENABLE - TEST_BACKWARD(Z3, 6); - #endif - #if HAS_Z4_ENABLE - TEST_BACKWARD(Z4, 7); - #endif - - #if HAS_E0_ENABLE - TEST_BACKWARD(E0, 8); - #endif - #if HAS_E1_ENABLE - TEST_BACKWARD(E1, 9); - #endif - #if HAS_E2_ENABLE - TEST_BACKWARD(E2, 10); - #endif - #if HAS_E3_ENABLE - TEST_BACKWARD(E3, 11); - #endif - #if HAS_E4_ENABLE - TEST_BACKWARD(E4, 12); - #endif - #if HAS_E5_ENABLE - TEST_BACKWARD(E5, 13); - #endif - #if HAS_E6_ENABLE - TEST_BACKWARD(E6, 14); - #endif - #if HAS_E7_ENABLE - TEST_BACKWARD(E7, 15); - #endif + #define TEST_BACKWARD(AXIS, BIT) TERN_(HAS_##AXIS##_ENABLE, _TEST_BACKWARD(AXIS, BIT)) + + TEST_BACKWARD(X, 0); + TEST_BACKWARD(X2, 1); + + TEST_BACKWARD(Y, 2); + TEST_BACKWARD(Y2, 3); + + TEST_BACKWARD(Z, 4); + TEST_BACKWARD(Z2, 5); + TEST_BACKWARD(Z3, 6); + TEST_BACKWARD(Z4, 7); + + TEST_BACKWARD(I, 8); + TEST_BACKWARD(J, 9); + TEST_BACKWARD(K, 10); + + TEST_BACKWARD(E0, 11); + TEST_BACKWARD(E1, 12); + TEST_BACKWARD(E2, 13); + TEST_BACKWARD(E3, 14); + TEST_BACKWARD(E4, 15); + TEST_BACKWARD(E5, 16); + TEST_BACKWARD(E6, 17); + TEST_BACKWARD(E7, 18); if (!axis_plug_backward) WRITE(SAFE_POWER_PIN, HIGH); @@ -113,59 +87,31 @@ void stepper_driver_backward_report() { stepper_driver_backward_error(axis); }; - #define REPORT_BACKWARD(axis, bit) _report_if_backward(PSTR(STRINGIFY(axis)), bit) - - #if HAS_X_ENABLE - REPORT_BACKWARD(X, 0); - #endif - #if HAS_X2_ENABLE - REPORT_BACKWARD(X2, 1); - #endif - - #if HAS_Y_ENABLE - REPORT_BACKWARD(Y, 2); - #endif - #if HAS_Y2_ENABLE - REPORT_BACKWARD(Y2, 3); - #endif - - #if HAS_Z_ENABLE - REPORT_BACKWARD(Z, 4); - #endif - #if HAS_Z2_ENABLE - REPORT_BACKWARD(Z2, 5); - #endif - #if HAS_Z3_ENABLE - REPORT_BACKWARD(Z3, 6); - #endif - #if HAS_Z4_ENABLE - REPORT_BACKWARD(Z4, 7); - #endif - - #if HAS_E0_ENABLE - REPORT_BACKWARD(E0, 8); - #endif - #if HAS_E1_ENABLE - REPORT_BACKWARD(E1, 9); - #endif - #if HAS_E2_ENABLE - REPORT_BACKWARD(E2, 10); - #endif - #if HAS_E3_ENABLE - REPORT_BACKWARD(E3, 11); - #endif - #if HAS_E4_ENABLE - REPORT_BACKWARD(E4, 12); - #endif - #if HAS_E5_ENABLE - REPORT_BACKWARD(E5, 13); - #endif - #if HAS_E6_ENABLE - REPORT_BACKWARD(E6, 14); - #endif - #if HAS_E7_ENABLE - REPORT_BACKWARD(E7, 15); - #endif + #define REPORT_BACKWARD(axis, bit) TERN_(HAS_##axis##_ENABLE, _report_if_backward(PSTR(STRINGIFY(axis)), bit)) + + REPORT_BACKWARD(X, 0); + REPORT_BACKWARD(X2, 1); + + REPORT_BACKWARD(Y, 2); + REPORT_BACKWARD(Y2, 3); + + REPORT_BACKWARD(Z, 4); + REPORT_BACKWARD(Z2, 5); + REPORT_BACKWARD(Z3, 6); + REPORT_BACKWARD(Z4, 7); + + REPORT_BACKWARD(I, 8); + REPORT_BACKWARD(J, 9); + REPORT_BACKWARD(K, 10); + + REPORT_BACKWARD(E0, 11); + REPORT_BACKWARD(E1, 12); + REPORT_BACKWARD(E2, 13); + REPORT_BACKWARD(E3, 14); + REPORT_BACKWARD(E4, 15); + REPORT_BACKWARD(E5, 16); + REPORT_BACKWARD(E6, 17); + REPORT_BACKWARD(E7, 18); } #endif // HAS_DRIVER_SAFE_POWER_PROTECT