Browse Source

🎨 IJK auto-allocation (#22075)

ellensp 3 years ago
parent
commit
70b80fcd16
No account linked to committer's email address
1 changed files with 212 additions and 0 deletions
  1. 212
    0
      Marlin/src/pins/pins_postprocess.h

+ 212
- 0
Marlin/src/pins/pins_postprocess.h View File

@@ -809,6 +809,8 @@
809 809
     #undef Z3_DIAG_PIN
810 810
   #endif
811 811
   #define Z4_E_INDEX INCREMENT(Z3_E_INDEX)
812
+#else
813
+  #define Z4_E_INDEX Z3_E_INDEX
812 814
 #endif
813 815
 
814 816
 #ifndef Z3_CS_PIN
@@ -876,6 +878,9 @@
876 878
     #endif
877 879
     #undef Z4_DIAG_PIN
878 880
   #endif
881
+  #define I_E_INDEX INCREMENT(Z4_E_INDEX)
882
+#else
883
+  #define I_E_INDEX Z4_E_INDEX
879 884
 #endif
880 885
 
881 886
 #ifndef Z4_CS_PIN
@@ -891,6 +896,213 @@
891 896
   #define Z4_MS3_PIN -1
892 897
 #endif
893 898
 
899
+#if LINEAR_AXES >= 4
900
+  #ifndef I_STEP_PIN
901
+    #define I_STEP_PIN   _EPIN(I_E_INDEX, STEP)
902
+    #define I_DIR_PIN    _EPIN(I_E_INDEX, DIR)
903
+    #define I_ENABLE_PIN _EPIN(I_E_INDEX, ENABLE)
904
+    #if I_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(I_STEP)
905
+      #error "No E stepper plug left for I!"
906
+    #endif
907
+  #endif
908
+  #if AXIS_HAS_SPI(I)
909
+    #ifndef I_CS_PIN
910
+      #define I_CS_PIN   _EPIN(I_E_INDEX, CS)
911
+    #endif
912
+  #endif
913
+  #ifndef I_MS1_PIN
914
+    #define I_MS1_PIN    _EPIN(I_E_INDEX, MS1)
915
+  #endif
916
+  #ifndef I_MS2_PIN
917
+    #define I_MS2_PIN    _EPIN(I_E_INDEX, MS2)
918
+  #endif
919
+  #ifndef I_MS3_PIN
920
+    #define I_MS3_PIN    _EPIN(I_E_INDEX, MS3)
921
+  #endif
922
+  #if AXIS_HAS_UART(I)
923
+    #ifndef I_SERIAL_TX_PIN
924
+      #define I_SERIAL_TX_PIN _EPIN(I_E_INDEX, SERIAL_TX)
925
+    #endif
926
+    #ifndef I_SERIAL_RX_PIN
927
+      #define I_SERIAL_RX_PIN _EPIN(I_E_INDEX, SERIAL_RX)
928
+    #endif
929
+  #endif
930
+  // Auto-assign pins for stallGuard sensorless homing
931
+  #if !defined(I_USE_ENDSTOP) && defined(I_STALL_SENSITIVITY) && _PEXI(I_E_INDEX, DIAG)
932
+    #define I_DIAG_PIN _EPIN(I_E_INDEX, DIAG)
933
+    #if   DIAG_REMAPPED(I, X_MIN)
934
+      #define I_USE_ENDSTOP _XMIN_
935
+    #elif DIAG_REMAPPED(I, Y_MIN)
936
+      #define I_USE_ENDSTOP _YMIN_
937
+    #elif DIAG_REMAPPED(I, Z_MIN)
938
+      #define I_USE_ENDSTOP _ZMIN_
939
+    #elif DIAG_REMAPPED(I, X_MAX)
940
+      #define I_USE_ENDSTOP _XMAX_
941
+    #elif DIAG_REMAPPED(I, Y_MAX)
942
+      #define I_USE_ENDSTOP _YMAX_
943
+    #elif DIAG_REMAPPED(I, Z_MAX)
944
+      #define I_USE_ENDSTOP _ZMAX_
945
+    #else
946
+      #define _I_USE_ENDSTOP(P) _E##P##_DIAG_
947
+      #define I_USE_ENDSTOP _I_USE_ENDSTOP(I_E_INDEX)
948
+    #endif
949
+    #undef I_DIAG_PIN
950
+  #endif
951
+  #define J_E_INDEX INCREMENT(I_E_INDEX)
952
+#else
953
+  #define J_E_INDEX I_E_INDEX
954
+#endif
955
+
956
+#ifndef I_CS_PIN
957
+  #define I_CS_PIN  -1
958
+#endif
959
+#ifndef I_MS1_PIN
960
+  #define I_MS1_PIN -1
961
+#endif
962
+#ifndef I_MS2_PIN
963
+  #define I_MS2_PIN -1
964
+#endif
965
+#ifndef I_MS3_PIN
966
+  #define I_MS3_PIN -1
967
+#endif
968
+
969
+#if LINEAR_AXES >= 5
970
+  #ifndef J_STEP_PIN
971
+    #define J_STEP_PIN   _EPIN(J_E_INDEX, STEP)
972
+    #define J_DIR_PIN    _EPIN(J_E_INDEX, DIR)
973
+    #define J_ENABLE_PIN _EPIN(J_E_INDEX, ENABLE)
974
+    #if I_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(J_STEP)
975
+      #error "No E stepper plug left for J!"
976
+    #endif
977
+  #endif
978
+  #if AXIS_HAS_SPI(J)
979
+    #ifndef J_CS_PIN
980
+      #define J_CS_PIN   _EPIN(J_E_INDEX, CS)
981
+    #endif
982
+  #endif
983
+  #ifndef J_MS1_PIN
984
+    #define J_MS1_PIN    _EPIN(J_E_INDEX, MS1)
985
+  #endif
986
+  #ifndef J_MS2_PIN
987
+    #define J_MS2_PIN    _EPIN(J_E_INDEX, MS2)
988
+  #endif
989
+  #ifndef J_MS3_PIN
990
+    #define J_MS3_PIN    _EPIN(J_E_INDEX, MS3)
991
+  #endif
992
+  #if AXIS_HAS_UART(J)
993
+    #ifndef J_SERIAL_TX_PIN
994
+      #define J_SERIAL_TX_PIN _EPIN(J_E_INDEX, SERIAL_TX)
995
+    #endif
996
+    #ifndef J_SERIAL_RX_PIN
997
+      #define J_SERIAL_RX_PIN _EPIN(J_E_INDEX, SERIAL_RX)
998
+    #endif
999
+  #endif
1000
+  // Auto-assign pins for stallGuard sensorless homing
1001
+  #if !defined(J_USE_ENDSTOP) && defined(J_STALL_SENSITIVITY) && _PEXI(J_E_INDEX, DIAG)
1002
+    #define J_DIAG_PIN _EPIN(J_E_INDEX, DIAG)
1003
+    #if   DIAG_REMAPPED(J, X_MIN)
1004
+      #define J_USE_ENDSTOP _XMIN_
1005
+    #elif DIAG_REMAPPED(J, Y_MIN)
1006
+      #define J_USE_ENDSTOP _YMIN_
1007
+    #elif DIAG_REMAPPED(J, Z_MIN)
1008
+      #define J_USE_ENDSTOP _ZMIN_
1009
+    #elif DIAG_REMAPPED(J, X_MAX)
1010
+      #define J_USE_ENDSTOP _XMAX_
1011
+    #elif DIAG_REMAPPED(J, Y_MAX)
1012
+      #define J_USE_ENDSTOP _YMAX_
1013
+    #elif DIAG_REMAPPED(I, Z_MAX)
1014
+      #define J_USE_ENDSTOP _ZMAX_
1015
+    #else
1016
+      #define _J_USE_ENDSTOP(P) _E##P##_DIAG_
1017
+      #define J_USE_ENDSTOP _J_USE_ENDSTOP(J_E_INDEX)
1018
+    #endif
1019
+    #undef J_DIAG_PIN
1020
+  #endif
1021
+  #define K_E_INDEX INCREMENT(J_E_INDEX)
1022
+#else
1023
+  #define K_E_INDEX J_E_INDEX
1024
+#endif
1025
+
1026
+#ifndef J_CS_PIN
1027
+  #define J_CS_PIN  -1
1028
+#endif
1029
+#ifndef J_MS1_PIN
1030
+  #define J_MS1_PIN -1
1031
+#endif
1032
+#ifndef J_MS2_PIN
1033
+  #define J_MS2_PIN -1
1034
+#endif
1035
+#ifndef J_MS3_PIN
1036
+  #define J_MS3_PIN -1
1037
+#endif
1038
+
1039
+#if LINEAR_AXES >= 6
1040
+  #ifndef K_STEP_PIN
1041
+    #define K_STEP_PIN   _EPIN(K_E_INDEX, STEP)
1042
+    #define K_DIR_PIN    _EPIN(K_E_INDEX, DIR)
1043
+    #define K_ENABLE_PIN _EPIN(K_E_INDEX, ENABLE)
1044
+    #if K_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(K_STEP)
1045
+      #error "No E stepper plug left for K!"
1046
+    #endif
1047
+  #endif
1048
+  #if AXIS_HAS_SPI(K)
1049
+    #ifndef K_CS_PIN
1050
+      #define K_CS_PIN   _EPIN(K_E_INDEX, CS)
1051
+    #endif
1052
+  #endif
1053
+  #ifndef K_MS1_PIN
1054
+    #define K_MS1_PIN    _EPIN(K_E_INDEX, MS1)
1055
+  #endif
1056
+  #ifndef K_MS2_PIN
1057
+    #define K_MS2_PIN    _EPIN(K_E_INDEX, MS2)
1058
+  #endif
1059
+  #ifndef K_MS3_PIN
1060
+    #define K_MS3_PIN    _EPIN(K_E_INDEX, MS3)
1061
+  #endif
1062
+  #if AXIS_HAS_UART(K)
1063
+    #ifndef K_SERIAL_TX_PIN
1064
+      #define K_SERIAL_TX_PIN _EPIN(K_E_INDEX, SERIAL_TX)
1065
+    #endif
1066
+    #ifndef K_SERIAL_RX_PIN
1067
+      #define K_SERIAL_RX_PIN _EPIN(K_E_INDEX, SERIAL_RX)
1068
+    #endif
1069
+  #endif
1070
+  // Auto-assign pins for stallGuard sensorless homing
1071
+  #if !defined(K_USE_ENDSTOP) && defined(K_STALL_SENSITIVITY) && _PEXI(K_E_INDEX, DIAG)
1072
+    #define K_DIAG_PIN _EPIN(K_E_INDEX, DIAG)
1073
+    #if   DIAG_REMAPPED(K, X_MIN)
1074
+      #define K_USE_ENDSTOP _XMIN_
1075
+    #elif DIAG_REMAPPED(K, Y_MIN)
1076
+      #define K_USE_ENDSTOP _YMIN_
1077
+    #elif DIAG_REMAPPED(K, Z_MIN)
1078
+      #define K_USE_ENDSTOP _ZMIN_
1079
+    #elif DIAG_REMAPPED(K, X_MAX)
1080
+      #define K_USE_ENDSTOP _XMAX_
1081
+    #elif DIAG_REMAPPED(K, Y_MAX)
1082
+      #define K_USE_ENDSTOP _YMAX_
1083
+    #elif DIAG_REMAPPED(K, Z_MAX)
1084
+      #define K_USE_ENDSTOP _ZMAX_
1085
+    #else
1086
+      #define _K_USE_ENDSTOP(P) _E##P##_DIAG_
1087
+      #define K_USE_ENDSTOP _K_USE_ENDSTOP(K_E_INDEX)
1088
+    #endif
1089
+    #undef K_DIAG_PIN
1090
+  #endif
1091
+#endif
1092
+
1093
+#ifndef K_CS_PIN
1094
+  #define K_CS_PIN  -1
1095
+#endif
1096
+#ifndef K_MS1_PIN
1097
+  #define K_MS1_PIN -1
1098
+#endif
1099
+#ifndef K_MS2_PIN
1100
+  #define K_MS2_PIN -1
1101
+#endif
1102
+#ifndef K_MS3_PIN
1103
+  #define K_MS3_PIN -1
1104
+#endif
1105
+
894 1106
 //
895 1107
 // Disable unused endstop / probe pins
896 1108
 //

Loading…
Cancel
Save