Browse Source

Overridable Options - Part 8 (PR#2560)

Apply `ENABLED` / `DISABLED` macros to stepper-related files.
Scott Lahteine 9 years ago
parent
commit
c35fb88094
4 changed files with 149 additions and 149 deletions
  1. 47
    47
      Marlin/stepper.cpp
  2. 4
    4
      Marlin/stepper.h
  3. 76
    76
      Marlin/stepper_indirection.cpp
  4. 22
    22
      Marlin/stepper_indirection.h

+ 47
- 47
Marlin/stepper.cpp View File

49
 static unsigned char out_bits = 0;        // The next stepping-bits to be output
49
 static unsigned char out_bits = 0;        // The next stepping-bits to be output
50
 static unsigned int cleaning_buffer_counter;
50
 static unsigned int cleaning_buffer_counter;
51
 
51
 
52
-#ifdef Z_DUAL_ENDSTOPS
52
+#if ENABLED(Z_DUAL_ENDSTOPS)
53
   static bool performing_homing = false, 
53
   static bool performing_homing = false, 
54
               locked_z_motor = false, 
54
               locked_z_motor = false, 
55
               locked_z2_motor = false;
55
               locked_z2_motor = false;
59
 static long counter_x, counter_y, counter_z, counter_e;
59
 static long counter_x, counter_y, counter_z, counter_e;
60
 volatile static unsigned long step_events_completed; // The number of step events executed in the current block
60
 volatile static unsigned long step_events_completed; // The number of step events executed in the current block
61
 
61
 
62
-#ifdef ADVANCE
62
+#if ENABLED(ADVANCE)
63
   static long advance_rate, advance, final_advance = 0;
63
   static long advance_rate, advance, final_advance = 0;
64
   static long old_advance = 0;
64
   static long old_advance = 0;
65
   static long e_steps[4];
65
   static long e_steps[4];
76
 volatile long endstops_stepsTotal, endstops_stepsDone;
76
 volatile long endstops_stepsTotal, endstops_stepsDone;
77
 static volatile char endstop_hit_bits = 0; // use X_MIN, Y_MIN, Z_MIN and Z_PROBE as BIT value
77
 static volatile char endstop_hit_bits = 0; // use X_MIN, Y_MIN, Z_MIN and Z_PROBE as BIT value
78
 
78
 
79
-#ifndef Z_DUAL_ENDSTOPS
79
+#if DISABLED(Z_DUAL_ENDSTOPS)
80
   static byte
80
   static byte
81
 #else
81
 #else
82
   static uint16_t
82
   static uint16_t
83
 #endif
83
 #endif
84
   old_endstop_bits = 0; // use X_MIN, X_MAX... Z_MAX, Z_PROBE, Z2_MIN, Z2_MAX
84
   old_endstop_bits = 0; // use X_MIN, X_MAX... Z_MAX, Z_PROBE, Z2_MIN, Z2_MAX
85
 
85
 
86
-#ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
86
+#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
87
   bool abort_on_endstop_hit = false;
87
   bool abort_on_endstop_hit = false;
88
 #endif
88
 #endif
89
 
89
 
90
-#ifdef MOTOR_CURRENT_PWM_XY_PIN
90
+#if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
91
   int motor_current_setting[3] = DEFAULT_PWM_MOTOR_CURRENT;
91
   int motor_current_setting[3] = DEFAULT_PWM_MOTOR_CURRENT;
92
 #endif
92
 #endif
93
 
93
 
101
 //================================ functions ================================
101
 //================================ functions ================================
102
 //===========================================================================
102
 //===========================================================================
103
 
103
 
104
-#ifdef DUAL_X_CARRIAGE
104
+#if ENABLED(DUAL_X_CARRIAGE)
105
   #define X_APPLY_DIR(v,ALWAYS) \
105
   #define X_APPLY_DIR(v,ALWAYS) \
106
     if (extruder_duplication_enabled || ALWAYS) { \
106
     if (extruder_duplication_enabled || ALWAYS) { \
107
       X_DIR_WRITE(v); \
107
       X_DIR_WRITE(v); \
123
   #define X_APPLY_STEP(v,Q) X_STEP_WRITE(v)
123
   #define X_APPLY_STEP(v,Q) X_STEP_WRITE(v)
124
 #endif
124
 #endif
125
 
125
 
126
-#ifdef Y_DUAL_STEPPER_DRIVERS
126
+#if ENABLED(Y_DUAL_STEPPER_DRIVERS)
127
   #define Y_APPLY_DIR(v,Q) { Y_DIR_WRITE(v); Y2_DIR_WRITE((v) != INVERT_Y2_VS_Y_DIR); }
127
   #define Y_APPLY_DIR(v,Q) { Y_DIR_WRITE(v); Y2_DIR_WRITE((v) != INVERT_Y2_VS_Y_DIR); }
128
   #define Y_APPLY_STEP(v,Q) { Y_STEP_WRITE(v); Y2_STEP_WRITE(v); }
128
   #define Y_APPLY_STEP(v,Q) { Y_STEP_WRITE(v); Y2_STEP_WRITE(v); }
129
 #else
129
 #else
131
   #define Y_APPLY_STEP(v,Q) Y_STEP_WRITE(v)
131
   #define Y_APPLY_STEP(v,Q) Y_STEP_WRITE(v)
132
 #endif
132
 #endif
133
 
133
 
134
-#ifdef Z_DUAL_STEPPER_DRIVERS
134
+#if ENABLED(Z_DUAL_STEPPER_DRIVERS)
135
   #define Z_APPLY_DIR(v,Q) { Z_DIR_WRITE(v); Z2_DIR_WRITE(v); }
135
   #define Z_APPLY_DIR(v,Q) { Z_DIR_WRITE(v); Z2_DIR_WRITE(v); }
136
-  #ifdef Z_DUAL_ENDSTOPS
136
+  #if ENABLED(Z_DUAL_ENDSTOPS)
137
     #define Z_APPLY_STEP(v,Q) \
137
     #define Z_APPLY_STEP(v,Q) \
138
     if (performing_homing) { \
138
     if (performing_homing) { \
139
       if (Z_HOME_DIR > 0) {\
139
       if (Z_HOME_DIR > 0) {\
263
       SERIAL_ECHOPAIR(" Z:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
263
       SERIAL_ECHOPAIR(" Z:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
264
       LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "Z");
264
       LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "Z");
265
     }
265
     }
266
-    #ifdef Z_PROBE_ENDSTOP
267
-    if (endstop_hit_bits & BIT(Z_PROBE)) {
268
-      SERIAL_ECHOPAIR(" Z_PROBE:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
269
-      LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "ZP");
270
-    }
266
+    #if ENABLED(Z_PROBE_ENDSTOP)
267
+      if (endstop_hit_bits & BIT(Z_PROBE)) {
268
+        SERIAL_ECHOPAIR(" Z_PROBE:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
269
+        LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "ZP");
270
+      }
271
     #endif
271
     #endif
272
     SERIAL_EOL;
272
     SERIAL_EOL;
273
 
273
 
274
     endstops_hit_on_purpose();
274
     endstops_hit_on_purpose();
275
 
275
 
276
-    #if defined(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) && defined(SDSUPPORT)
276
+    #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) && ENABLED(SDSUPPORT)
277
       if (abort_on_endstop_hit) {
277
       if (abort_on_endstop_hit) {
278
         card.sdprinting = false;
278
         card.sdprinting = false;
279
         card.closefile();
279
         card.closefile();
556
     count_direction[Z_AXIS] = 1;
556
     count_direction[Z_AXIS] = 1;
557
   }
557
   }
558
   
558
   
559
-  #ifndef ADVANCE
559
+  #if DISABLED(ADVANCE)
560
     if (TEST(out_bits, E_AXIS)) {
560
     if (TEST(out_bits, E_AXIS)) {
561
       REV_E_DIR();
561
       REV_E_DIR();
562
       count_direction[E_AXIS] = -1;
562
       count_direction[E_AXIS] = -1;
577
     set_stepper_direction();
577
     set_stepper_direction();
578
   }
578
   }
579
   
579
   
580
-  #ifdef ADVANCE
580
+  #if ENABLED(ADVANCE)
581
     advance = current_block->initial_advance;
581
     advance = current_block->initial_advance;
582
     final_advance = current_block->final_advance;
582
     final_advance = current_block->final_advance;
583
     // Do E steps + advance steps
583
     // Do E steps + advance steps
630
       counter_y = counter_z = counter_e = counter_x;
630
       counter_y = counter_z = counter_e = counter_x;
631
       step_events_completed = 0;
631
       step_events_completed = 0;
632
 
632
 
633
-      #ifdef Z_LATE_ENABLE
633
+      #if ENABLED(Z_LATE_ENABLE)
634
         if (current_block->steps[Z_AXIS] > 0) {
634
         if (current_block->steps[Z_AXIS] > 0) {
635
           enable_z();
635
           enable_z();
636
           OCR1A = 2000; //1ms wait
636
           OCR1A = 2000; //1ms wait
638
         }
638
         }
639
       #endif
639
       #endif
640
 
640
 
641
-      // #ifdef ADVANCE
641
+      // #if ENABLED(ADVANCE)
642
       //   e_steps[current_block->active_extruder] = 0;
642
       //   e_steps[current_block->active_extruder] = 0;
643
       // #endif
643
       // #endif
644
     }
644
     }
658
         MSerial.checkRx(); // Check for serial chars.
658
         MSerial.checkRx(); // Check for serial chars.
659
       #endif
659
       #endif
660
 
660
 
661
-      #ifdef ADVANCE
661
+      #if ENABLED(ADVANCE)
662
         counter_e += current_block->steps[E_AXIS];
662
         counter_e += current_block->steps[E_AXIS];
663
         if (counter_e > 0) {
663
         if (counter_e > 0) {
664
           counter_e -= current_block->step_event_count;
664
           counter_e -= current_block->step_event_count;
677
       STEP_ADD(x,X);
677
       STEP_ADD(x,X);
678
       STEP_ADD(y,Y);
678
       STEP_ADD(y,Y);
679
       STEP_ADD(z,Z);
679
       STEP_ADD(z,Z);
680
-      #ifndef ADVANCE
680
+      #if DISABLED(ADVANCE)
681
         STEP_ADD(e,E);
681
         STEP_ADD(e,E);
682
       #endif
682
       #endif
683
 
683
 
691
       STEP_IF_COUNTER(x, X);
691
       STEP_IF_COUNTER(x, X);
692
       STEP_IF_COUNTER(y, Y);
692
       STEP_IF_COUNTER(y, Y);
693
       STEP_IF_COUNTER(z, Z);
693
       STEP_IF_COUNTER(z, Z);
694
-      #ifndef ADVANCE
694
+      #if DISABLED(ADVANCE)
695
         STEP_IF_COUNTER(e, E);
695
         STEP_IF_COUNTER(e, E);
696
       #endif
696
       #endif
697
 
697
 
714
       timer = calc_timer(acc_step_rate);
714
       timer = calc_timer(acc_step_rate);
715
       OCR1A = timer;
715
       OCR1A = timer;
716
       acceleration_time += timer;
716
       acceleration_time += timer;
717
-      #ifdef ADVANCE
717
+      #if ENABLED(ADVANCE)
718
         for(int8_t i=0; i < step_loops; i++) {
718
         for(int8_t i=0; i < step_loops; i++) {
719
           advance += advance_rate;
719
           advance += advance_rate;
720
         }
720
         }
743
       timer = calc_timer(step_rate);
743
       timer = calc_timer(step_rate);
744
       OCR1A = timer;
744
       OCR1A = timer;
745
       deceleration_time += timer;
745
       deceleration_time += timer;
746
-      #ifdef ADVANCE
746
+      #if ENABLED(ADVANCE)
747
         for(int8_t i=0; i < step_loops; i++) {
747
         for(int8_t i=0; i < step_loops; i++) {
748
           advance -= advance_rate;
748
           advance -= advance_rate;
749
         }
749
         }
767
   }
767
   }
768
 }
768
 }
769
 
769
 
770
-#ifdef ADVANCE
770
+#if ENABLED(ADVANCE)
771
   unsigned char old_OCR0A;
771
   unsigned char old_OCR0A;
772
   // Timer interrupt for E. e_steps is set in the main routine;
772
   // Timer interrupt for E. e_steps is set in the main routine;
773
   // Timer 0 is shared with millies
773
   // Timer 0 is shared with millies
845
   microstep_init(); //Initialize Microstepping Pins
845
   microstep_init(); //Initialize Microstepping Pins
846
 
846
 
847
   // initialise TMC Steppers
847
   // initialise TMC Steppers
848
-  #ifdef HAVE_TMCDRIVER
848
+  #if ENABLED(HAVE_TMCDRIVER)
849
     tmc_init();
849
     tmc_init();
850
   #endif
850
   #endif
851
     // initialise L6470 Steppers
851
     // initialise L6470 Steppers
852
-  #ifdef HAVE_L6470DRIVER
852
+  #if ENABLED(HAVE_L6470DRIVER)
853
     L6470_init();
853
     L6470_init();
854
   #endif
854
   #endif
855
 
855
 
862
   #endif
862
   #endif
863
   #if HAS_Y_DIR
863
   #if HAS_Y_DIR
864
     Y_DIR_INIT;
864
     Y_DIR_INIT;
865
-    #if defined(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_DIR
865
+    #if ENABLED(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_DIR
866
       Y2_DIR_INIT;
866
       Y2_DIR_INIT;
867
     #endif
867
     #endif
868
   #endif
868
   #endif
869
   #if HAS_Z_DIR
869
   #if HAS_Z_DIR
870
     Z_DIR_INIT;
870
     Z_DIR_INIT;
871
-    #if defined(Z_DUAL_STEPPER_DRIVERS) && HAS_Z2_DIR
871
+    #if ENABLED(Z_DUAL_STEPPER_DRIVERS) && HAS_Z2_DIR
872
       Z2_DIR_INIT;
872
       Z2_DIR_INIT;
873
     #endif
873
     #endif
874
   #endif
874
   #endif
899
     Y_ENABLE_INIT;
899
     Y_ENABLE_INIT;
900
     if (!Y_ENABLE_ON) Y_ENABLE_WRITE(HIGH);
900
     if (!Y_ENABLE_ON) Y_ENABLE_WRITE(HIGH);
901
 
901
 
902
-  #if defined(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_ENABLE
902
+  #if ENABLED(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_ENABLE
903
     Y2_ENABLE_INIT;
903
     Y2_ENABLE_INIT;
904
     if (!Y_ENABLE_ON) Y2_ENABLE_WRITE(HIGH);
904
     if (!Y_ENABLE_ON) Y2_ENABLE_WRITE(HIGH);
905
   #endif
905
   #endif
908
     Z_ENABLE_INIT;
908
     Z_ENABLE_INIT;
909
     if (!Z_ENABLE_ON) Z_ENABLE_WRITE(HIGH);
909
     if (!Z_ENABLE_ON) Z_ENABLE_WRITE(HIGH);
910
 
910
 
911
-    #if defined(Z_DUAL_STEPPER_DRIVERS) && HAS_Z2_ENABLE
911
+    #if ENABLED(Z_DUAL_STEPPER_DRIVERS) && HAS_Z2_ENABLE
912
       Z2_ENABLE_INIT;
912
       Z2_ENABLE_INIT;
913
       if (!Z_ENABLE_ON) Z2_ENABLE_WRITE(HIGH);
913
       if (!Z_ENABLE_ON) Z2_ENABLE_WRITE(HIGH);
914
     #endif
914
     #endif
934
 
934
 
935
   #if HAS_X_MIN
935
   #if HAS_X_MIN
936
     SET_INPUT(X_MIN_PIN);
936
     SET_INPUT(X_MIN_PIN);
937
-    #ifdef ENDSTOPPULLUP_XMIN
937
+    #if ENABLED(ENDSTOPPULLUP_XMIN)
938
       WRITE(X_MIN_PIN,HIGH);
938
       WRITE(X_MIN_PIN,HIGH);
939
     #endif
939
     #endif
940
   #endif
940
   #endif
941
 
941
 
942
   #if HAS_Y_MIN
942
   #if HAS_Y_MIN
943
     SET_INPUT(Y_MIN_PIN);
943
     SET_INPUT(Y_MIN_PIN);
944
-    #ifdef ENDSTOPPULLUP_YMIN
944
+    #if ENABLED(ENDSTOPPULLUP_YMIN)
945
       WRITE(Y_MIN_PIN,HIGH);
945
       WRITE(Y_MIN_PIN,HIGH);
946
     #endif
946
     #endif
947
   #endif
947
   #endif
948
 
948
 
949
   #if HAS_Z_MIN
949
   #if HAS_Z_MIN
950
     SET_INPUT(Z_MIN_PIN);
950
     SET_INPUT(Z_MIN_PIN);
951
-    #ifdef ENDSTOPPULLUP_ZMIN
951
+    #if ENABLED(ENDSTOPPULLUP_ZMIN)
952
       WRITE(Z_MIN_PIN,HIGH);
952
       WRITE(Z_MIN_PIN,HIGH);
953
     #endif
953
     #endif
954
   #endif
954
   #endif
955
 
955
 
956
   #if HAS_X_MAX
956
   #if HAS_X_MAX
957
     SET_INPUT(X_MAX_PIN);
957
     SET_INPUT(X_MAX_PIN);
958
-    #ifdef ENDSTOPPULLUP_XMAX
958
+    #if ENABLED(ENDSTOPPULLUP_XMAX)
959
       WRITE(X_MAX_PIN,HIGH);
959
       WRITE(X_MAX_PIN,HIGH);
960
     #endif
960
     #endif
961
   #endif
961
   #endif
962
 
962
 
963
   #if HAS_Y_MAX
963
   #if HAS_Y_MAX
964
     SET_INPUT(Y_MAX_PIN);
964
     SET_INPUT(Y_MAX_PIN);
965
-    #ifdef ENDSTOPPULLUP_YMAX
965
+    #if ENABLED(ENDSTOPPULLUP_YMAX)
966
       WRITE(Y_MAX_PIN,HIGH);
966
       WRITE(Y_MAX_PIN,HIGH);
967
     #endif
967
     #endif
968
   #endif
968
   #endif
969
 
969
 
970
   #if HAS_Z_MAX
970
   #if HAS_Z_MAX
971
     SET_INPUT(Z_MAX_PIN);
971
     SET_INPUT(Z_MAX_PIN);
972
-    #ifdef ENDSTOPPULLUP_ZMAX
972
+    #if ENABLED(ENDSTOPPULLUP_ZMAX)
973
       WRITE(Z_MAX_PIN,HIGH);
973
       WRITE(Z_MAX_PIN,HIGH);
974
     #endif
974
     #endif
975
   #endif
975
   #endif
976
 
976
 
977
   #if HAS_Z2_MAX
977
   #if HAS_Z2_MAX
978
     SET_INPUT(Z2_MAX_PIN);
978
     SET_INPUT(Z2_MAX_PIN);
979
-    #ifdef ENDSTOPPULLUP_ZMAX
979
+    #if ENABLED(ENDSTOPPULLUP_ZMAX)
980
       WRITE(Z2_MAX_PIN,HIGH);
980
       WRITE(Z2_MAX_PIN,HIGH);
981
     #endif
981
     #endif
982
   #endif
982
   #endif
983
 
983
 
984
-  #if (defined(Z_PROBE_PIN) && Z_PROBE_PIN >= 0) && defined(Z_PROBE_ENDSTOP) // Check for Z_PROBE_ENDSTOP so we don't pull a pin high unless it's to be used.
984
+  #if HAS_Z_PROBE && ENABLED(Z_PROBE_ENDSTOP) // Check for Z_PROBE_ENDSTOP so we don't pull a pin high unless it's to be used.
985
     SET_INPUT(Z_PROBE_PIN);
985
     SET_INPUT(Z_PROBE_PIN);
986
-    #ifdef ENDSTOPPULLUP_ZPROBE
986
+    #if ENABLED(ENDSTOPPULLUP_ZPROBE)
987
       WRITE(Z_PROBE_PIN,HIGH);
987
       WRITE(Z_PROBE_PIN,HIGH);
988
     #endif
988
     #endif
989
   #endif
989
   #endif
1007
     AXIS_INIT(x, X2, X);
1007
     AXIS_INIT(x, X2, X);
1008
   #endif
1008
   #endif
1009
   #if HAS_Y_STEP
1009
   #if HAS_Y_STEP
1010
-    #if defined(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_STEP
1010
+    #if ENABLED(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_STEP
1011
       Y2_STEP_INIT;
1011
       Y2_STEP_INIT;
1012
       Y2_STEP_WRITE(INVERT_Y_STEP_PIN);
1012
       Y2_STEP_WRITE(INVERT_Y_STEP_PIN);
1013
     #endif
1013
     #endif
1014
     AXIS_INIT(y, Y, Y);
1014
     AXIS_INIT(y, Y, Y);
1015
   #endif
1015
   #endif
1016
   #if HAS_Z_STEP
1016
   #if HAS_Z_STEP
1017
-    #if defined(Z_DUAL_STEPPER_DRIVERS) && HAS_Z2_STEP
1017
+    #if ENABLED(Z_DUAL_STEPPER_DRIVERS) && HAS_Z2_STEP
1018
       Z2_STEP_INIT;
1018
       Z2_STEP_INIT;
1019
       Z2_STEP_WRITE(INVERT_Z_STEP_PIN);
1019
       Z2_STEP_WRITE(INVERT_Z_STEP_PIN);
1020
     #endif
1020
     #endif
1054
   TCNT1 = 0;
1054
   TCNT1 = 0;
1055
   ENABLE_STEPPER_DRIVER_INTERRUPT();
1055
   ENABLE_STEPPER_DRIVER_INTERRUPT();
1056
 
1056
 
1057
-  #ifdef ADVANCE
1057
+  #if ENABLED(ADVANCE)
1058
     #if defined(TCCR0A) && defined(WGM01)
1058
     #if defined(TCCR0A) && defined(WGM01)
1059
       TCCR0A &= ~BIT(WGM01);
1059
       TCCR0A &= ~BIT(WGM01);
1060
       TCCR0A &= ~BIT(WGM00);
1060
       TCCR0A &= ~BIT(WGM00);
1113
   ENABLE_STEPPER_DRIVER_INTERRUPT();
1113
   ENABLE_STEPPER_DRIVER_INTERRUPT();
1114
 }
1114
 }
1115
 
1115
 
1116
-#ifdef BABYSTEPPING
1116
+#if ENABLED(BABYSTEPPING)
1117
 
1117
 
1118
   // MUST ONLY BE CALLED BY AN ISR,
1118
   // MUST ONLY BE CALLED BY AN ISR,
1119
   // No other ISR should ever interrupt this!
1119
   // No other ISR should ever interrupt this!
1146
  
1146
  
1147
       case Z_AXIS: {
1147
       case Z_AXIS: {
1148
 
1148
 
1149
-        #ifndef DELTA
1149
+        #if DISABLED(DELTA)
1150
 
1150
 
1151
           BABYSTEP_AXIS(z, Z, BABYSTEP_INVERT_Z);
1151
           BABYSTEP_AXIS(z, Z, BABYSTEP_INVERT_Z);
1152
 
1152
 
1272
     case 1: digitalWrite(Y_MS2_PIN, ms2); break;
1272
     case 1: digitalWrite(Y_MS2_PIN, ms2); break;
1273
     case 2: digitalWrite(Z_MS2_PIN, ms2); break;
1273
     case 2: digitalWrite(Z_MS2_PIN, ms2); break;
1274
     case 3: digitalWrite(E0_MS2_PIN, ms2); break;
1274
     case 3: digitalWrite(E0_MS2_PIN, ms2); break;
1275
-    #if defined(E1_MS2_PIN) && E1_MS2_PIN >= 0
1275
+    #if PIN_EXISTS(E1_MS2)
1276
       case 4: digitalWrite(E1_MS2_PIN, ms2); break;
1276
       case 4: digitalWrite(E1_MS2_PIN, ms2); break;
1277
     #endif
1277
     #endif
1278
   }
1278
   }
1309
   #endif
1309
   #endif
1310
 }
1310
 }
1311
 
1311
 
1312
-#ifdef Z_DUAL_ENDSTOPS
1312
+#if ENABLED(Z_DUAL_ENDSTOPS)
1313
   void In_Homing_Process(bool state) { performing_homing = state; }
1313
   void In_Homing_Process(bool state) { performing_homing = state; }
1314
   void Lock_z_motor(bool state) { locked_z_motor = state; }
1314
   void Lock_z_motor(bool state) { locked_z_motor = state; }
1315
   void Lock_z2_motor(bool state) { locked_z2_motor = state; }
1315
   void Lock_z2_motor(bool state) { locked_z2_motor = state; }

+ 4
- 4
Marlin/stepper.h View File

33
   #define NORM_E_DIR() { if(current_block->active_extruder == 2) { E2_DIR_WRITE(!INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}}
33
   #define NORM_E_DIR() { if(current_block->active_extruder == 2) { E2_DIR_WRITE(!INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}}
34
   #define REV_E_DIR() { if(current_block->active_extruder == 2) { E2_DIR_WRITE(INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}}
34
   #define REV_E_DIR() { if(current_block->active_extruder == 2) { E2_DIR_WRITE(INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}}
35
 #elif EXTRUDERS > 1
35
 #elif EXTRUDERS > 1
36
-  #ifndef DUAL_X_CARRIAGE
36
+  #if DISABLED(DUAL_X_CARRIAGE)
37
     #define E_STEP_WRITE(v) { if(current_block->active_extruder == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}
37
     #define E_STEP_WRITE(v) { if(current_block->active_extruder == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}
38
     #define NORM_E_DIR() { if(current_block->active_extruder == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}
38
     #define NORM_E_DIR() { if(current_block->active_extruder == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}
39
     #define REV_E_DIR() { if(current_block->active_extruder == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}
39
     #define REV_E_DIR() { if(current_block->active_extruder == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}
49
   #define REV_E_DIR() E0_DIR_WRITE(INVERT_E0_DIR)
49
   #define REV_E_DIR() E0_DIR_WRITE(INVERT_E0_DIR)
50
 #endif
50
 #endif
51
 
51
 
52
-#ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
52
+#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
53
   extern bool abort_on_endstop_hit;
53
   extern bool abort_on_endstop_hit;
54
 #endif
54
 #endif
55
 
55
 
95
 void microstep_init();
95
 void microstep_init();
96
 void microstep_readings();
96
 void microstep_readings();
97
 
97
 
98
-#ifdef Z_DUAL_ENDSTOPS
98
+#if ENABLED(Z_DUAL_ENDSTOPS)
99
   void In_Homing_Process(bool state);
99
   void In_Homing_Process(bool state);
100
   void Lock_z_motor(bool state);
100
   void Lock_z_motor(bool state);
101
   void Lock_z2_motor(bool state);
101
   void Lock_z2_motor(bool state);
102
 #endif
102
 #endif
103
 
103
 
104
-#ifdef BABYSTEPPING
104
+#if ENABLED(BABYSTEPPING)
105
   void babystep(const uint8_t axis,const bool direction); // perform a short step with a single stepper motor, outside of any convention
105
   void babystep(const uint8_t axis,const bool direction); // perform a short step with a single stepper motor, outside of any convention
106
 #endif
106
 #endif
107
      
107
      

+ 76
- 76
Marlin/stepper_indirection.cpp View File

22
 #include "stepper_indirection.h"
22
 #include "stepper_indirection.h"
23
 #include "Configuration.h"
23
 #include "Configuration.h"
24
 
24
 
25
-#ifdef HAVE_TMCDRIVER
26
-#include <SPI.h>
27
-#include <TMC26XStepper.h>
25
+#if ENABLED(HAVE_TMCDRIVER)
26
+  #include <SPI.h>
27
+  #include <TMC26XStepper.h>
28
 #endif
28
 #endif
29
 
29
 
30
 // Stepper objects of TMC steppers used
30
 // Stepper objects of TMC steppers used
31
-#ifdef X_IS_TMC
31
+#if ENABLED(X_IS_TMC)
32
 	TMC26XStepper stepperX(200,X_ENABLE_PIN,X_STEP_PIN,X_DIR_PIN,X_MAX_CURRENT,X_SENSE_RESISTOR);
32
 	TMC26XStepper stepperX(200,X_ENABLE_PIN,X_STEP_PIN,X_DIR_PIN,X_MAX_CURRENT,X_SENSE_RESISTOR);
33
 #endif
33
 #endif
34
-#ifdef X2_IS_TMC
34
+#if ENABLED(X2_IS_TMC)
35
 	TMC26XStepper stepperX2(200,X2_ENABLE_PIN,X2_STEP_PIN,X2_DIR_PIN,X2_MAX_CURRENT,X2_SENSE_RESISTOR);
35
 	TMC26XStepper stepperX2(200,X2_ENABLE_PIN,X2_STEP_PIN,X2_DIR_PIN,X2_MAX_CURRENT,X2_SENSE_RESISTOR);
36
 #endif
36
 #endif
37
-#ifdef Y_IS_TMC
37
+#if ENABLED(Y_IS_TMC)
38
 	TMC26XStepper stepperY(200,Y_ENABLE_PIN,Y_STEP_PIN,Y_DIR_PIN,Y_MAX_CURRENT,Y_SENSE_RESISTOR);
38
 	TMC26XStepper stepperY(200,Y_ENABLE_PIN,Y_STEP_PIN,Y_DIR_PIN,Y_MAX_CURRENT,Y_SENSE_RESISTOR);
39
 #endif
39
 #endif
40
-#ifdef Y2_IS_TMC
40
+#if ENABLED(Y2_IS_TMC)
41
 	TMC26XStepper stepperY2(200,Y2_ENABLE_PIN,Y2_STEP_PIN,Y2_DIR_PIN,Y2_MAX_CURRENT,Y2_SENSE_RESISTOR);
41
 	TMC26XStepper stepperY2(200,Y2_ENABLE_PIN,Y2_STEP_PIN,Y2_DIR_PIN,Y2_MAX_CURRENT,Y2_SENSE_RESISTOR);
42
 #endif
42
 #endif
43
-#ifdef Z_IS_TMC
43
+#if ENABLED(Z_IS_TMC)
44
 	TMC26XStepper stepperZ(200,Z_ENABLE_PIN,Z_STEP_PIN,Z_DIR_PIN,Z_MAX_CURRENT,Z_SENSE_RESISTOR);
44
 	TMC26XStepper stepperZ(200,Z_ENABLE_PIN,Z_STEP_PIN,Z_DIR_PIN,Z_MAX_CURRENT,Z_SENSE_RESISTOR);
45
 #endif
45
 #endif
46
-#ifdef Z2_IS_TMC
46
+#if ENABLED(Z2_IS_TMC)
47
 	TMC26XStepper stepperZ2(200,Z2_ENABLE_PIN,Z2_STEP_PIN,Z2_DIR_PIN,Z2_MAX_CURRENT,Z2_SENSE_RESISTOR);
47
 	TMC26XStepper stepperZ2(200,Z2_ENABLE_PIN,Z2_STEP_PIN,Z2_DIR_PIN,Z2_MAX_CURRENT,Z2_SENSE_RESISTOR);
48
 #endif
48
 #endif
49
-#ifdef E0_IS_TMC
49
+#if ENABLED(E0_IS_TMC)
50
 	TMC26XStepper stepperE0(200,E0_ENABLE_PIN,E0_STEP_PIN,E0_DIR_PIN,E0_MAX_CURRENT,E0_SENSE_RESISTOR);
50
 	TMC26XStepper stepperE0(200,E0_ENABLE_PIN,E0_STEP_PIN,E0_DIR_PIN,E0_MAX_CURRENT,E0_SENSE_RESISTOR);
51
 #endif
51
 #endif
52
-#ifdef E1_IS_TMC
52
+#if ENABLED(E1_IS_TMC)
53
 	TMC26XStepper stepperE1(200,E1_ENABLE_PIN,E1_STEP_PIN,E1_DIR_PIN,E1_MAX_CURRENT,E1_SENSE_RESISTOR);
53
 	TMC26XStepper stepperE1(200,E1_ENABLE_PIN,E1_STEP_PIN,E1_DIR_PIN,E1_MAX_CURRENT,E1_SENSE_RESISTOR);
54
 #endif
54
 #endif
55
-#ifdef E2_IS_TMC
55
+#if ENABLED(E2_IS_TMC)
56
 	TMC26XStepper stepperE2(200,E2_ENABLE_PIN,E2_STEP_PIN,E2_DIR_PIN,E2_MAX_CURRENT,E2_SENSE_RESISTOR);
56
 	TMC26XStepper stepperE2(200,E2_ENABLE_PIN,E2_STEP_PIN,E2_DIR_PIN,E2_MAX_CURRENT,E2_SENSE_RESISTOR);
57
 #endif
57
 #endif
58
-#ifdef E3_IS_TMC
58
+#if ENABLED(E3_IS_TMC)
59
 	TMC26XStepper stepperE3(200,E3_ENABLE_PIN,E3_STEP_PIN,E3_DIR_PIN,E3_MAX_CURRENT,E3_SENSE_RESISTOR);
59
 	TMC26XStepper stepperE3(200,E3_ENABLE_PIN,E3_STEP_PIN,E3_DIR_PIN,E3_MAX_CURRENT,E3_SENSE_RESISTOR);
60
 #endif	
60
 #endif	
61
 
61
 
62
-#ifdef HAVE_TMCDRIVER
62
+#if ENABLED(HAVE_TMCDRIVER)
63
 void tmc_init()
63
 void tmc_init()
64
 {
64
 {
65
-#ifdef X_IS_TMC
65
+  #if ENABLED(X_IS_TMC)
66
 	stepperX.setMicrosteps(X_MICROSTEPS);
66
 	stepperX.setMicrosteps(X_MICROSTEPS);
67
 	stepperX.start();
67
 	stepperX.start();
68
-#endif
69
-#ifdef X2_IS_TMC
68
+  #endif
69
+  #if ENABLED(X2_IS_TMC)
70
 	stepperX2.setMicrosteps(X2_MICROSTEPS);
70
 	stepperX2.setMicrosteps(X2_MICROSTEPS);
71
 	stepperX2.start();
71
 	stepperX2.start();
72
-#endif
73
-#ifdef Y_IS_TMC
72
+  #endif
73
+  #if ENABLED(Y_IS_TMC)
74
 	stepperY.setMicrosteps(Y_MICROSTEPS);
74
 	stepperY.setMicrosteps(Y_MICROSTEPS);
75
 	stepperY.start();
75
 	stepperY.start();
76
-#endif
77
-#ifdef Y2_IS_TMC
76
+  #endif
77
+  #if ENABLED(Y2_IS_TMC)
78
 	stepperY2.setMicrosteps(Y2_MICROSTEPS);
78
 	stepperY2.setMicrosteps(Y2_MICROSTEPS);
79
 	stepperY2.start();
79
 	stepperY2.start();
80
-#endif
81
-#ifdef Z_IS_TMC
80
+  #endif
81
+  #if ENABLED(Z_IS_TMC)
82
 	stepperZ.setMicrosteps(Z_MICROSTEPS);
82
 	stepperZ.setMicrosteps(Z_MICROSTEPS);
83
 	stepperZ.start();
83
 	stepperZ.start();
84
-#endif
85
-#ifdef Z2_IS_TMC
84
+  #endif
85
+  #if ENABLED(Z2_IS_TMC)
86
 	stepperZ2.setMicrosteps(Z2_MICROSTEPS);
86
 	stepperZ2.setMicrosteps(Z2_MICROSTEPS);
87
 	stepperZ2.start();
87
 	stepperZ2.start();
88
-#endif
89
-#ifdef E0_IS_TMC
88
+  #endif
89
+  #if ENABLED(E0_IS_TMC)
90
 	stepperE0.setMicrosteps(E0_MICROSTEPS);
90
 	stepperE0.setMicrosteps(E0_MICROSTEPS);
91
 	stepperE0.start();
91
 	stepperE0.start();
92
-#endif
93
-#ifdef E1_IS_TMC
92
+  #endif
93
+  #if ENABLED(E1_IS_TMC)
94
 	stepperE1.setMicrosteps(E1_MICROSTEPS);
94
 	stepperE1.setMicrosteps(E1_MICROSTEPS);
95
 	stepperE1.start();
95
 	stepperE1.start();
96
-#endif
97
-#ifdef E2_IS_TMC
96
+  #endif
97
+  #if ENABLED(E2_IS_TMC)
98
 	stepperE2.setMicrosteps(E2_MICROSTEPS);
98
 	stepperE2.setMicrosteps(E2_MICROSTEPS);
99
 	stepperE2.start();
99
 	stepperE2.start();
100
-#endif
101
-#ifdef E3_IS_TMC
100
+  #endif
101
+  #if ENABLED(E3_IS_TMC)
102
 	stepperE3.setMicrosteps(E3_MICROSTEPS);
102
 	stepperE3.setMicrosteps(E3_MICROSTEPS);
103
 	stepperE3.start();
103
 	stepperE3.start();
104
-#endif
104
+  #endif
105
 }
105
 }
106
 #endif
106
 #endif
107
 
107
 
108
 // L6470 Driver objects and inits
108
 // L6470 Driver objects and inits
109
 
109
 
110
-#ifdef HAVE_L6470DRIVER
110
+#if ENABLED(HAVE_L6470DRIVER)
111
 #include <SPI.h>
111
 #include <SPI.h>
112
 #include <L6470.h>
112
 #include <L6470.h>
113
 #endif
113
 #endif
114
 
114
 
115
 // L6470 Stepper objects
115
 // L6470 Stepper objects
116
-#ifdef X_IS_L6470
116
+  #if ENABLED(X_IS_L6470)
117
 	L6470 stepperX(X_ENABLE_PIN);
117
 	L6470 stepperX(X_ENABLE_PIN);
118
-#endif
119
-#ifdef X2_IS_L6470
118
+  #endif
119
+  #if ENABLED(X2_IS_L6470)
120
 	L6470 stepperX2(X2_ENABLE_PIN);
120
 	L6470 stepperX2(X2_ENABLE_PIN);
121
-#endif
122
-#ifdef Y_IS_L6470
121
+  #endif
122
+  #if ENABLED(Y_IS_L6470)
123
 	L6470 stepperY(Y_ENABLE_PIN);
123
 	L6470 stepperY(Y_ENABLE_PIN);
124
-#endif
125
-#ifdef Y2_IS_L6470
124
+  #endif
125
+  #if ENABLED(Y2_IS_L6470)
126
 	L6470 stepperY2(Y2_ENABLE_PIN);
126
 	L6470 stepperY2(Y2_ENABLE_PIN);
127
-#endif
128
-#ifdef Z_IS_L6470
127
+  #endif
128
+  #if ENABLED(Z_IS_L6470)
129
 	L6470 stepperZ(Z_ENABLE_PIN);
129
 	L6470 stepperZ(Z_ENABLE_PIN);
130
-#endif
131
-#ifdef Z2_IS_L6470
130
+  #endif
131
+  #if ENABLED(Z2_IS_L6470)
132
 	L6470 stepperZ2(Z2_ENABLE_PIN);
132
 	L6470 stepperZ2(Z2_ENABLE_PIN);
133
-#endif
134
-#ifdef E0_IS_L6470
133
+  #endif
134
+  #if ENABLED(E0_IS_L6470)
135
 	L6470 stepperE0(E0_ENABLE_PIN);
135
 	L6470 stepperE0(E0_ENABLE_PIN);
136
-#endif
137
-#ifdef E1_IS_L6470
136
+  #endif
137
+  #if ENABLED(E1_IS_L6470)
138
 	L6470 stepperE1(E1_ENABLE_PIN);
138
 	L6470 stepperE1(E1_ENABLE_PIN);
139
-#endif
140
-#ifdef E2_IS_L6470
139
+  #endif
140
+  #if ENABLED(E2_IS_L6470)
141
 	L6470 stepperE2(E2_ENABLE_PIN);
141
 	L6470 stepperE2(E2_ENABLE_PIN);
142
-#endif
143
-#ifdef E3_IS_L6470
142
+  #endif
143
+  #if ENABLED(E3_IS_L6470)
144
 	L6470 stepperE3(E3_ENABLE_PIN);
144
 	L6470 stepperE3(E3_ENABLE_PIN);
145
-#endif	
145
+  #endif	
146
 
146
 
147
 
147
 
148
 // init routine
148
 // init routine
149
-#ifdef HAVE_L6470DRIVER
149
+#if ENABLED(HAVE_L6470DRIVER)
150
 void L6470_init()
150
 void L6470_init()
151
 {
151
 {
152
-#ifdef X_IS_L6470
152
+  #if ENABLED(X_IS_L6470)
153
 	stepperX.init(X_K_VAL);
153
 	stepperX.init(X_K_VAL);
154
 	stepperX.softFree();
154
 	stepperX.softFree();
155
 	stepperX.setMicroSteps(X_MICROSTEPS);
155
 	stepperX.setMicroSteps(X_MICROSTEPS);
156
     stepperX.setOverCurrent(X_OVERCURRENT); //set overcurrent protection
156
     stepperX.setOverCurrent(X_OVERCURRENT); //set overcurrent protection
157
     stepperX.setStallCurrent(X_STALLCURRENT);
157
     stepperX.setStallCurrent(X_STALLCURRENT);
158
-#endif
159
-#ifdef X2_IS_L6470
158
+  #endif
159
+  #if ENABLED(X2_IS_L6470)
160
 	stepperX2.init(X2_K_VAL);
160
 	stepperX2.init(X2_K_VAL);
161
 	stepperX2.softFree();
161
 	stepperX2.softFree();
162
 	stepperX2.setMicroSteps(X2_MICROSTEPS);
162
 	stepperX2.setMicroSteps(X2_MICROSTEPS);
163
     stepperX2.setOverCurrent(X2_OVERCURRENT); //set overcurrent protection
163
     stepperX2.setOverCurrent(X2_OVERCURRENT); //set overcurrent protection
164
     stepperX2.setStallCurrent(X2_STALLCURRENT);
164
     stepperX2.setStallCurrent(X2_STALLCURRENT);
165
-#endif
166
-#ifdef Y_IS_L6470
165
+  #endif
166
+  #if ENABLED(Y_IS_L6470)
167
 	stepperY.init(Y_K_VAL);
167
 	stepperY.init(Y_K_VAL);
168
 	stepperY.softFree();
168
 	stepperY.softFree();
169
 	stepperY.setMicroSteps(Y_MICROSTEPS);
169
 	stepperY.setMicroSteps(Y_MICROSTEPS);
170
     stepperY.setOverCurrent(Y_OVERCURRENT); //set overcurrent protection
170
     stepperY.setOverCurrent(Y_OVERCURRENT); //set overcurrent protection
171
     stepperY.setStallCurrent(Y_STALLCURRENT);
171
     stepperY.setStallCurrent(Y_STALLCURRENT);
172
-#endif
173
-#ifdef Y2_IS_L6470
172
+  #endif
173
+  #if ENABLED(Y2_IS_L6470)
174
 	stepperY2.init(Y2_K_VAL);
174
 	stepperY2.init(Y2_K_VAL);
175
 	stepperY2.softFree();
175
 	stepperY2.softFree();
176
 	stepperY2.setMicroSteps(Y2_MICROSTEPS);
176
 	stepperY2.setMicroSteps(Y2_MICROSTEPS);
177
     stepperY2.setOverCurrent(Y2_OVERCURRENT); //set overcurrent protection
177
     stepperY2.setOverCurrent(Y2_OVERCURRENT); //set overcurrent protection
178
     stepperY2.setStallCurrent(Y2_STALLCURRENT);
178
     stepperY2.setStallCurrent(Y2_STALLCURRENT);
179
-#endif
180
-#ifdef Z_IS_L6470
179
+  #endif
180
+  #if ENABLED(Z_IS_L6470)
181
 	stepperZ.init(Z_K_VAL);
181
 	stepperZ.init(Z_K_VAL);
182
 	stepperZ.softFree();
182
 	stepperZ.softFree();
183
 	stepperZ.setMicroSteps(Z_MICROSTEPS);
183
 	stepperZ.setMicroSteps(Z_MICROSTEPS);
184
     stepperZ.setOverCurrent(Z_OVERCURRENT); //set overcurrent protection
184
     stepperZ.setOverCurrent(Z_OVERCURRENT); //set overcurrent protection
185
     stepperZ.setStallCurrent(Z_STALLCURRENT);
185
     stepperZ.setStallCurrent(Z_STALLCURRENT);
186
-#endif
187
-#ifdef Z2_IS_L6470
186
+  #endif
187
+  #if ENABLED(Z2_IS_L6470)
188
 	stepperZ2.init(Z2_K_VAL);
188
 	stepperZ2.init(Z2_K_VAL);
189
 	stepperZ2.softFree();
189
 	stepperZ2.softFree();
190
 	stepperZ2.setMicroSteps(Z2_MICROSTEPS);
190
 	stepperZ2.setMicroSteps(Z2_MICROSTEPS);
191
     stepperZ2.setOverCurrent(Z2_OVERCURRENT); //set overcurrent protection
191
     stepperZ2.setOverCurrent(Z2_OVERCURRENT); //set overcurrent protection
192
     stepperZ2.setStallCurrent(Z2_STALLCURRENT);
192
     stepperZ2.setStallCurrent(Z2_STALLCURRENT);
193
-#endif
194
-#ifdef E0_IS_L6470
193
+  #endif
194
+  #if ENABLED(E0_IS_L6470)
195
 	stepperE0.init(E0_K_VAL);
195
 	stepperE0.init(E0_K_VAL);
196
 	stepperE0.softFree();
196
 	stepperE0.softFree();
197
 	stepperE0.setMicroSteps(E0_MICROSTEPS);
197
 	stepperE0.setMicroSteps(E0_MICROSTEPS);
198
     stepperE0.setOverCurrent(E0_OVERCURRENT); //set overcurrent protection
198
     stepperE0.setOverCurrent(E0_OVERCURRENT); //set overcurrent protection
199
     stepperE0.setStallCurrent(E0_STALLCURRENT);
199
     stepperE0.setStallCurrent(E0_STALLCURRENT);
200
-#endif
201
-#ifdef E1_IS_L6470
200
+  #endif
201
+  #if ENABLED(E1_IS_L6470)
202
 	stepperE1.init(E1_K_VAL);
202
 	stepperE1.init(E1_K_VAL);
203
 	stepperE1.softFree();
203
 	stepperE1.softFree();
204
 	stepperE1.setMicroSteps(E1_MICROSTEPS);
204
 	stepperE1.setMicroSteps(E1_MICROSTEPS);
205
     stepperE1.setOverCurrent(E1_OVERCURRENT); //set overcurrent protection
205
     stepperE1.setOverCurrent(E1_OVERCURRENT); //set overcurrent protection
206
     stepperE1.setStallCurrent(E1_STALLCURRENT);
206
     stepperE1.setStallCurrent(E1_STALLCURRENT);
207
-#endif
208
-#ifdef E2_IS_L6470
207
+  #endif
208
+  #if ENABLED(E2_IS_L6470)
209
 	stepperE2.init(E2_K_VAL);
209
 	stepperE2.init(E2_K_VAL);
210
 	stepperE2.softFree();
210
 	stepperE2.softFree();
211
 	stepperE2.setMicroSteps(E2_MICROSTEPS);
211
 	stepperE2.setMicroSteps(E2_MICROSTEPS);
212
     stepperE2.setOverCurrent(E2_OVERCURRENT); //set overcurrent protection
212
     stepperE2.setOverCurrent(E2_OVERCURRENT); //set overcurrent protection
213
     stepperE2.setStallCurrent(E2_STALLCURRENT);
213
     stepperE2.setStallCurrent(E2_STALLCURRENT);
214
-#endif
215
-#ifdef E3_IS_L6470
214
+  #endif
215
+  #if ENABLED(E3_IS_L6470)
216
 	stepperE3.init(E3_K_VAL);
216
 	stepperE3.init(E3_K_VAL);
217
 	stepperE3.softFree();
217
 	stepperE3.softFree();
218
 	stepperE3.setMicroSteps(E3_MICROSTEPS);
218
 	stepperE3.setMicroSteps(E3_MICROSTEPS);
219
     stepperE3.setOverCurrent(E3_OVERCURRENT); //set overcurrent protection
219
     stepperE3.setOverCurrent(E3_OVERCURRENT); //set overcurrent protection
220
     stepperE3.setStallCurrent(E3_STALLCURRENT);
220
     stepperE3.setStallCurrent(E3_STALLCURRENT);
221
-#endif	
221
+  #endif	
222
 }
222
 }
223
 #endif
223
 #endif
224
 
224
 

+ 22
- 22
Marlin/stepper_indirection.h View File

158
 // Pin redefines for TMC drivers. 
158
 // Pin redefines for TMC drivers. 
159
 // TMC26X drivers have step and dir on normal pins, but everything else via SPI
159
 // TMC26X drivers have step and dir on normal pins, but everything else via SPI
160
 //////////////////////////////////
160
 //////////////////////////////////
161
-#ifdef HAVE_TMCDRIVER
161
+#if ENABLED(HAVE_TMCDRIVER)
162
 #include <SPI.h>
162
 #include <SPI.h>
163
 #include <TMC26XStepper.h>
163
 #include <TMC26XStepper.h>
164
 
164
 
165
   void tmc_init();
165
   void tmc_init();
166
-#ifdef X_IS_TMC
166
+#if ENABLED(X_IS_TMC)
167
    extern TMC26XStepper stepperX;
167
    extern TMC26XStepper stepperX;
168
    #undef X_ENABLE_INIT 
168
    #undef X_ENABLE_INIT 
169
    #define X_ENABLE_INIT ((void)0)
169
    #define X_ENABLE_INIT ((void)0)
175
    #define X_ENABLE_READ stepperX.isEnabled()
175
    #define X_ENABLE_READ stepperX.isEnabled()
176
    
176
    
177
 #endif
177
 #endif
178
-#ifdef X2_IS_TMC
178
+#if ENABLED(X2_IS_TMC)
179
    extern TMC26XStepper stepperX2;
179
    extern TMC26XStepper stepperX2;
180
    #undef X2_ENABLE_INIT
180
    #undef X2_ENABLE_INIT
181
    #define X2_ENABLE_INIT ((void)0)
181
    #define X2_ENABLE_INIT ((void)0)
186
    #undef X2_ENABLE_READ
186
    #undef X2_ENABLE_READ
187
    #define X2_ENABLE_READ stepperX2.isEnabled()   
187
    #define X2_ENABLE_READ stepperX2.isEnabled()   
188
 #endif
188
 #endif
189
-#ifdef Y_IS_TMC
189
+#if ENABLED(Y_IS_TMC)
190
    extern TMC26XStepper stepperY;
190
    extern TMC26XStepper stepperY;
191
    #undef Y_ENABLE_INIT
191
    #undef Y_ENABLE_INIT
192
    #define Y_ENABLE_INIT ((void)0)
192
    #define Y_ENABLE_INIT ((void)0)
197
    #undef Y_ENABLE_READ
197
    #undef Y_ENABLE_READ
198
    #define Y_ENABLE_READ stepperY.isEnabled()   
198
    #define Y_ENABLE_READ stepperY.isEnabled()   
199
 #endif
199
 #endif
200
-#ifdef Y2_IS_TMC
200
+#if ENABLED(Y2_IS_TMC)
201
    extern TMC26XStepper stepperY2;
201
    extern TMC26XStepper stepperY2;
202
    #undef Y2_ENABLE_INIT
202
    #undef Y2_ENABLE_INIT
203
    #define Y2_ENABLE_INIT ((void)0)
203
    #define Y2_ENABLE_INIT ((void)0)
208
    #undef Y2_ENABLE_READ
208
    #undef Y2_ENABLE_READ
209
    #define Y2_ENABLE_READ stepperY2.isEnabled()     
209
    #define Y2_ENABLE_READ stepperY2.isEnabled()     
210
 #endif
210
 #endif
211
-#ifdef Z_IS_TMC
211
+#if ENABLED(Z_IS_TMC)
212
    extern TMC26XStepper stepperZ;
212
    extern TMC26XStepper stepperZ;
213
    #undef Z_ENABLE_INIT
213
    #undef Z_ENABLE_INIT
214
    #define Z_ENABLE_INIT ((void)0)
214
    #define Z_ENABLE_INIT ((void)0)
219
    #undef Z_ENABLE_READ
219
    #undef Z_ENABLE_READ
220
    #define Z_ENABLE_READ stepperZ.isEnabled()       
220
    #define Z_ENABLE_READ stepperZ.isEnabled()       
221
 #endif
221
 #endif
222
-#ifdef Z2_IS_TMC
222
+#if ENABLED(Z2_IS_TMC)
223
    extern TMC26XStepper stepperZ2;
223
    extern TMC26XStepper stepperZ2;
224
    #undef Z2_ENABLE_INIT
224
    #undef Z2_ENABLE_INIT
225
    #define Z2_ENABLE_INIT ((void)0)
225
    #define Z2_ENABLE_INIT ((void)0)
230
    #undef Z2_ENABLE_READ
230
    #undef Z2_ENABLE_READ
231
    #define Z2_ENABLE_READ stepperZ2.isEnabled()   
231
    #define Z2_ENABLE_READ stepperZ2.isEnabled()   
232
 #endif
232
 #endif
233
-#ifdef E0_IS_TMC
233
+#if ENABLED(E0_IS_TMC)
234
    extern TMC26XStepper stepperE0;
234
    extern TMC26XStepper stepperE0;
235
    #undef E0_ENABLE_INIT
235
    #undef E0_ENABLE_INIT
236
    #define E0_ENABLE_INIT ((void)0)
236
    #define E0_ENABLE_INIT ((void)0)
241
    #undef E0_ENABLE_READ
241
    #undef E0_ENABLE_READ
242
    #define E0_ENABLE_READ stepperE0.isEnabled()   
242
    #define E0_ENABLE_READ stepperE0.isEnabled()   
243
 #endif
243
 #endif
244
-#ifdef E1_IS_TMC
244
+#if ENABLED(E1_IS_TMC)
245
    extern TMC26XStepper stepperE1;
245
    extern TMC26XStepper stepperE1;
246
    #undef E1_ENABLE_INIT
246
    #undef E1_ENABLE_INIT
247
    #define E1_ENABLE_INIT ((void)0)
247
    #define E1_ENABLE_INIT ((void)0)
252
    #undef E1_ENABLE_READ
252
    #undef E1_ENABLE_READ
253
    #define E1_ENABLE_READ stepperE1.isEnabled()   
253
    #define E1_ENABLE_READ stepperE1.isEnabled()   
254
 #endif
254
 #endif
255
-#ifdef E2_IS_TMC
255
+#if ENABLED(E2_IS_TMC)
256
    extern TMC26XStepper stepperE2;
256
    extern TMC26XStepper stepperE2;
257
    #undef E2_ENABLE_INIT
257
    #undef E2_ENABLE_INIT
258
    #define E2_ENABLE_INIT ((void)0)
258
    #define E2_ENABLE_INIT ((void)0)
263
    #undef E2_ENABLE_READ
263
    #undef E2_ENABLE_READ
264
    #define E2_ENABLE_READ stepperE2.isEnabled()   
264
    #define E2_ENABLE_READ stepperE2.isEnabled()   
265
 #endif
265
 #endif
266
-#ifdef E3_IS_TMC
266
+#if ENABLED(E3_IS_TMC)
267
    extern TMC26XStepper stepperE3;
267
    extern TMC26XStepper stepperE3;
268
    #undef E3_ENABLE_INIT
268
    #undef E3_ENABLE_INIT
269
    #define E3_ENABLE_INIT ((void)0)
269
    #define E3_ENABLE_INIT ((void)0)
281
 // Pin redefines for L6470 drivers. 
281
 // Pin redefines for L6470 drivers. 
282
 // L640 drivers have step on normal pins, but dir and everything else via SPI
282
 // L640 drivers have step on normal pins, but dir and everything else via SPI
283
 //////////////////////////////////
283
 //////////////////////////////////
284
-#ifdef HAVE_L6470DRIVER
284
+#if ENABLED(HAVE_L6470DRIVER)
285
 
285
 
286
 #include <SPI.h>
286
 #include <SPI.h>
287
 #include <L6470.h>
287
 #include <L6470.h>
288
 
288
 
289
   void L6470_init();
289
   void L6470_init();
290
-#ifdef X_IS_L6470
290
+#if ENABLED(X_IS_L6470)
291
    extern L6470 stepperX;
291
    extern L6470 stepperX;
292
    #undef X_ENABLE_INIT 
292
    #undef X_ENABLE_INIT 
293
    #define X_ENABLE_INIT ((void)0)
293
    #define X_ENABLE_INIT ((void)0)
308
    #define X_DIR_READ (stepperX.getStatus() & STATUS_DIR)
308
    #define X_DIR_READ (stepperX.getStatus() & STATUS_DIR)
309
    
309
    
310
 #endif
310
 #endif
311
-#ifdef X2_IS_L6470
311
+#if ENABLED(X2_IS_L6470)
312
    extern L6470 stepperX2;
312
    extern L6470 stepperX2;
313
    #undef X2_ENABLE_INIT
313
    #undef X2_ENABLE_INIT
314
    #define X2_ENABLE_INIT ((void)0)
314
    #define X2_ENABLE_INIT ((void)0)
328
    #undef X2_DIR_READ
328
    #undef X2_DIR_READ
329
    #define X2_DIR_READ (stepperX2.getStatus() & STATUS_DIR)
329
    #define X2_DIR_READ (stepperX2.getStatus() & STATUS_DIR)
330
 #endif
330
 #endif
331
-#ifdef Y_IS_L6470
331
+#if ENABLED(Y_IS_L6470)
332
    extern L6470 stepperY;
332
    extern L6470 stepperY;
333
    #undef Y_ENABLE_INIT
333
    #undef Y_ENABLE_INIT
334
    #define Y_ENABLE_INIT ((void)0)
334
    #define Y_ENABLE_INIT ((void)0)
348
    #undef Y_DIR_READ
348
    #undef Y_DIR_READ
349
    #define Y_DIR_READ (stepperY.getStatus() & STATUS_DIR)  
349
    #define Y_DIR_READ (stepperY.getStatus() & STATUS_DIR)  
350
 #endif
350
 #endif
351
-#ifdef Y2_IS_L6470
351
+#if ENABLED(Y2_IS_L6470)
352
    extern L6470 stepperY2;
352
    extern L6470 stepperY2;
353
    #undef Y2_ENABLE_INIT
353
    #undef Y2_ENABLE_INIT
354
    #define Y2_ENABLE_INIT ((void)0)
354
    #define Y2_ENABLE_INIT ((void)0)
368
    #undef Y2_DIR_READ
368
    #undef Y2_DIR_READ
369
    #define Y2_DIR_READ (stepperY2.getStatus() & STATUS_DIR)   
369
    #define Y2_DIR_READ (stepperY2.getStatus() & STATUS_DIR)   
370
 #endif
370
 #endif
371
-#ifdef Z_IS_L6470
371
+#if ENABLED(Z_IS_L6470)
372
    extern L6470 stepperZ;
372
    extern L6470 stepperZ;
373
    #undef Z_ENABLE_INIT
373
    #undef Z_ENABLE_INIT
374
    #define Z_ENABLE_INIT ((void)0)
374
    #define Z_ENABLE_INIT ((void)0)
388
    #undef Y_DIR_READ
388
    #undef Y_DIR_READ
389
    #define Y_DIR_READ (stepperZ.getStatus() & STATUS_DIR)      
389
    #define Y_DIR_READ (stepperZ.getStatus() & STATUS_DIR)      
390
 #endif
390
 #endif
391
-#ifdef Z2_IS_L6470
391
+#if ENABLED(Z2_IS_L6470)
392
    extern L6470 stepperZ2;
392
    extern L6470 stepperZ2;
393
    #undef Z2_ENABLE_INIT
393
    #undef Z2_ENABLE_INIT
394
    #define Z2_ENABLE_INIT ((void)0)
394
    #define Z2_ENABLE_INIT ((void)0)
408
    #undef Y2_DIR_READ
408
    #undef Y2_DIR_READ
409
    #define Y2_DIR_READ (stepperZ2.getStatus() & STATUS_DIR)       
409
    #define Y2_DIR_READ (stepperZ2.getStatus() & STATUS_DIR)       
410
 #endif
410
 #endif
411
-#ifdef E0_IS_L6470
411
+#if ENABLED(E0_IS_L6470)
412
    extern L6470 stepperE0;
412
    extern L6470 stepperE0;
413
    #undef E0_ENABLE_INIT
413
    #undef E0_ENABLE_INIT
414
    #define E0_ENABLE_INIT ((void)0)
414
    #define E0_ENABLE_INIT ((void)0)
428
    #undef E0_DIR_READ
428
    #undef E0_DIR_READ
429
    #define E0_DIR_READ (stepperE0.getStatus() & STATUS_DIR)    
429
    #define E0_DIR_READ (stepperE0.getStatus() & STATUS_DIR)    
430
 #endif
430
 #endif
431
-#ifdef E1_IS_L6470
431
+#if ENABLED(E1_IS_L6470)
432
    extern L6470 stepperE1;
432
    extern L6470 stepperE1;
433
    #undef E1_ENABLE_INIT
433
    #undef E1_ENABLE_INIT
434
    #define E1_ENABLE_INIT ((void)0)
434
    #define E1_ENABLE_INIT ((void)0)
448
    #undef E1_DIR_READ
448
    #undef E1_DIR_READ
449
    #define E1_DIR_READ (stepperE1.getStatus() & STATUS_DIR)  
449
    #define E1_DIR_READ (stepperE1.getStatus() & STATUS_DIR)  
450
 #endif
450
 #endif
451
-#ifdef E2_IS_L6470
451
+#if ENABLED(E2_IS_L6470)
452
    extern L6470 stepperE2;
452
    extern L6470 stepperE2;
453
    #undef E2_ENABLE_INIT
453
    #undef E2_ENABLE_INIT
454
    #define E2_ENABLE_INIT ((void)0)
454
    #define E2_ENABLE_INIT ((void)0)
468
    #undef E2_DIR_READ
468
    #undef E2_DIR_READ
469
    #define E2_DIR_READ (stepperE2.getStatus() & STATUS_DIR)  
469
    #define E2_DIR_READ (stepperE2.getStatus() & STATUS_DIR)  
470
 #endif
470
 #endif
471
-#ifdef E3_IS_L6470
471
+#if ENABLED(E3_IS_L6470)
472
    extern L6470 stepperE3;
472
    extern L6470 stepperE3;
473
    #undef E3_ENABLE_INIT
473
    #undef E3_ENABLE_INIT
474
    #define E3_ENABLE_INIT ((void)0)
474
    #define E3_ENABLE_INIT ((void)0)

Loading…
Cancel
Save