Browse Source

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

Fixes #9211
Scott Lahteine 7 years ago
parent
commit
d385b9aac7
No account linked to committer's email address
1 changed files with 54 additions and 24 deletions
  1. 54
    24
      Marlin/src/pins/pins.h

+ 54
- 24
Marlin/src/pins/pins.h View File

@@ -464,6 +464,31 @@
464 464
   #define E4_ENABLE_PIN -1
465 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 492
 #ifndef FAN_PIN
468 493
   #define FAN_PIN -1
469 494
 #endif
@@ -591,7 +616,7 @@
591 616
 #endif
592 617
 
593 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 620
 #define _E1_PINS
596 621
 #define _E2_PINS
597 622
 #define _E3_PINS
@@ -601,30 +626,33 @@
601 626
                       // Tools 0 and 1 use E0
602 627
   #if EXTRUDERS > 2   // Tools 2 and 3 use E1
603 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 630
     #if EXTRUDERS > 4 // Tools 4 and 5 use E2
606 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 633
     #endif
609 634
   #endif
610 635
 #elif EXTRUDERS > 1
611 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 638
   #if EXTRUDERS > 2
614 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 641
     #if EXTRUDERS > 3
617 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 644
       #if EXTRUDERS > 4
620 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 647
       #endif // EXTRUDERS > 4
623 648
     #endif // EXTRUDERS > 3
624 649
   #endif // EXTRUDERS > 2
625 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 656
 #define _H1_PINS
629 657
 #define _H2_PINS
630 658
 #define _H3_PINS
@@ -632,37 +660,37 @@
632 660
 
633 661
 #if HOTENDS > 1
634 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 664
   #if HOTENDS > 2
637 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 667
     #if HOTENDS > 3
640 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 670
       #if HOTENDS > 4
643 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 673
       #endif // HOTENDS > 4
646 674
     #endif // HOTENDS > 3
647 675
   #endif // HOTENDS > 2
648 676
 #elif ENABLED(MIXING_EXTRUDER)
649 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 679
   #if MIXING_STEPPERS > 2
652 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 682
     #if MIXING_STEPPERS > 3
655 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 685
       #if MIXING_STEPPERS > 4
658 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 688
       #endif // MIXING_STEPPERS > 4
661 689
     #endif // MIXING_STEPPERS > 3
662 690
   #endif // MIXING_STEPPERS > 2
663 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 696
 // Assign endstop pins for boards with only 3 connectors
@@ -765,12 +793,13 @@
765 793
     #define X2_STEP_PIN   _EPIN(E_STEPPERS, STEP)
766 794
     #define X2_DIR_PIN    _EPIN(E_STEPPERS, DIR)
767 795
     #define X2_ENABLE_PIN _EPIN(E_STEPPERS, ENABLE)
796
+    #define X2_CS_PIN     _EPIN(E_STEPPERS, CS)
768 797
     #if E_STEPPERS > 4 || !PIN_EXISTS(X2_ENABLE)
769 798
       #error "No E stepper plug left for X2!"
770 799
     #endif
771 800
   #endif
772 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 803
   #define Y2_E_INDEX INCREMENT(E_STEPPERS)
775 804
 #else
776 805
   #define Y2_E_INDEX E_STEPPERS
@@ -782,12 +811,13 @@
782 811
     #define Y2_STEP_PIN   _EPIN(Y2_E_INDEX, STEP)
783 812
     #define Y2_DIR_PIN    _EPIN(Y2_E_INDEX, DIR)
784 813
     #define Y2_ENABLE_PIN _EPIN(Y2_E_INDEX, ENABLE)
814
+    #define Y2_CS_PIN     _EPIN(Y2_E_INDEX, CS)
785 815
     #if Y2_E_INDEX > 4 || !PIN_EXISTS(Y2_ENABLE)
786 816
       #error "No E stepper plug left for Y2!"
787 817
     #endif
788 818
   #endif
789 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 821
   #define Z2_E_INDEX INCREMENT(Y2_E_INDEX)
792 822
 #else
793 823
   #define Z2_E_INDEX Y2_E_INDEX
@@ -799,12 +829,13 @@
799 829
     #define Z2_STEP_PIN   _EPIN(Z2_E_INDEX, STEP)
800 830
     #define Z2_DIR_PIN    _EPIN(Z2_E_INDEX, DIR)
801 831
     #define Z2_ENABLE_PIN _EPIN(Z2_E_INDEX, ENABLE)
832
+    #define Z2_CS_PIN     _EPIN(Z2_E_INDEX, CS)
802 833
     #if Z2_E_INDEX > 4 || !PIN_EXISTS(Z2_ENABLE)
803 834
       #error "No E stepper plug left for Z2!"
804 835
     #endif
805 836
   #endif
806 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 839
 #endif
809 840
 
810 841
 #ifndef HAL_SENSITIVE_PINS
@@ -812,14 +843,13 @@
812 843
 #endif
813 844
 
814 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 849
     PS_ON_PIN, HEATER_BED_PIN, FAN_PIN, FAN1_PIN, FAN2_PIN, CONTROLLER_FAN_PIN, \
819 850
     _E0_PINS _E1_PINS _E2_PINS _E3_PINS _E4_PINS BED_PINS \
820 851
     _H0_PINS _H1_PINS _H2_PINS _H3_PINS _H4_PINS \
821 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 853
     HAL_SENSITIVE_PINS \
824 854
   }
825 855
 

Loading…
Cancel
Save