1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-23 20:18:52 +00:00

Fix up, improve endstop pin auto-assignment

Followup for #16723
This commit is contained in:
Scott Lahteine 2020-01-30 14:09:33 -06:00
parent e8e25b80d1
commit 62f52ebb3a
3 changed files with 43 additions and 28 deletions

View File

@ -36,11 +36,10 @@
* Limit Switches
*/
#if X_STALL_SENSITIVITY
#define X_STOP_PIN X_DIAG_PIN
#if X_HOME_DIR < 0
#define X_MIN_PIN X_DIAG_PIN
#define X_MAX_PIN P1_28 // X+
#else
#define X_MAX_PIN X_DIAG_PIN
#define X_MIN_PIN P1_28 // X+
#endif
#else
@ -49,11 +48,10 @@
#endif
#if Y_STALL_SENSITIVITY
#define Y_STOP_PIN Y_DIAG_PIN
#if Y_HOME_DIR < 0
#define Y_MIN_PIN Y_DIAG_PIN
#define Y_MAX_PIN P1_26 // Y+
#else
#define Y_MAX_PIN Y_DIAG_PIN
#define Y_MIN_PIN P1_26 // Y+
#endif
#else
@ -62,11 +60,10 @@
#endif
#if Z_STALL_SENSITIVITY
#define Z_STOP_PIN Z_DIAG_PIN
#if Z_HOME_DIR < 0
#define Z_MIN_PIN Z_DIAG_PIN
#define Z_MAX_PIN P1_24 // Z+
#else
#define Z_MAX_PIN Z_DIAG_PIN
#define Z_MIN_PIN P1_24 // Z+
#endif
#else
@ -184,9 +181,6 @@
#define E1_SERIAL_TX_PIN P1_04
#define E1_SERIAL_RX_PIN P1_01
#define Z2_SERIAL_TX_PIN P1_04
#define Z2_SERIAL_RX_PIN P1_01
// Reduce baud rate to improve software serial reliability
#define TMC_BAUD_RATE 19200
#endif

View File

@ -50,11 +50,10 @@
// Limit Switches
//
#if X_STALL_SENSITIVITY
#define X_STOP_PIN X_DIAG_PIN
#if X_HOME_DIR < 0
#define X_MIN_PIN X_DIAG_PIN
#define X_MAX_PIN P1_26 // E0DET
#else
#define X_MAX_PIN X_DIAG_PIN
#define X_MIN_PIN P1_26 // E0DET
#endif
#else
@ -62,11 +61,10 @@
#endif
#if Y_STALL_SENSITIVITY
#define Y_STOP_PIN Y_DIAG_PIN
#if Y_HOME_DIR < 0
#define Y_MIN_PIN Y_DIAG_PIN
#define Y_MAX_PIN P1_25 // E1DET
#else
#define Y_MAX_PIN Y_DIAG_PIN
#define Y_MIN_PIN P1_25 // E1DET
#endif
#else
@ -74,11 +72,10 @@
#endif
#if Z_STALL_SENSITIVITY
#define Z_STOP_PIN Z_DIAG_PIN
#if Z_HOME_DIR < 0
#define Z_MIN_PIN Z_DIAG_PIN
#define Z_MAX_PIN P1_24 // PWRDET
#else
#define Z_MAX_PIN Z_DIAG_PIN
#define Z_MIN_PIN P1_24 // PWRDET
#endif
#else

View File

@ -1026,10 +1026,14 @@
#ifdef X_STOP_PIN
#if X_HOME_DIR < 0
#define X_MIN_PIN X_STOP_PIN
#define X_MAX_PIN -1
#ifndef X_MAX_PIN
#define X_MAX_PIN -1
#endif
#else
#define X_MIN_PIN -1
#define X_MAX_PIN X_STOP_PIN
#ifndef X_MIN_PIN
#define X_MIN_PIN -1
#endif
#endif
#elif X_HOME_DIR < 0
#define X_STOP_PIN X_MIN_PIN
@ -1040,10 +1044,14 @@
#ifdef Y_STOP_PIN
#if Y_HOME_DIR < 0
#define Y_MIN_PIN Y_STOP_PIN
#define Y_MAX_PIN -1
#ifndef Y_MAX_PIN
#define Y_MAX_PIN -1
#endif
#else
#define Y_MIN_PIN -1
#define Y_MAX_PIN Y_STOP_PIN
#ifndef Y_MIN_PIN
#define Y_MIN_PIN -1
#endif
#endif
#elif Y_HOME_DIR < 0
#define Y_STOP_PIN Y_MIN_PIN
@ -1054,10 +1062,14 @@
#ifdef Z_STOP_PIN
#if Z_HOME_DIR < 0
#define Z_MIN_PIN Z_STOP_PIN
#define Z_MAX_PIN -1
#ifndef Z_MAX_PIN
#define Z_MAX_PIN -1
#endif
#else
#define Z_MIN_PIN -1
#define Z_MAX_PIN Z_STOP_PIN
#ifndef Z_MIN_PIN
#define Z_MIN_PIN -1
#endif
#endif
#elif Z_HOME_DIR < 0
#define Z_STOP_PIN Z_MIN_PIN
@ -1127,9 +1139,11 @@
* overridden in Configuration.h or Configuration_adv.h.
*/
#define __PEXI(p,q) PIN_EXISTS(E##p##_##q)
#define _PEXI(p,q) __PEXI(p,q)
#define __EPIN(p,q) E##p##_##q##_PIN
#define _EPIN(p,q) __EPIN(p,q)
#define DIAG_REMAPPED(P,Q) (PIN_EXISTS(Q) && (P##_DIAG_PIN == Q##_PIN))
#define DIAG_REMAPPED(p,q) (PIN_EXISTS(q) && _EPIN(p##_E_INDEX, DIAG) == q##_PIN)
// The X2 axis, if any, should be the next open extruder port
#define X2_E_INDEX E_STEPPERS
@ -1167,7 +1181,8 @@
//
// Auto-assign pins for stallGuard sensorless homing
//
#if X2_STALL_SENSITIVITY && ENABLED(X_DUAL_ENDSTOPS) && _EPIN(X2_E_INDEX, DIAG) > 0
#if X2_STALL_SENSITIVITY && ENABLED(X_DUAL_ENDSTOPS) && _PEXI(X2_E_INDEX, DIAG)
#define X2_DIAG_PIN _EPIN(X2_E_INDEX, DIAG)
#if DIAG_REMAPPED(X2, X_MIN) // If already remapped in the pins file...
#define X2_USE_ENDSTOP _XMIN_
#elif DIAG_REMAPPED(X2, Y_MIN)
@ -1184,6 +1199,7 @@
#define _X2_USE_ENDSTOP(P) _E##P##_DIAG_
#define X2_USE_ENDSTOP _X2_USE_ENDSTOP(X2_E_INDEX)
#endif
#undef X2_DIAG_PIN
#endif
#define Y2_E_INDEX INCREMENT(X2_E_INDEX)
@ -1234,7 +1250,8 @@
#define Y2_SERIAL_RX_PIN _EPIN(Y2_E_INDEX, SERIAL_RX)
#endif
#endif
#if Y2_STALL_SENSITIVITY && ENABLED(X_DUAL_ENDSTOPS) && _EPIN(Y2_E_INDEX, DIAG) > 0
#if Y2_STALL_SENSITIVITY && ENABLED(Y_DUAL_ENDSTOPS) && _PEXI(Y2_E_INDEX, DIAG)
#define Y2_DIAG_PIN _EPIN(Y2_E_INDEX, DIAG)
#if DIAG_REMAPPED(Y2, X_MIN)
#define Y2_USE_ENDSTOP _XMIN_
#elif DIAG_REMAPPED(Y2, Y_MIN)
@ -1251,6 +1268,7 @@
#define _Y2_USE_ENDSTOP(P) _E##P##_DIAG_
#define Y2_USE_ENDSTOP _Y2_USE_ENDSTOP(Y2_E_INDEX)
#endif
#undef Y2_DIAG_PIN
#endif
#define Z2_E_INDEX INCREMENT(Y2_E_INDEX)
#else
@ -1300,7 +1318,8 @@
#define Z2_SERIAL_RX_PIN _EPIN(Z2_E_INDEX, SERIAL_RX)
#endif
#endif
#if Z2_STALL_SENSITIVITY && ENABLED(X_DUAL_ENDSTOPS) && _EPIN(Z2_E_INDEX, DIAG) > 0
#if Z2_STALL_SENSITIVITY && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 2 && _PEXI(Z2_E_INDEX, DIAG)
#define Z2_DIAG_PIN _EPIN(Z2_E_INDEX, DIAG)
#if DIAG_REMAPPED(Z2, X_MIN)
#define Z2_USE_ENDSTOP _XMIN_
#elif DIAG_REMAPPED(Z2, Y_MIN)
@ -1317,6 +1336,7 @@
#define _Z2_USE_ENDSTOP(P) _E##P##_DIAG_
#define Z2_USE_ENDSTOP _Z2_USE_ENDSTOP(Z2_E_INDEX)
#endif
#undef Z2_DIAG_PIN
#endif
#define Z3_E_INDEX INCREMENT(Z2_E_INDEX)
#else
@ -1367,7 +1387,8 @@
#define Z3_SERIAL_RX_PIN _EPIN(Z3_E_INDEX, SERIAL_RX)
#endif
#endif
#if Z3_STALL_SENSITIVITY && ENABLED(X_DUAL_ENDSTOPS) && _EPIN(Z3_E_INDEX, DIAG) > 0
#if Z3_STALL_SENSITIVITY && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3 && _PEXI(Z3_E_INDEX, DIAG)
#define Z3_DIAG_PIN _EPIN(Z3_E_INDEX, DIAG)
#if DIAG_REMAPPED(Z3, X_MIN)
#define Z3_USE_ENDSTOP _XMIN_
#elif DIAG_REMAPPED(Z3, Y_MIN)
@ -1382,8 +1403,9 @@
#define Z3_USE_ENDSTOP _ZMAX_
#else
#define _Z3_USE_ENDSTOP(P) _E##P##_DIAG_
#define Z3_USE_ENDSTOP _Y2_USE_ENDSTOP(Y2_E_INDEX)
#define Z3_USE_ENDSTOP _Z3_USE_ENDSTOP(Z3_E_INDEX)
#endif
#undef Z3_DIAG_PIN
#endif
#define Z4_E_INDEX INCREMENT(Z3_E_INDEX)
#endif
@ -1432,7 +1454,8 @@
#define Z4_SERIAL_RX_PIN _EPIN(Z4_E_INDEX, SERIAL_RX)
#endif
#endif
#if Z4_STALL_SENSITIVITY && ENABLED(X_DUAL_ENDSTOPS) && _EPIN(Z4_E_INDEX, DIAG) > 0
#if Z4_STALL_SENSITIVITY && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 4 && _PEXI(Z4_E_INDEX, DIAG)
#define Z4_DIAG_PIN _EPIN(Z4_E_INDEX, DIAG)
#if DIAG_REMAPPED(Z4, X_MIN)
#define Z4_USE_ENDSTOP _XMIN_
#elif DIAG_REMAPPED(Z4, Y_MIN)
@ -1449,6 +1472,7 @@
#define _Z4_USE_ENDSTOP(P) _E##P##_DIAG_
#define Z4_USE_ENDSTOP _Z4_USE_ENDSTOP(Z4_E_INDEX)
#endif
#undef Z4_DIAG_PIN
#endif
#endif