Selaa lähdekoodia

Auto-assign CS pins for X2, Y2, Z2 (#10057)

Fixes #9211
Scott Lahteine 7 vuotta sitten
vanhempi
commit
d385b9aac7
No account linked to committer's email address
1 muutettua tiedostoa jossa 54 lisäystä ja 24 poistoa
  1. 54
    24
      Marlin/src/pins/pins.h

+ 54
- 24
Marlin/src/pins/pins.h Näytä tiedosto

464
   #define E4_ENABLE_PIN -1
464
   #define E4_ENABLE_PIN -1
465
 #endif
465
 #endif
466
 
466
 
467
+#ifndef X_CS_PIN
468
+  #define X_CS_PIN -1
469
+#endif
470
+#ifndef Y_CS_PIN
471
+  #define Y_CS_PIN -1
472
+#endif
473
+#ifndef Z_CS_PIN
474
+  #define Z_CS_PIN -1
475
+#endif
476
+#ifndef E0_CS_PIN
477
+  #define E0_CS_PIN -1
478
+#endif
479
+#ifndef E1_CS_PIN
480
+  #define E1_CS_PIN -1
481
+#endif
482
+#ifndef E2_CS_PIN
483
+  #define E2_CS_PIN -1
484
+#endif
485
+#ifndef E3_CS_PIN
486
+  #define E3_CS_PIN -1
487
+#endif
488
+#ifndef E4_CS_PIN
489
+  #define E4_CS_PIN -1
490
+#endif
491
+
467
 #ifndef FAN_PIN
492
 #ifndef FAN_PIN
468
   #define FAN_PIN -1
493
   #define FAN_PIN -1
469
 #endif
494
 #endif
591
 #endif
616
 #endif
592
 
617
 
593
 // List of pins which to ignore when asked to change by gcode, 0 and 1 are RX and TX, do not mess with those!
618
 // List of pins which to ignore when asked to change by gcode, 0 and 1 are RX and TX, do not mess with those!
594
-#define _E0_PINS E0_STEP_PIN, E0_DIR_PIN, E0_ENABLE_PIN, E0_MS1_PIN, E0_MS2_PIN,
619
+#define _E0_PINS E0_STEP_PIN, E0_DIR_PIN, E0_ENABLE_PIN, E0_MS1_PIN, E0_MS2_PIN, E0_CS_PIN,
595
 #define _E1_PINS
620
 #define _E1_PINS
596
 #define _E2_PINS
621
 #define _E2_PINS
597
 #define _E3_PINS
622
 #define _E3_PINS
601
                       // Tools 0 and 1 use E0
626
                       // Tools 0 and 1 use E0
602
   #if EXTRUDERS > 2   // Tools 2 and 3 use E1
627
   #if EXTRUDERS > 2   // Tools 2 and 3 use E1
603
     #undef _E1_PINS
628
     #undef _E1_PINS
604
-    #define _E1_PINS E1_STEP_PIN, E1_DIR_PIN, E1_ENABLE_PIN, E1_MS1_PIN, E1_MS2_PIN,
629
+    #define _E1_PINS E1_STEP_PIN, E1_DIR_PIN, E1_ENABLE_PIN, E1_MS1_PIN, E1_MS2_PIN, E1_CS_PIN,
605
     #if EXTRUDERS > 4 // Tools 4 and 5 use E2
630
     #if EXTRUDERS > 4 // Tools 4 and 5 use E2
606
       #undef _E2_PINS
631
       #undef _E2_PINS
607
-      #define _E2_PINS E2_STEP_PIN, E2_DIR_PIN, E2_ENABLE_PIN, E2_MS1_PIN, E2_MS2_PIN,
632
+      #define _E2_PINS E2_STEP_PIN, E2_DIR_PIN, E2_ENABLE_PIN, E2_MS1_PIN, E2_MS2_PIN, E2_CS_PIN,
608
     #endif
633
     #endif
609
   #endif
634
   #endif
610
 #elif EXTRUDERS > 1
635
 #elif EXTRUDERS > 1
611
   #undef _E1_PINS
636
   #undef _E1_PINS
612
-  #define _E1_PINS E1_STEP_PIN, E1_DIR_PIN, E1_ENABLE_PIN, E1_MS1_PIN, E1_MS2_PIN,
637
+  #define _E1_PINS E1_STEP_PIN, E1_DIR_PIN, E1_ENABLE_PIN, E1_MS1_PIN, E1_MS2_PIN, E1_CS_PIN,
613
   #if EXTRUDERS > 2
638
   #if EXTRUDERS > 2
614
     #undef _E2_PINS
639
     #undef _E2_PINS
615
-    #define _E2_PINS E2_STEP_PIN, E2_DIR_PIN, E2_ENABLE_PIN, E2_MS1_PIN, E2_MS2_PIN,
640
+    #define _E2_PINS E2_STEP_PIN, E2_DIR_PIN, E2_ENABLE_PIN, E2_MS1_PIN, E2_MS2_PIN, E2_CS_PIN,
616
     #if EXTRUDERS > 3
641
     #if EXTRUDERS > 3
617
       #undef _E3_PINS
642
       #undef _E3_PINS
618
-      #define _E3_PINS E3_STEP_PIN, E3_DIR_PIN, E3_ENABLE_PIN, E3_MS1_PIN, E3_MS2_PIN,
643
+      #define _E3_PINS E3_STEP_PIN, E3_DIR_PIN, E3_ENABLE_PIN, E3_MS1_PIN, E3_MS2_PIN, E3_MS3_PIN, E3_CS_PIN,
619
       #if EXTRUDERS > 4
644
       #if EXTRUDERS > 4
620
         #undef _E4_PINS
645
         #undef _E4_PINS
621
-        #define _E4_PINS E4_STEP_PIN, E4_DIR_PIN, E4_ENABLE_PIN, E4_MS1_PIN, E4_MS2_PIN,
646
+        #define _E4_PINS E4_STEP_PIN, E4_DIR_PIN, E4_ENABLE_PIN, E4_MS1_PIN, E4_MS2_PIN, E4_MS3_PIN, E4_CS_PIN,
622
       #endif // EXTRUDERS > 4
647
       #endif // EXTRUDERS > 4
623
     #endif // EXTRUDERS > 3
648
     #endif // EXTRUDERS > 3
624
   #endif // EXTRUDERS > 2
649
   #endif // EXTRUDERS > 2
625
 #endif // EXTRUDERS > 1
650
 #endif // EXTRUDERS > 1
626
 
651
 
627
-#define _H0_PINS HEATER_0_PIN, E0_AUTO_FAN_PIN, analogInputToDigitalPin(TEMP_0_PIN),
652
+// Marlin needs to account for pins that equal -1
653
+#define marlinAnalogInputToDigitalPin(p) ((p) == -1 ? -1 : analogInputToDigitalPin(p))
654
+
655
+#define _H0_PINS HEATER_0_PIN, E0_AUTO_FAN_PIN, marlinAnalogInputToDigitalPin(TEMP_0_PIN),
628
 #define _H1_PINS
656
 #define _H1_PINS
629
 #define _H2_PINS
657
 #define _H2_PINS
630
 #define _H3_PINS
658
 #define _H3_PINS
632
 
660
 
633
 #if HOTENDS > 1
661
 #if HOTENDS > 1
634
   #undef _H1_PINS
662
   #undef _H1_PINS
635
-  #define _H1_PINS HEATER_1_PIN, E1_AUTO_FAN_PIN, analogInputToDigitalPin(TEMP_1_PIN),
663
+  #define _H1_PINS HEATER_1_PIN, E1_AUTO_FAN_PIN, marlinAnalogInputToDigitalPin(TEMP_1_PIN),
636
   #if HOTENDS > 2
664
   #if HOTENDS > 2
637
     #undef _H2_PINS
665
     #undef _H2_PINS
638
-    #define _H2_PINS HEATER_2_PIN, E2_AUTO_FAN_PIN, analogInputToDigitalPin(TEMP_2_PIN),
666
+    #define _H2_PINS HEATER_2_PIN, E2_AUTO_FAN_PIN, marlinAnalogInputToDigitalPin(TEMP_2_PIN),
639
     #if HOTENDS > 3
667
     #if HOTENDS > 3
640
       #undef _H3_PINS
668
       #undef _H3_PINS
641
-      #define _H3_PINS HEATER_3_PIN, E3_AUTO_FAN_PIN, analogInputToDigitalPin(TEMP_3_PIN),
669
+      #define _H3_PINS HEATER_3_PIN, E3_AUTO_FAN_PIN, marlinAnalogInputToDigitalPin(TEMP_3_PIN),
642
       #if HOTENDS > 4
670
       #if HOTENDS > 4
643
         #undef _H4_PINS
671
         #undef _H4_PINS
644
-        #define _H4_PINS HEATER_4_PIN, analogInputToDigitalPin(TEMP_4_PIN),
672
+        #define _H4_PINS HEATER_4_PIN, marlinAnalogInputToDigitalPin(TEMP_4_PIN),
645
       #endif // HOTENDS > 4
673
       #endif // HOTENDS > 4
646
     #endif // HOTENDS > 3
674
     #endif // HOTENDS > 3
647
   #endif // HOTENDS > 2
675
   #endif // HOTENDS > 2
648
 #elif ENABLED(MIXING_EXTRUDER)
676
 #elif ENABLED(MIXING_EXTRUDER)
649
   #undef _E1_PINS
677
   #undef _E1_PINS
650
-  #define _E1_PINS E1_STEP_PIN, E1_DIR_PIN, E1_ENABLE_PIN, E1_MS1_PIN, E1_MS2_PIN,
678
+  #define _E1_PINS E1_STEP_PIN, E1_DIR_PIN, E1_ENABLE_PIN, E1_MS1_PIN, E1_MS2_PIN, E1_CS_PIN,
651
   #if MIXING_STEPPERS > 2
679
   #if MIXING_STEPPERS > 2
652
     #undef _E2_PINS
680
     #undef _E2_PINS
653
-    #define _E2_PINS E2_STEP_PIN, E2_DIR_PIN, E2_ENABLE_PIN, E2_MS1_PIN, E2_MS2_PIN,
681
+    #define _E2_PINS E2_STEP_PIN, E2_DIR_PIN, E2_ENABLE_PIN, E2_MS1_PIN, E2_MS2_PIN, E2_CS_PIN,
654
     #if MIXING_STEPPERS > 3
682
     #if MIXING_STEPPERS > 3
655
       #undef _E3_PINS
683
       #undef _E3_PINS
656
-      #define _E3_PINS E3_STEP_PIN, E3_DIR_PIN, E3_ENABLE_PIN, E3_MS1_PIN, E3_MS2_PIN,
684
+      #define _E3_PINS E3_STEP_PIN, E3_DIR_PIN, E3_ENABLE_PIN, E3_MS1_PIN, E3_MS2_PIN, E3_CS_PIN,
657
       #if MIXING_STEPPERS > 4
685
       #if MIXING_STEPPERS > 4
658
         #undef _E4_PINS
686
         #undef _E4_PINS
659
-        #define _E4_PINS E4_STEP_PIN, E4_DIR_PIN, E4_ENABLE_PIN, E4_MS1_PIN, E4_MS2_PIN,
687
+        #define _E4_PINS E4_STEP_PIN, E4_DIR_PIN, E4_ENABLE_PIN, E4_MS1_PIN, E4_MS2_PIN, E4_CS_PIN,
660
       #endif // MIXING_STEPPERS > 4
688
       #endif // MIXING_STEPPERS > 4
661
     #endif // MIXING_STEPPERS > 3
689
     #endif // MIXING_STEPPERS > 3
662
   #endif // MIXING_STEPPERS > 2
690
   #endif // MIXING_STEPPERS > 2
663
 #endif // MIXING_STEPPERS > 1
691
 #endif // MIXING_STEPPERS > 1
664
 
692
 
665
-#define BED_PINS HEATER_BED_PIN, analogInputToDigitalPin(TEMP_BED_PIN),
693
+#define BED_PINS HEATER_BED_PIN, marlinAnalogInputToDigitalPin(TEMP_BED_PIN),
666
 
694
 
667
 //
695
 //
668
 // Assign endstop pins for boards with only 3 connectors
696
 // Assign endstop pins for boards with only 3 connectors
765
     #define X2_STEP_PIN   _EPIN(E_STEPPERS, STEP)
793
     #define X2_STEP_PIN   _EPIN(E_STEPPERS, STEP)
766
     #define X2_DIR_PIN    _EPIN(E_STEPPERS, DIR)
794
     #define X2_DIR_PIN    _EPIN(E_STEPPERS, DIR)
767
     #define X2_ENABLE_PIN _EPIN(E_STEPPERS, ENABLE)
795
     #define X2_ENABLE_PIN _EPIN(E_STEPPERS, ENABLE)
796
+    #define X2_CS_PIN     _EPIN(E_STEPPERS, CS)
768
     #if E_STEPPERS > 4 || !PIN_EXISTS(X2_ENABLE)
797
     #if E_STEPPERS > 4 || !PIN_EXISTS(X2_ENABLE)
769
       #error "No E stepper plug left for X2!"
798
       #error "No E stepper plug left for X2!"
770
     #endif
799
     #endif
771
   #endif
800
   #endif
772
   #undef _X2_PINS
801
   #undef _X2_PINS
773
-  #define _X2_PINS X2_STEP_PIN, X2_DIR_PIN, X2_ENABLE_PIN,
802
+  #define _X2_PINS X2_STEP_PIN, X2_DIR_PIN, X2_ENABLE_PIN, X2_CS_PIN,
774
   #define Y2_E_INDEX INCREMENT(E_STEPPERS)
803
   #define Y2_E_INDEX INCREMENT(E_STEPPERS)
775
 #else
804
 #else
776
   #define Y2_E_INDEX E_STEPPERS
805
   #define Y2_E_INDEX E_STEPPERS
782
     #define Y2_STEP_PIN   _EPIN(Y2_E_INDEX, STEP)
811
     #define Y2_STEP_PIN   _EPIN(Y2_E_INDEX, STEP)
783
     #define Y2_DIR_PIN    _EPIN(Y2_E_INDEX, DIR)
812
     #define Y2_DIR_PIN    _EPIN(Y2_E_INDEX, DIR)
784
     #define Y2_ENABLE_PIN _EPIN(Y2_E_INDEX, ENABLE)
813
     #define Y2_ENABLE_PIN _EPIN(Y2_E_INDEX, ENABLE)
814
+    #define Y2_CS_PIN     _EPIN(Y2_E_INDEX, CS)
785
     #if Y2_E_INDEX > 4 || !PIN_EXISTS(Y2_ENABLE)
815
     #if Y2_E_INDEX > 4 || !PIN_EXISTS(Y2_ENABLE)
786
       #error "No E stepper plug left for Y2!"
816
       #error "No E stepper plug left for Y2!"
787
     #endif
817
     #endif
788
   #endif
818
   #endif
789
   #undef _Y2_PINS
819
   #undef _Y2_PINS
790
-  #define _Y2_PINS Y2_STEP_PIN, Y2_DIR_PIN, Y2_ENABLE_PIN,
820
+  #define _Y2_PINS Y2_STEP_PIN, Y2_DIR_PIN, Y2_ENABLE_PIN, Y2_CS_PIN,
791
   #define Z2_E_INDEX INCREMENT(Y2_E_INDEX)
821
   #define Z2_E_INDEX INCREMENT(Y2_E_INDEX)
792
 #else
822
 #else
793
   #define Z2_E_INDEX Y2_E_INDEX
823
   #define Z2_E_INDEX Y2_E_INDEX
799
     #define Z2_STEP_PIN   _EPIN(Z2_E_INDEX, STEP)
829
     #define Z2_STEP_PIN   _EPIN(Z2_E_INDEX, STEP)
800
     #define Z2_DIR_PIN    _EPIN(Z2_E_INDEX, DIR)
830
     #define Z2_DIR_PIN    _EPIN(Z2_E_INDEX, DIR)
801
     #define Z2_ENABLE_PIN _EPIN(Z2_E_INDEX, ENABLE)
831
     #define Z2_ENABLE_PIN _EPIN(Z2_E_INDEX, ENABLE)
832
+    #define Z2_CS_PIN     _EPIN(Z2_E_INDEX, CS)
802
     #if Z2_E_INDEX > 4 || !PIN_EXISTS(Z2_ENABLE)
833
     #if Z2_E_INDEX > 4 || !PIN_EXISTS(Z2_ENABLE)
803
       #error "No E stepper plug left for Z2!"
834
       #error "No E stepper plug left for Z2!"
804
     #endif
835
     #endif
805
   #endif
836
   #endif
806
   #undef _Z2_PINS
837
   #undef _Z2_PINS
807
-  #define _Z2_PINS Z2_STEP_PIN, Z2_DIR_PIN, Z2_ENABLE_PIN,
838
+  #define _Z2_PINS Z2_STEP_PIN, Z2_DIR_PIN, Z2_ENABLE_PIN, Z2_CS_PIN,
808
 #endif
839
 #endif
809
 
840
 
810
 #ifndef HAL_SENSITIVE_PINS
841
 #ifndef HAL_SENSITIVE_PINS
812
 #endif
843
 #endif
813
 
844
 
814
 #define SENSITIVE_PINS { \
845
 #define SENSITIVE_PINS { \
815
-    X_STEP_PIN, X_DIR_PIN, X_ENABLE_PIN, X_MIN_PIN, X_MAX_PIN, \
816
-    Y_STEP_PIN, Y_DIR_PIN, Y_ENABLE_PIN, Y_MIN_PIN, Y_MAX_PIN, \
817
-    Z_STEP_PIN, Z_DIR_PIN, Z_ENABLE_PIN, Z_MIN_PIN, Z_MAX_PIN, Z_MIN_PROBE_PIN, \
846
+    X_STEP_PIN, X_DIR_PIN, X_ENABLE_PIN, X_MIN_PIN, X_MAX_PIN, X_MS1_PIN, X_MS2_PIN, X_CS_PIN, \
847
+    Y_STEP_PIN, Y_DIR_PIN, Y_ENABLE_PIN, Y_MIN_PIN, Y_MAX_PIN, Y_MS1_PIN, Y_MS2_PIN, Y_CS_PIN, \
848
+    Z_STEP_PIN, Z_DIR_PIN, Z_ENABLE_PIN, Z_MIN_PIN, Z_MAX_PIN, Z_MS1_PIN, Z_MS2_PIN, Z_MS3_PIN, Z_CS_PIN, Z_MIN_PROBE_PIN, \
818
     PS_ON_PIN, HEATER_BED_PIN, FAN_PIN, FAN1_PIN, FAN2_PIN, CONTROLLER_FAN_PIN, \
849
     PS_ON_PIN, HEATER_BED_PIN, FAN_PIN, FAN1_PIN, FAN2_PIN, CONTROLLER_FAN_PIN, \
819
     _E0_PINS _E1_PINS _E2_PINS _E3_PINS _E4_PINS BED_PINS \
850
     _E0_PINS _E1_PINS _E2_PINS _E3_PINS _E4_PINS BED_PINS \
820
     _H0_PINS _H1_PINS _H2_PINS _H3_PINS _H4_PINS \
851
     _H0_PINS _H1_PINS _H2_PINS _H3_PINS _H4_PINS \
821
     _X2_PINS _Y2_PINS _Z2_PINS \
852
     _X2_PINS _Y2_PINS _Z2_PINS \
822
-    X_MS1_PIN, X_MS2_PIN, Y_MS1_PIN, Y_MS2_PIN, Z_MS1_PIN, Z_MS2_PIN, \
823
     HAL_SENSITIVE_PINS \
853
     HAL_SENSITIVE_PINS \
824
   }
854
   }
825
 
855
 

Loading…
Peruuta
Tallenna