ソースを参照

Introduce a layer of macro indirection to all stepper pins. This allows other stepper drivers to redefine them, so they can use SPI/I2C instead of direct pin manipulation.

domonoky 9年前
コミット
b55995aae8
5個のファイルの変更353行の追加196行の削除
  1. 20
    20
      Marlin/Marlin.h
  2. 7
    7
      Marlin/Marlin_main.cpp
  3. 154
    154
      Marlin/stepper.cpp
  4. 16
    15
      Marlin/stepper.h
  5. 156
    0
      Marlin/stepper_indirection.h

+ 20
- 20
Marlin/Marlin.h ファイルの表示

@@ -112,11 +112,11 @@ void manage_inactivity(bool ignore_stepper_queue=false);
112 112
 
113 113
 #if defined(DUAL_X_CARRIAGE) && defined(X_ENABLE_PIN) && X_ENABLE_PIN > -1 \
114 114
     && defined(X2_ENABLE_PIN) && X2_ENABLE_PIN > -1
115
-  #define  enable_x() do { WRITE(X_ENABLE_PIN, X_ENABLE_ON); WRITE(X2_ENABLE_PIN, X_ENABLE_ON); } while (0)
116
-  #define disable_x() do { WRITE(X_ENABLE_PIN,!X_ENABLE_ON); WRITE(X2_ENABLE_PIN,!X_ENABLE_ON); axis_known_position[X_AXIS] = false; } while (0)
115
+  #define  enable_x() do { X_ENABLE_WRITE( X_ENABLE_ON); X2_ENABLE_WRITE( X_ENABLE_ON); } while (0)
116
+  #define disable_x() do { X_ENABLE_WRITE(!X_ENABLE_ON); X2_ENABLE_WRITE(!X_ENABLE_ON); axis_known_position[X_AXIS] = false; } while (0)
117 117
 #elif defined(X_ENABLE_PIN) && X_ENABLE_PIN > -1
118
-  #define  enable_x() WRITE(X_ENABLE_PIN, X_ENABLE_ON)
119
-  #define disable_x() { WRITE(X_ENABLE_PIN,!X_ENABLE_ON); axis_known_position[X_AXIS] = false; }
118
+  #define  enable_x() X_ENABLE_WRITE( X_ENABLE_ON)
119
+  #define disable_x() { X_ENABLE_WRITE(!X_ENABLE_ON); axis_known_position[X_AXIS] = false; }
120 120
 #else
121 121
   #define enable_x() ;
122 122
   #define disable_x() ;
@@ -124,11 +124,11 @@ void manage_inactivity(bool ignore_stepper_queue=false);
124 124
 
125 125
 #if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1
126 126
   #ifdef Y_DUAL_STEPPER_DRIVERS
127
-    #define  enable_y() { WRITE(Y_ENABLE_PIN, Y_ENABLE_ON); WRITE(Y2_ENABLE_PIN,  Y_ENABLE_ON); }
128
-    #define disable_y() { WRITE(Y_ENABLE_PIN,!Y_ENABLE_ON); WRITE(Y2_ENABLE_PIN, !Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }
127
+    #define  enable_y() { Y_ENABLE_WRITE( Y_ENABLE_ON); Y2_ENABLE_WRITE(Y_ENABLE_ON); }
128
+    #define disable_y() { Y_ENABLE_WRITE(!Y_ENABLE_ON); Y2_ENABLE_WRITE(!Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }
129 129
   #else
130
-    #define  enable_y() WRITE(Y_ENABLE_PIN, Y_ENABLE_ON)
131
-    #define disable_y() { WRITE(Y_ENABLE_PIN,!Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }
130
+    #define  enable_y() Y_ENABLE_WRITE( Y_ENABLE_ON)
131
+    #define disable_y() { Y_ENABLE_WRITE(!Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }
132 132
   #endif
133 133
 #else
134 134
   #define enable_y() ;
@@ -137,11 +137,11 @@ void manage_inactivity(bool ignore_stepper_queue=false);
137 137
 
138 138
 #if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1
139 139
   #ifdef Z_DUAL_STEPPER_DRIVERS
140
-    #define  enable_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); }
141
-    #define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
140
+    #define  enable_z() { Z_ENABLE_WRITE( Z_ENABLE_ON); Z2_ENABLE_WRITE(Z_ENABLE_ON); }
141
+    #define disable_z() { Z_ENABLE_WRITE(!Z_ENABLE_ON); Z2_ENABLE_WRITE(!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
142 142
   #else
143
-    #define  enable_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON)
144
-    #define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
143
+    #define  enable_z() Z_ENABLE_WRITE( Z_ENABLE_ON)
144
+    #define disable_z() { Z_ENABLE_WRITE(!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
145 145
   #endif
146 146
 #else
147 147
   #define enable_z() ;
@@ -149,32 +149,32 @@ void manage_inactivity(bool ignore_stepper_queue=false);
149 149
 #endif
150 150
 
151 151
 #if defined(E0_ENABLE_PIN) && (E0_ENABLE_PIN > -1)
152
-  #define enable_e0() WRITE(E0_ENABLE_PIN, E_ENABLE_ON)
153
-  #define disable_e0() WRITE(E0_ENABLE_PIN,!E_ENABLE_ON)
152
+  #define enable_e0() E0_ENABLE_WRITE(E_ENABLE_ON)
153
+  #define disable_e0() E0_ENABLE_WRITE(!E_ENABLE_ON)
154 154
 #else
155 155
   #define enable_e0()  /* nothing */
156 156
   #define disable_e0() /* nothing */
157 157
 #endif
158 158
 
159 159
 #if (EXTRUDERS > 1) && defined(E1_ENABLE_PIN) && (E1_ENABLE_PIN > -1)
160
-  #define enable_e1() WRITE(E1_ENABLE_PIN, E_ENABLE_ON)
161
-  #define disable_e1() WRITE(E1_ENABLE_PIN,!E_ENABLE_ON)
160
+  #define enable_e1() E1_ENABLE_WRITE(E_ENABLE_ON)
161
+  #define disable_e1() E1_ENABLE_WRITE(!E_ENABLE_ON)
162 162
 #else
163 163
   #define enable_e1()  /* nothing */
164 164
   #define disable_e1() /* nothing */
165 165
 #endif
166 166
 
167 167
 #if (EXTRUDERS > 2) && defined(E2_ENABLE_PIN) && (E2_ENABLE_PIN > -1)
168
-  #define enable_e2() WRITE(E2_ENABLE_PIN, E_ENABLE_ON)
169
-  #define disable_e2() WRITE(E2_ENABLE_PIN,!E_ENABLE_ON)
168
+  #define enable_e2() E2_ENABLE_WRITE(E_ENABLE_ON)
169
+  #define disable_e2() E2_ENABLE_WRITE(!E_ENABLE_ON)
170 170
 #else
171 171
   #define enable_e2()  /* nothing */
172 172
   #define disable_e2() /* nothing */
173 173
 #endif
174 174
 
175 175
 #if (EXTRUDERS > 3) && defined(E3_ENABLE_PIN) && (E3_ENABLE_PIN > -1)
176
-  #define enable_e3() WRITE(E3_ENABLE_PIN, E_ENABLE_ON)
177
-  #define disable_e3() WRITE(E3_ENABLE_PIN,!E_ENABLE_ON)
176
+  #define enable_e3() E3_ENABLE_WRITE(E_ENABLE_ON)
177
+  #define disable_e3() E3_ENABLE_WRITE(!E_ENABLE_ON)
178 178
 #else
179 179
   #define enable_e3()  /* nothing */
180 180
   #define disable_e3() /* nothing */

+ 7
- 7
Marlin/Marlin_main.cpp ファイルの表示

@@ -4284,17 +4284,17 @@ void controllerFan()
4284 4284
   {
4285 4285
     lastMotorCheck = millis();
4286 4286
 
4287
-    if(!READ(X_ENABLE_PIN) || !READ(Y_ENABLE_PIN) || !READ(Z_ENABLE_PIN) || (soft_pwm_bed > 0)
4287
+    if(!READ(X_ENABLE_PIN) || !Y_ENABLE_READ || !Z_ENABLE_READ || (soft_pwm_bed > 0)
4288 4288
     #if EXTRUDERS > 2
4289
-       || !READ(E2_ENABLE_PIN)
4289
+       || !E2_ENABLE_READ
4290 4290
     #endif
4291 4291
     #if EXTRUDER > 1
4292 4292
       #if defined(X2_ENABLE_PIN) && X2_ENABLE_PIN > -1
4293
-       || !READ(X2_ENABLE_PIN)
4293
+       || !X2_ENABLE_READ
4294 4294
       #endif
4295
-       || !READ(E1_ENABLE_PIN)
4295
+       || !E1_ENABLE_READ)
4296 4296
     #endif
4297
-       || !READ(E0_ENABLE_PIN)) //If any of the drivers are enabled...
4297
+       || !E0_ENABLE_READ) //If any of the drivers are enabled...
4298 4298
     {
4299 4299
       lastMotor = millis(); //... set time to NOW so the fan will turn on
4300 4300
     }
@@ -4518,7 +4518,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s
4518 4518
     if( (millis() - previous_millis_cmd) >  EXTRUDER_RUNOUT_SECONDS*1000 )
4519 4519
     if(degHotend(active_extruder)>EXTRUDER_RUNOUT_MINTEMP)
4520 4520
     {
4521
-     bool oldstatus=READ(E0_ENABLE_PIN);
4521
+     bool oldstatus=E0_ENABLE_READ;
4522 4522
      enable_e0();
4523 4523
      float oldepos=current_position[E_AXIS];
4524 4524
      float oldedes=destination[E_AXIS];
@@ -4530,7 +4530,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s
4530 4530
      plan_set_e_position(oldepos);
4531 4531
      previous_millis_cmd=millis();
4532 4532
      st_synchronize();
4533
-     WRITE(E0_ENABLE_PIN,oldstatus);
4533
+     E0_ENABLE_WRITE(oldstatus);
4534 4534
     }
4535 4535
   #endif
4536 4536
   #if defined(DUAL_X_CARRIAGE)

+ 154
- 154
Marlin/stepper.cpp ファイルの表示

@@ -349,51 +349,51 @@ ISR(TIMER1_COMPA_vect)
349 349
     if((out_bits & (1<<X_AXIS))!=0){
350 350
       #ifdef DUAL_X_CARRIAGE
351 351
         if (extruder_duplication_enabled){
352
-          WRITE(X_DIR_PIN, INVERT_X_DIR);
353
-          WRITE(X2_DIR_PIN, INVERT_X_DIR);
352
+          X_DIR_WRITE(INVERT_X_DIR);
353
+          X2_DIR_WRITE(INVERT_X_DIR);
354 354
         }
355 355
         else{
356 356
           if (current_block->active_extruder != 0)
357
-            WRITE(X2_DIR_PIN, INVERT_X_DIR);
357
+            X2_DIR_WRITE(INVERT_X_DIR);
358 358
           else
359
-            WRITE(X_DIR_PIN, INVERT_X_DIR);
359
+            X_DIR_WRITE(INVERT_X_DIR);
360 360
         }
361 361
       #else
362
-        WRITE(X_DIR_PIN, INVERT_X_DIR);
362
+        X_DIR_WRITE(INVERT_X_DIR);
363 363
       #endif        
364 364
       count_direction[X_AXIS]=-1;
365 365
     }
366 366
     else{
367 367
       #ifdef DUAL_X_CARRIAGE
368 368
         if (extruder_duplication_enabled){
369
-          WRITE(X_DIR_PIN, !INVERT_X_DIR);
370
-          WRITE(X2_DIR_PIN, !INVERT_X_DIR);
369
+          X_DIR_WRITE(!INVERT_X_DIR);
370
+          X2_DIR_WRITE( !INVERT_X_DIR);
371 371
         }
372 372
         else{
373 373
           if (current_block->active_extruder != 0)
374
-            WRITE(X2_DIR_PIN, !INVERT_X_DIR);
374
+            X2_DIR_WRITE(!INVERT_X_DIR);
375 375
           else
376
-            WRITE(X_DIR_PIN, !INVERT_X_DIR);
376
+            X_DIR_WRITE(!INVERT_X_DIR);
377 377
         }
378 378
       #else
379
-        WRITE(X_DIR_PIN, !INVERT_X_DIR);
379
+        X_DIR_WRITE(!INVERT_X_DIR);
380 380
       #endif        
381 381
       count_direction[X_AXIS]=1;
382 382
     }
383 383
     if((out_bits & (1<<Y_AXIS))!=0){
384
-      WRITE(Y_DIR_PIN, INVERT_Y_DIR);
384
+      Y_DIR_WRITE(INVERT_Y_DIR);
385 385
 	  
386 386
 	  #ifdef Y_DUAL_STEPPER_DRIVERS
387
-	    WRITE(Y2_DIR_PIN, !(INVERT_Y_DIR == INVERT_Y2_VS_Y_DIR));
387
+	    Y2_DIR_WRITE(!(INVERT_Y_DIR == INVERT_Y2_VS_Y_DIR));
388 388
 	  #endif
389 389
 	  
390 390
       count_direction[Y_AXIS]=-1;
391 391
     }
392 392
     else{
393
-      WRITE(Y_DIR_PIN, !INVERT_Y_DIR);
393
+      Y_DIR_WRITE(!INVERT_Y_DIR);
394 394
 	  
395 395
 	  #ifdef Y_DUAL_STEPPER_DRIVERS
396
-	    WRITE(Y2_DIR_PIN, (INVERT_Y_DIR == INVERT_Y2_VS_Y_DIR));
396
+	    Y2_DIR_WRITE((INVERT_Y_DIR == INVERT_Y2_VS_Y_DIR));
397 397
 	  #endif
398 398
 	  
399 399
       count_direction[Y_AXIS]=1;
@@ -485,10 +485,10 @@ ISR(TIMER1_COMPA_vect)
485 485
     }
486 486
 
487 487
     if ((out_bits & (1<<Z_AXIS)) != 0) {   // -direction
488
-      WRITE(Z_DIR_PIN,INVERT_Z_DIR);
488
+      Z_DIR_WRITE(INVERT_Z_DIR);
489 489
       
490 490
       #ifdef Z_DUAL_STEPPER_DRIVERS
491
-        WRITE(Z2_DIR_PIN,INVERT_Z_DIR);
491
+        Z2_DIR_WRITE(INVERT_Z_DIR);
492 492
       #endif
493 493
 
494 494
       count_direction[Z_AXIS]=-1;
@@ -506,10 +506,10 @@ ISR(TIMER1_COMPA_vect)
506 506
       }
507 507
     }
508 508
     else { // +direction
509
-      WRITE(Z_DIR_PIN,!INVERT_Z_DIR);
509
+      Z_DIR_WRITE(!INVERT_Z_DIR);
510 510
 
511 511
       #ifdef Z_DUAL_STEPPER_DRIVERS
512
-        WRITE(Z2_DIR_PIN,!INVERT_Z_DIR);
512
+        Z2_DIR_WRITE(!INVERT_Z_DIR);
513 513
       #endif
514 514
 
515 515
       count_direction[Z_AXIS]=1;
@@ -565,17 +565,17 @@ ISR(TIMER1_COMPA_vect)
565 565
 	 * low instead of doing each in turn. The extra tests add enough
566 566
 	 * lag to allow it work with without needing NOPs */ 
567 567
       if (counter_x > 0) {
568
-        WRITE(X_STEP_PIN, HIGH);
568
+        X_STEP_WRITE(HIGH);
569 569
       }
570 570
 
571 571
       counter_y += current_block->steps_y;
572 572
       if (counter_y > 0) {
573
-        WRITE(Y_STEP_PIN, HIGH);
573
+        Y_STEP_WRITE( HIGH);
574 574
       }
575 575
 
576 576
       counter_z += current_block->steps_z;
577 577
       if (counter_z > 0) {
578
-        WRITE(Z_STEP_PIN, HIGH);
578
+        Z_STEP_WRITE( HIGH);
579 579
       }
580 580
 
581 581
       #ifndef ADVANCE
@@ -588,19 +588,19 @@ ISR(TIMER1_COMPA_vect)
588 588
       if (counter_x > 0) {
589 589
         counter_x -= current_block->step_event_count;
590 590
         count_position[X_AXIS]+=count_direction[X_AXIS];   
591
-        WRITE(X_STEP_PIN, LOW);
591
+        X_STEP_WRITE(LOW);
592 592
       }
593 593
 
594 594
       if (counter_y > 0) {
595 595
         counter_y -= current_block->step_event_count;
596 596
         count_position[Y_AXIS]+=count_direction[Y_AXIS];
597
-        WRITE(Y_STEP_PIN, LOW);
597
+        Y_STEP_WRITE( LOW);
598 598
       }
599 599
 
600 600
       if (counter_z > 0) {
601 601
         counter_z -= current_block->step_event_count;
602 602
         count_position[Z_AXIS]+=count_direction[Z_AXIS];
603
-        WRITE(Z_STEP_PIN, LOW);
603
+        Z_STEP_WRITE(LOW);
604 604
       }
605 605
 
606 606
       #ifndef ADVANCE
@@ -614,67 +614,67 @@ ISR(TIMER1_COMPA_vect)
614 614
         if (counter_x > 0) {
615 615
         #ifdef DUAL_X_CARRIAGE
616 616
           if (extruder_duplication_enabled){
617
-            WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
618
-            WRITE(X2_STEP_PIN, !INVERT_X_STEP_PIN);
617
+            X_STEP_WRITE(!INVERT_X_STEP_PIN);
618
+            X2_STEP_WRITE( !INVERT_X_STEP_PIN);
619 619
           }
620 620
           else {
621 621
             if (current_block->active_extruder != 0)
622
-              WRITE(X2_STEP_PIN, !INVERT_X_STEP_PIN);
622
+              X2_STEP_WRITE( !INVERT_X_STEP_PIN);
623 623
             else
624
-              WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
624
+              X_STEP_WRITE(!INVERT_X_STEP_PIN);
625 625
           }
626 626
         #else
627
-          WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
627
+          X_STEP_WRITE(!INVERT_X_STEP_PIN);
628 628
         #endif        
629 629
           counter_x -= current_block->step_event_count;
630 630
           count_position[X_AXIS]+=count_direction[X_AXIS];   
631 631
         #ifdef DUAL_X_CARRIAGE
632 632
           if (extruder_duplication_enabled){
633
-            WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
634
-            WRITE(X2_STEP_PIN, INVERT_X_STEP_PIN);
633
+            X_STEP_WRITE(INVERT_X_STEP_PIN);
634
+            X2_STEP_WRITE(INVERT_X_STEP_PIN);
635 635
           }
636 636
           else {
637 637
             if (current_block->active_extruder != 0)
638
-              WRITE(X2_STEP_PIN, INVERT_X_STEP_PIN);
638
+              X2_STEP_WRITE(INVERT_X_STEP_PIN);
639 639
             else
640
-              WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
640
+              X_STEP_WRITE(INVERT_X_STEP_PIN);
641 641
           }
642 642
         #else
643
-          WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
643
+          X_STEP_WRITE(INVERT_X_STEP_PIN);
644 644
         #endif
645 645
         }
646 646
 
647 647
         counter_y += current_block->steps_y;
648 648
         if (counter_y > 0) {
649
-          WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
649
+          Y_STEP_WRITE(!INVERT_Y_STEP_PIN);
650 650
 		  
651 651
 		  #ifdef Y_DUAL_STEPPER_DRIVERS
652
-			WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN);
652
+			Y2_STEP_WRITE( !INVERT_Y_STEP_PIN);
653 653
 		  #endif
654 654
 		  
655 655
           counter_y -= current_block->step_event_count;
656 656
           count_position[Y_AXIS]+=count_direction[Y_AXIS];
657
-          WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
657
+          Y_STEP_WRITE(INVERT_Y_STEP_PIN);
658 658
 		  
659 659
 		  #ifdef Y_DUAL_STEPPER_DRIVERS
660
-			WRITE(Y2_STEP_PIN, INVERT_Y_STEP_PIN);
660
+			Y2_STEP_WRITE( INVERT_Y_STEP_PIN);
661 661
 		  #endif
662 662
         }
663 663
 
664 664
       counter_z += current_block->steps_z;
665 665
       if (counter_z > 0) {
666
-        WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN);
666
+        Z_STEP_WRITE( !INVERT_Z_STEP_PIN);
667 667
         
668 668
         #ifdef Z_DUAL_STEPPER_DRIVERS
669
-          WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN);
669
+          Z2_STEP_WRITE(!INVERT_Z_STEP_PIN);
670 670
         #endif
671 671
 
672 672
         counter_z -= current_block->step_event_count;
673 673
         count_position[Z_AXIS]+=count_direction[Z_AXIS];
674
-        WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN);
674
+        Z_STEP_WRITE( INVERT_Z_STEP_PIN);
675 675
         
676 676
         #ifdef Z_DUAL_STEPPER_DRIVERS
677
-          WRITE(Z2_STEP_PIN, INVERT_Z_STEP_PIN);
677
+          Z2_STEP_WRITE(INVERT_Z_STEP_PIN);
678 678
         #endif
679 679
       }
680 680
 
@@ -771,60 +771,60 @@ ISR(TIMER1_COMPA_vect)
771 771
     // Set E direction (Depends on E direction + advance)
772 772
     for(unsigned char i=0; i<4;i++) {
773 773
       if (e_steps[0] != 0) {
774
-        WRITE(E0_STEP_PIN, INVERT_E_STEP_PIN);
774
+        E0_STEP_WRITE( INVERT_E_STEP_PIN);
775 775
         if (e_steps[0] < 0) {
776
-          WRITE(E0_DIR_PIN, INVERT_E0_DIR);
776
+          E0_DIR_WRITE(INVERT_E0_DIR);
777 777
           e_steps[0]++;
778
-          WRITE(E0_STEP_PIN, !INVERT_E_STEP_PIN);
778
+          E0_STEP_WRITE(!INVERT_E_STEP_PIN);
779 779
         }
780 780
         else if (e_steps[0] > 0) {
781
-          WRITE(E0_DIR_PIN, !INVERT_E0_DIR);
781
+          E0_DIR_WRITE(!INVERT_E0_DIR);
782 782
           e_steps[0]--;
783
-          WRITE(E0_STEP_PIN, !INVERT_E_STEP_PIN);
783
+          E0_STEP_WRITE(!INVERT_E_STEP_PIN);
784 784
         }
785 785
       }
786 786
  #if EXTRUDERS > 1
787 787
       if (e_steps[1] != 0) {
788
-        WRITE(E1_STEP_PIN, INVERT_E_STEP_PIN);
788
+        E1_STEP_WRITE(INVERT_E_STEP_PIN);
789 789
         if (e_steps[1] < 0) {
790
-          WRITE(E1_DIR_PIN, INVERT_E1_DIR);
790
+          E1_DIR_WRITE(INVERT_E1_DIR);
791 791
           e_steps[1]++;
792
-          WRITE(E1_STEP_PIN, !INVERT_E_STEP_PIN);
792
+          E1_STEP_WRITE(!INVERT_E_STEP_PIN);
793 793
         }
794 794
         else if (e_steps[1] > 0) {
795
-          WRITE(E1_DIR_PIN, !INVERT_E1_DIR);
795
+          E1_DIR_WRITE(!INVERT_E1_DIR);
796 796
           e_steps[1]--;
797
-          WRITE(E1_STEP_PIN, !INVERT_E_STEP_PIN);
797
+          E1_STEP_WRITE(!INVERT_E_STEP_PIN);
798 798
         }
799 799
       }
800 800
  #endif
801 801
  #if EXTRUDERS > 2
802 802
       if (e_steps[2] != 0) {
803
-        WRITE(E2_STEP_PIN, INVERT_E_STEP_PIN);
803
+        E2_STEP_WRITE(INVERT_E_STEP_PIN);
804 804
         if (e_steps[2] < 0) {
805
-          WRITE(E2_DIR_PIN, INVERT_E2_DIR);
805
+          E2_DIR_WRITE(INVERT_E2_DIR);
806 806
           e_steps[2]++;
807
-          WRITE(E2_STEP_PIN, !INVERT_E_STEP_PIN);
807
+          E2_STEP_WRITE(!INVERT_E_STEP_PIN);
808 808
         }
809 809
         else if (e_steps[2] > 0) {
810
-          WRITE(E2_DIR_PIN, !INVERT_E2_DIR);
810
+          E2_DIR_WRITE(!INVERT_E2_DIR);
811 811
           e_steps[2]--;
812
-          WRITE(E2_STEP_PIN, !INVERT_E_STEP_PIN);
812
+          E2_STEP_WRITE(!INVERT_E_STEP_PIN);
813 813
         }
814 814
       }
815 815
  #endif
816 816
  #if EXTRUDERS > 3
817 817
       if (e_steps[3] != 0) {
818
-        WRITE(E3_STEP_PIN, INVERT_E_STEP_PIN);
818
+        E3_STEP_WRITE(INVERT_E_STEP_PIN);
819 819
         if (e_steps[3] < 0) {
820
-          WRITE(E3_DIR_PIN, INVERT_E3_DIR);
820
+          E3_DIR_WRITE(INVERT_E3_DIR);
821 821
           e_steps[3]++;
822
-          WRITE(E3_STEP_PIN, !INVERT_E_STEP_PIN);
822
+          E3_STEP_WRITE(!INVERT_E_STEP_PIN);
823 823
         }
824 824
         else if (e_steps[3] > 0) {
825
-          WRITE(E3_DIR_PIN, !INVERT_E3_DIR);
825
+          E3_DIR_WRITE(!INVERT_E3_DIR);
826 826
           e_steps[3]--;
827
-          WRITE(E3_STEP_PIN, !INVERT_E_STEP_PIN);
827
+          E3_STEP_WRITE(!INVERT_E_STEP_PIN);
828 828
         }
829 829
       }
830 830
  #endif
@@ -840,81 +840,81 @@ void st_init()
840 840
 
841 841
   //Initialize Dir Pins
842 842
   #if defined(X_DIR_PIN) && X_DIR_PIN > -1
843
-    SET_OUTPUT(X_DIR_PIN);
843
+    X_DIR_INIT;
844 844
   #endif
845 845
   #if defined(X2_DIR_PIN) && X2_DIR_PIN > -1
846
-    SET_OUTPUT(X2_DIR_PIN);
846
+    X2_DIR_INIT;
847 847
   #endif
848 848
   #if defined(Y_DIR_PIN) && Y_DIR_PIN > -1
849
-    SET_OUTPUT(Y_DIR_PIN);
849
+    Y_DIR_INIT;
850 850
 		
851 851
 	#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_DIR_PIN) && (Y2_DIR_PIN > -1)
852
-	  SET_OUTPUT(Y2_DIR_PIN);
852
+	  Y2_DIR_INIT;
853 853
 	#endif
854 854
   #endif
855 855
   #if defined(Z_DIR_PIN) && Z_DIR_PIN > -1
856
-    SET_OUTPUT(Z_DIR_PIN);
856
+    Z_DIR_INIT;
857 857
 
858 858
     #if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_DIR_PIN) && (Z2_DIR_PIN > -1)
859
-      SET_OUTPUT(Z2_DIR_PIN);
859
+      Z2_DIR_INIT;
860 860
     #endif
861 861
   #endif
862 862
   #if defined(E0_DIR_PIN) && E0_DIR_PIN > -1
863
-    SET_OUTPUT(E0_DIR_PIN);
863
+    E0_DIR_INIT;
864 864
   #endif
865 865
   #if defined(E1_DIR_PIN) && (E1_DIR_PIN > -1)
866
-    SET_OUTPUT(E1_DIR_PIN);
866
+    E1_DIR_INIT;
867 867
   #endif
868 868
   #if defined(E2_DIR_PIN) && (E2_DIR_PIN > -1)
869
-    SET_OUTPUT(E2_DIR_PIN);
869
+    E2_DIR_INIT;
870 870
   #endif
871 871
   #if defined(E3_DIR_PIN) && (E3_DIR_PIN > -1)
872
-    SET_OUTPUT(E3_DIR_PIN);
872
+    E3_DIR_INIT;
873 873
   #endif
874 874
 
875 875
   //Initialize Enable Pins - steppers default to disabled.
876 876
 
877 877
   #if defined(X_ENABLE_PIN) && X_ENABLE_PIN > -1
878
-    SET_OUTPUT(X_ENABLE_PIN);
879
-    if(!X_ENABLE_ON) WRITE(X_ENABLE_PIN,HIGH);
878
+    X_ENABLE_INIT;
879
+    if(!X_ENABLE_ON) X_ENABLE_WRITE(HIGH);
880 880
   #endif
881 881
   #if defined(X2_ENABLE_PIN) && X2_ENABLE_PIN > -1
882
-    SET_OUTPUT(X2_ENABLE_PIN);
883
-    if(!X_ENABLE_ON) WRITE(X2_ENABLE_PIN,HIGH);
882
+    X2_ENABLE_INIT;
883
+    if(!X_ENABLE_ON) X2_ENABLE_WRITE(HIGH);
884 884
   #endif
885 885
   #if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1
886
-    SET_OUTPUT(Y_ENABLE_PIN);
887
-    if(!Y_ENABLE_ON) WRITE(Y_ENABLE_PIN,HIGH);
886
+    Y_ENABLE_INIT;
887
+    if(!Y_ENABLE_ON) Y_ENABLE_WRITE(HIGH);
888 888
 	
889 889
 	#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_ENABLE_PIN) && (Y2_ENABLE_PIN > -1)
890
-	  SET_OUTPUT(Y2_ENABLE_PIN);
891
-	  if(!Y_ENABLE_ON) WRITE(Y2_ENABLE_PIN,HIGH);
890
+	  Y2_ENABLE_INIT;
891
+	  if(!Y_ENABLE_ON) Y2_ENABLE_WRITE(HIGH);
892 892
 	#endif
893 893
   #endif
894 894
   #if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1
895
-    SET_OUTPUT(Z_ENABLE_PIN);
896
-    if(!Z_ENABLE_ON) WRITE(Z_ENABLE_PIN,HIGH);
895
+    Z_ENABLE_INIT;
896
+    if(!Z_ENABLE_ON) Z_ENABLE_WRITE(HIGH);
897 897
 
898 898
     #if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_ENABLE_PIN) && (Z2_ENABLE_PIN > -1)
899
-      SET_OUTPUT(Z2_ENABLE_PIN);
900
-      if(!Z_ENABLE_ON) WRITE(Z2_ENABLE_PIN,HIGH);
899
+      Z2_ENABLE_INIT;
900
+      if(!Z_ENABLE_ON) Z2_ENABLE_WRITE(HIGH);
901 901
     #endif
902 902
   #endif
903 903
   #if defined(E0_ENABLE_PIN) && (E0_ENABLE_PIN > -1)
904
-    SET_OUTPUT(E0_ENABLE_PIN);
905
-    if(!E_ENABLE_ON) WRITE(E0_ENABLE_PIN,HIGH);
904
+    E0_ENABLE_INIT;
905
+    if(!E_ENABLE_ON) E0_ENABLE_WRITE(HIGH);
906 906
   #endif
907 907
   #if defined(E1_ENABLE_PIN) && (E1_ENABLE_PIN > -1)
908
-    SET_OUTPUT(E1_ENABLE_PIN);
909
-    if(!E_ENABLE_ON) WRITE(E1_ENABLE_PIN,HIGH);
908
+    E1_ENABLE_INIT;
909
+    if(!E_ENABLE_ON) E1_ENABLE_WRITE(HIGH);
910 910
   #endif
911 911
   #if defined(E2_ENABLE_PIN) && (E2_ENABLE_PIN > -1)
912
-    SET_OUTPUT(E2_ENABLE_PIN);
913
-    if(!E_ENABLE_ON) WRITE(E2_ENABLE_PIN,HIGH);
912
+    E2_ENABLE_INIT;
913
+    if(!E_ENABLE_ON) E2_ENABLE_WRITE(HIGH);
914 914
   #endif
915 915
   #if defined(E3_ENABLE_PIN) && (E3_ENABLE_PIN > -1)
916
-    SET_OUTPUT(E3_ENABLE_PIN);
917
-    if(!E_ENABLE_ON) WRITE(E3_ENABLE_PIN,HIGH);
916
+    E3_ENABLE_INIT;
917
+    if(!E_ENABLE_ON) E3_ENABLE_WRITE(HIGH);
918 918
   #endif
919 919
 
920 920
   //endstops and pullups
@@ -964,51 +964,51 @@ void st_init()
964 964
 
965 965
   //Initialize Step Pins
966 966
   #if defined(X_STEP_PIN) && (X_STEP_PIN > -1)
967
-    SET_OUTPUT(X_STEP_PIN);
968
-    WRITE(X_STEP_PIN,INVERT_X_STEP_PIN);
967
+    X_STEP_INIT;
968
+    X_STEP_WRITE(INVERT_X_STEP_PIN);
969 969
     disable_x();
970 970
   #endif
971 971
   #if defined(X2_STEP_PIN) && (X2_STEP_PIN > -1)
972
-    SET_OUTPUT(X2_STEP_PIN);
973
-    WRITE(X2_STEP_PIN,INVERT_X_STEP_PIN);
972
+    X2_STEP_INIT;
973
+    X2_STEP_WRITE(INVERT_X_STEP_PIN);
974 974
     disable_x();
975 975
   #endif
976 976
   #if defined(Y_STEP_PIN) && (Y_STEP_PIN > -1)
977
-    SET_OUTPUT(Y_STEP_PIN);
978
-    WRITE(Y_STEP_PIN,INVERT_Y_STEP_PIN);
977
+    Y_STEP_INIT;
978
+    Y_STEP_WRITE(INVERT_Y_STEP_PIN);
979 979
     #if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_STEP_PIN) && (Y2_STEP_PIN > -1)
980
-      SET_OUTPUT(Y2_STEP_PIN);
981
-      WRITE(Y2_STEP_PIN,INVERT_Y_STEP_PIN);
980
+      Y2_STEP_INIT;
981
+      Y2_STEP_WRITE(INVERT_Y_STEP_PIN);
982 982
     #endif
983 983
     disable_y();
984 984
   #endif
985 985
   #if defined(Z_STEP_PIN) && (Z_STEP_PIN > -1)
986
-    SET_OUTPUT(Z_STEP_PIN);
987
-    WRITE(Z_STEP_PIN,INVERT_Z_STEP_PIN);
986
+    Z_STEP_INIT;
987
+    Z_STEP_WRITE(INVERT_Z_STEP_PIN);
988 988
     #if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_STEP_PIN) && (Z2_STEP_PIN > -1)
989
-      SET_OUTPUT(Z2_STEP_PIN);
990
-      WRITE(Z2_STEP_PIN,INVERT_Z_STEP_PIN);
989
+      Z2_STEP_INIT;
990
+      Z2_STEP_WRITE(INVERT_Z_STEP_PIN);
991 991
     #endif
992 992
     disable_z();
993 993
   #endif
994 994
   #if defined(E0_STEP_PIN) && (E0_STEP_PIN > -1)
995
-    SET_OUTPUT(E0_STEP_PIN);
996
-    WRITE(E0_STEP_PIN,INVERT_E_STEP_PIN);
995
+    E0_STEP_INIT;
996
+    E0_STEP_WRITE(INVERT_E_STEP_PIN);
997 997
     disable_e0();
998 998
   #endif
999 999
   #if defined(E1_STEP_PIN) && (E1_STEP_PIN > -1)
1000
-    SET_OUTPUT(E1_STEP_PIN);
1001
-    WRITE(E1_STEP_PIN,INVERT_E_STEP_PIN);
1000
+    E1_STEP_INIT;
1001
+    E1_STEP_WRITE(INVERT_E_STEP_PIN);
1002 1002
     disable_e1();
1003 1003
   #endif
1004 1004
   #if defined(E2_STEP_PIN) && (E2_STEP_PIN > -1)
1005
-    SET_OUTPUT(E2_STEP_PIN);
1006
-    WRITE(E2_STEP_PIN,INVERT_E_STEP_PIN);
1005
+    E2_STEP_INIT;
1006
+    E2_STEP_WRITE(INVERT_E_STEP_PIN);
1007 1007
     disable_e2();
1008 1008
   #endif
1009 1009
   #if defined(E3_STEP_PIN) && (E3_STEP_PIN > -1)
1010
-    SET_OUTPUT(E3_STEP_PIN);
1011
-    WRITE(E3_STEP_PIN,INVERT_E_STEP_PIN);
1010
+    E3_STEP_INIT;
1011
+    E3_STEP_WRITE(INVERT_E_STEP_PIN);
1012 1012
     disable_e3();
1013 1013
   #endif
1014 1014
 
@@ -1127,31 +1127,31 @@ void babystep(const uint8_t axis,const bool direction)
1127 1127
   case X_AXIS:
1128 1128
   {
1129 1129
     enable_x();   
1130
-    uint8_t old_x_dir_pin= READ(X_DIR_PIN);  //if dualzstepper, both point to same direction.
1130
+    uint8_t old_x_dir_pin= X_DIR_READ;  //if dualzstepper, both point to same direction.
1131 1131
    
1132 1132
     //setup new step
1133
-    WRITE(X_DIR_PIN,(INVERT_X_DIR)^direction);
1133
+    X_DIR_WRITE((INVERT_X_DIR)^direction);
1134 1134
     #ifdef DUAL_X_CARRIAGE
1135
-      WRITE(X2_DIR_PIN,(INVERT_X_DIR)^direction);
1135
+      X2_DIR_WRITE((INVERT_X_DIR)^direction);
1136 1136
     #endif
1137 1137
     
1138 1138
     //perform step 
1139
-    WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); 
1139
+    X_STEP_WRITE(!INVERT_X_STEP_PIN); 
1140 1140
     #ifdef DUAL_X_CARRIAGE
1141
-      WRITE(X2_STEP_PIN, !INVERT_X_STEP_PIN);
1141
+      X2_STEP_WRITE(!INVERT_X_STEP_PIN);
1142 1142
     #endif
1143 1143
 
1144 1144
     _delay_us(1U); // wait 1 microsecond
1145 1145
 
1146
-    WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
1146
+    X_STEP_WRITE(INVERT_X_STEP_PIN);
1147 1147
     #ifdef DUAL_X_CARRIAGE
1148
-      WRITE(X2_STEP_PIN, INVERT_X_STEP_PIN);
1148
+      X2_STEP_WRITE(INVERT_X_STEP_PIN);
1149 1149
     #endif
1150 1150
 
1151 1151
     //get old pin state back.
1152
-    WRITE(X_DIR_PIN,old_x_dir_pin);
1152
+    X_DIR_WRITE(old_x_dir_pin);
1153 1153
     #ifdef DUAL_X_CARRIAGE
1154
-      WRITE(X2_DIR_PIN,old_x_dir_pin);
1154
+      X2_DIR_WRITE(old_x_dir_pin);
1155 1155
     #endif
1156 1156
 
1157 1157
   }
@@ -1159,31 +1159,31 @@ void babystep(const uint8_t axis,const bool direction)
1159 1159
   case Y_AXIS:
1160 1160
   {
1161 1161
     enable_y();   
1162
-    uint8_t old_y_dir_pin= READ(Y_DIR_PIN);  //if dualzstepper, both point to same direction.
1162
+    uint8_t old_y_dir_pin= Y_DIR_READ;  //if dualzstepper, both point to same direction.
1163 1163
    
1164 1164
     //setup new step
1165
-    WRITE(Y_DIR_PIN,(INVERT_Y_DIR)^direction);
1165
+    Y_DIR_WRITE((INVERT_Y_DIR)^direction);
1166 1166
     #ifdef DUAL_Y_CARRIAGE
1167
-      WRITE(Y2_DIR_PIN,(INVERT_Y_DIR)^direction);
1167
+      Y2_DIR_WRITE((INVERT_Y_DIR)^direction);
1168 1168
     #endif
1169 1169
     
1170 1170
     //perform step 
1171
-    WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); 
1171
+    Y_STEP_WRITE(!INVERT_Y_STEP_PIN); 
1172 1172
     #ifdef DUAL_Y_CARRIAGE
1173
-      WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN);
1173
+      Y2_STEP_WRITE( !INVERT_Y_STEP_PIN);
1174 1174
     #endif
1175 1175
 
1176 1176
     _delay_us(1U); // wait 1 microsecond
1177 1177
 
1178
-    WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
1178
+    Y_STEP_WRITE(INVERT_Y_STEP_PIN);
1179 1179
     #ifdef DUAL_Y_CARRIAGE
1180
-      WRITE(Y2_STEP_PIN, INVERT_Y_STEP_PIN);
1180
+      Y2_STEP_WRITE(INVERT_Y_STEP_PIN);
1181 1181
     #endif
1182 1182
 
1183 1183
     //get old pin state back.
1184
-    WRITE(Y_DIR_PIN,old_y_dir_pin);
1184
+    Y_DIR_WRITE(old_y_dir_pin);
1185 1185
     #ifdef DUAL_Y_CARRIAGE
1186
-      WRITE(Y2_DIR_PIN,old_y_dir_pin);
1186
+      Y2_DIR_WRITE(old_y_dir_pin);
1187 1187
     #endif
1188 1188
 
1189 1189
   }
@@ -1193,29 +1193,29 @@ void babystep(const uint8_t axis,const bool direction)
1193 1193
   case Z_AXIS:
1194 1194
   {
1195 1195
     enable_z();
1196
-    uint8_t old_z_dir_pin= READ(Z_DIR_PIN);  //if dualzstepper, both point to same direction.
1196
+    uint8_t old_z_dir_pin= Z_DIR_READ;  //if dualzstepper, both point to same direction.
1197 1197
     //setup new step
1198
-    WRITE(Z_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z);
1198
+    Z_DIR_WRITE((INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z);
1199 1199
     #ifdef Z_DUAL_STEPPER_DRIVERS
1200
-      WRITE(Z2_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z);
1200
+      Z2_DIR_WRITE((INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z);
1201 1201
     #endif
1202 1202
     //perform step 
1203
-    WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); 
1203
+    Z_STEP_WRITE(!INVERT_Z_STEP_PIN); 
1204 1204
     #ifdef Z_DUAL_STEPPER_DRIVERS
1205
-      WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN);
1205
+      Z2_STEP_WRITE( !INVERT_Z_STEP_PIN);
1206 1206
     #endif
1207 1207
 
1208 1208
     _delay_us(1U); // wait 1 microsecond
1209 1209
 
1210
-    WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN);
1210
+    Z_STEP_WRITE( INVERT_Z_STEP_PIN);
1211 1211
     #ifdef Z_DUAL_STEPPER_DRIVERS
1212
-      WRITE(Z2_STEP_PIN, INVERT_Z_STEP_PIN);
1212
+      Z2_STEP_WRITE(INVERT_Z_STEP_PIN);
1213 1213
     #endif
1214 1214
 
1215 1215
     //get old pin state back.
1216
-    WRITE(Z_DIR_PIN,old_z_dir_pin);
1216
+    Z_DIR_WRITE(old_z_dir_pin);
1217 1217
     #ifdef Z_DUAL_STEPPER_DRIVERS
1218
-      WRITE(Z2_DIR_PIN,old_z_dir_pin);
1218
+      Z2_DIR_WRITE(old_z_dir_pin);
1219 1219
     #endif
1220 1220
 
1221 1221
   }
@@ -1226,29 +1226,29 @@ void babystep(const uint8_t axis,const bool direction)
1226 1226
     enable_x();
1227 1227
     enable_y();
1228 1228
     enable_z();
1229
-    uint8_t old_x_dir_pin= READ(X_DIR_PIN);  
1230
-    uint8_t old_y_dir_pin= READ(Y_DIR_PIN);  
1231
-    uint8_t old_z_dir_pin= READ(Z_DIR_PIN);  
1229
+    uint8_t old_x_dir_pin= X_DIR_READ;  
1230
+    uint8_t old_y_dir_pin= Y_DIR_READ;
1231
+    uint8_t old_z_dir_pin= Z_DIR_READ;
1232 1232
     //setup new step
1233
-    WRITE(X_DIR_PIN,(INVERT_X_DIR)^direction^BABYSTEP_INVERT_Z);
1234
-    WRITE(Y_DIR_PIN,(INVERT_Y_DIR)^direction^BABYSTEP_INVERT_Z);
1235
-    WRITE(Z_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z);
1233
+    X_DIR_WRITE((INVERT_X_DIR)^direction^BABYSTEP_INVERT_Z);
1234
+    Y_DIR_WRITE((INVERT_Y_DIR)^direction^BABYSTEP_INVERT_Z);
1235
+    Z_DIR_WRITE((INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z);
1236 1236
     
1237 1237
     //perform step 
1238
-    WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); 
1239
-    WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); 
1240
-    WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); 
1238
+    X_STEP_WRITE( !INVERT_X_STEP_PIN); 
1239
+    Y_STEP_WRITE(!INVERT_Y_STEP_PIN); 
1240
+    Z_STEP_WRITE(!INVERT_Z_STEP_PIN); 
1241 1241
     
1242 1242
     _delay_us(1U); // wait 1 microsecond
1243 1243
 
1244
-    WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); 
1245
-    WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); 
1246
-    WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN);
1244
+    X_STEP_WRITE(INVERT_X_STEP_PIN); 
1245
+    Y_STEP_WRITE(INVERT_Y_STEP_PIN); 
1246
+    Z_STEP_WRITE(INVERT_Z_STEP_PIN);
1247 1247
 
1248 1248
     //get old pin state back.
1249
-    WRITE(X_DIR_PIN,old_x_dir_pin);
1250
-    WRITE(Y_DIR_PIN,old_y_dir_pin);
1251
-    WRITE(Z_DIR_PIN,old_z_dir_pin);
1249
+    X_DIR_WRITE(old_x_dir_pin);
1250
+    Y_DIR_WRITE(old_y_dir_pin);
1251
+    Z_DIR_WRITE(old_z_dir_pin);
1252 1252
 
1253 1253
   }
1254 1254
   break;

+ 16
- 15
Marlin/stepper.h ファイルの表示

@@ -22,30 +22,31 @@
22 22
 #define stepper_h 
23 23
 
24 24
 #include "planner.h"
25
+#include "stepper_indirection.h"
25 26
 
26 27
 #if EXTRUDERS > 3
27
-  #define WRITE_E_STEP(v) { if(current_block->active_extruder == 3) { WRITE(E3_STEP_PIN, v); } else { if(current_block->active_extruder == 2) { WRITE(E2_STEP_PIN, v); } else { if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }}}}
28
-  #define NORM_E_DIR() { if(current_block->active_extruder == 3) { WRITE(E3_DIR_PIN, !INVERT_E3_DIR); } else { if(current_block->active_extruder == 2) { WRITE(E2_DIR_PIN, !INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }}}}
29
-  #define REV_E_DIR() { if(current_block->active_extruder == 3) { WRITE(E3_DIR_PIN, INVERT_E3_DIR); } else { if(current_block->active_extruder == 2) { WRITE(E2_DIR_PIN, INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }}}}
28
+  #define WRITE_E_STEP(v) { if(current_block->active_extruder == 3) { E3_STEP_WRITE(v); } else { if(current_block->active_extruder == 2) { E2_STEP_WRITE(v); } else { if(current_block->active_extruder == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}}}
29
+  #define NORM_E_DIR() { if(current_block->active_extruder == 3) { E3_DIR_WRITE( !INVERT_E3_DIR); } else { 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); }}}}
30
+  #define REV_E_DIR() { if(current_block->active_extruder == 3) { E3_DIR_WRITE(INVERT_E3_DIR); } else { 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); }}}}
30 31
 #elif EXTRUDERS > 2
31
-  #define WRITE_E_STEP(v) { if(current_block->active_extruder == 2) { WRITE(E2_STEP_PIN, v); } else { if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }}}
32
-  #define NORM_E_DIR() { if(current_block->active_extruder == 2) { WRITE(E2_DIR_PIN, !INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }}}
33
-  #define REV_E_DIR() { if(current_block->active_extruder == 2) { WRITE(E2_DIR_PIN, INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }}}
32
+  #define WRITE_E_STEP(v) { if(current_block->active_extruder == 2) { E2_STEP_WRITE(v); } else { if(current_block->active_extruder == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}}
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 35
 #elif EXTRUDERS > 1
35 36
   #ifndef DUAL_X_CARRIAGE
36
-    #define WRITE_E_STEP(v) { if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }}
37
-    #define NORM_E_DIR() { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }}
38
-    #define REV_E_DIR() { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }}
37
+    #define WRITE_E_STEP(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); }}
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 40
   #else
40 41
     extern bool extruder_duplication_enabled;
41
-    #define WRITE_E_STEP(v) { if(extruder_duplication_enabled) { WRITE(E0_STEP_PIN, v); WRITE(E1_STEP_PIN, v); } else if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }}
42
-    #define NORM_E_DIR() { if(extruder_duplication_enabled) { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }}
43
-    #define REV_E_DIR() { if(extruder_duplication_enabled) { WRITE(E0_DIR_PIN, INVERT_E0_DIR); WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }}
42
+    #define WRITE_E_STEP(v) { if(extruder_duplication_enabled) { E0_STEP_WRITE(v); E1_STEP_WRITE(v); } else if(current_block->active_extruder == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}
43
+    #define NORM_E_DIR() { if(extruder_duplication_enabled) { E0_DIR_WRITE(!INVERT_E0_DIR); E1_DIR_WRITE(!INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}
44
+    #define REV_E_DIR() { if(extruder_duplication_enabled) { E0_DIR_WRITE(INVERT_E0_DIR); E1_DIR_WRITE(INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}
44 45
   #endif  
45 46
 #else
46
-  #define WRITE_E_STEP(v) WRITE(E0_STEP_PIN, v)
47
-  #define NORM_E_DIR() WRITE(E0_DIR_PIN, !INVERT_E0_DIR)
48
-  #define REV_E_DIR() WRITE(E0_DIR_PIN, INVERT_E0_DIR)
47
+  #define WRITE_E_STEP(v) E0_STEP_WRITE(v)
48
+  #define NORM_E_DIR() E0_DIR_WRITE(!INVERT_E0_DIR)
49
+  #define REV_E_DIR() E0_DIR_WRITE(INVERT_E0_DIR)
49 50
 #endif
50 51
 
51 52
 #ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED

+ 156
- 0
Marlin/stepper_indirection.h ファイルの表示

@@ -0,0 +1,156 @@
1
+/*
2
+  stepper_indirection.h - stepper motor driver indirection macros
3
+  to allow some stepper functions to be done via SPI/I2c instead of direct pin manipulation
4
+  Part of Marlin
5
+
6
+  Copyright (c) 2015 Dominik Wenger
7
+
8
+  Marlin is free software: you can redistribute it and/or modify
9
+  it under the terms of the GNU General Public License as published by
10
+  the Free Software Foundation, either version 3 of the License, or
11
+  (at your option) any later version.
12
+
13
+  Marlin is distributed in the hope that it will be useful,
14
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+  GNU General Public License for more details.
17
+
18
+  You should have received a copy of the GNU General Public License
19
+  along with Marlin.  If not, see <http://www.gnu.org/licenses/>.
20
+*/
21
+
22
+#ifndef STEPPER_INDIRECTION_H
23
+#define STEPPER_INDIRECTION_H
24
+
25
+// X motor
26
+#define X_STEP_INIT SET_OUTPUT(X_STEP_PIN)
27
+#define X_STEP_WRITE(STATE) WRITE(X_STEP_PIN,STATE)
28
+#define X_STEP_READ READ(X_STEP_PIN)
29
+
30
+#define X_DIR_INIT SET_OUTPUT(X_DIR_PIN)
31
+#define X_DIR_WRITE(STATE) WRITE(X_DIR_PIN,STATE)
32
+#define X_DIR_READ READ(X_DIR_PIN)
33
+
34
+#define X_ENABLE_INIT SET_OUTPUT(X_ENABLE_PIN)
35
+#define X_ENABLE_WRITE(STATE) WRITE(X_ENABLE_PIN,STATE)
36
+#define X_ENABLE_READ READ(X_ENABLE_PIN)
37
+
38
+// X2 motor
39
+#define X2_STEP_INIT SET_OUTPUT(X2_STEP_PIN)
40
+#define X2_STEP_WRITE(STATE) WRITE(X2_STEP_PIN,STATE)
41
+#define X2_STEP_READ READ(X2_STEP_PIN)
42
+
43
+#define X2_DIR_INIT SET_OUTPUT(X2_DIR_PIN)
44
+#define X2_DIR_WRITE(STATE) WRITE(X2_DIR_PIN,STATE)
45
+#define X2_DIR_READ READ(X_DIR_PIN)
46
+
47
+#define X2_ENABLE_INIT SET_OUTPUT(X2_ENABLE_PIN)
48
+#define X2_ENABLE_WRITE(STATE) WRITE(X2_ENABLE_PIN,STATE)
49
+#define X2_ENABLE_READ READ(X_ENABLE_PIN)
50
+
51
+// Y motor
52
+#define Y_STEP_INIT SET_OUTPUT(Y_STEP_PIN)
53
+#define Y_STEP_WRITE(STATE) WRITE(Y_STEP_PIN,STATE)
54
+#define Y_STEP_READ READ(Y_STEP_PIN)
55
+
56
+#define Y_DIR_INIT SET_OUTPUT(Y_DIR_PIN)
57
+#define Y_DIR_WRITE(STATE) WRITE(Y_DIR_PIN,STATE)
58
+#define Y_DIR_READ READ(Y_DIR_PIN)
59
+
60
+#define Y_ENABLE_INIT SET_OUTPUT(Y_ENABLE_PIN)
61
+#define Y_ENABLE_WRITE(STATE) WRITE(Y_ENABLE_PIN,STATE)
62
+#define Y_ENABLE_READ READ(Y_ENABLE_PIN)
63
+
64
+// Y2 motor
65
+#define Y2_STEP_INIT SET_OUTPUT(Y2_STEP_PIN)
66
+#define Y2_STEP_WRITE(STATE) WRITE(Y2_STEP_PIN,STATE)
67
+#define Y2_STEP_READ READ(Y2_STEP_PIN)
68
+
69
+#define Y2_DIR_INIT SET_OUTPUT(Y2_DIR_PIN)
70
+#define Y2_DIR_WRITE(STATE) WRITE(Y2_DIR_PIN,STATE)
71
+#define Y2_DIR_READ READ(Y2_DIR_PIN)
72
+
73
+#define Y2_ENABLE_INIT SET_OUTPUT(Y2_ENABLE_PIN)
74
+#define Y2_ENABLE_WRITE(STATE) WRITE(Y2_ENABLE_PIN,STATE)
75
+#define Y2_ENABLE_READ READ(Y2_ENABLE_PIN)
76
+
77
+// Z motor
78
+#define Z_STEP_INIT SET_OUTPUT(Z_STEP_PIN)
79
+#define Z_STEP_WRITE(STATE) WRITE(Z_STEP_PIN,STATE)
80
+#define Z_STEP_READ READ(Z_STEP_PIN)
81
+
82
+#define Z_DIR_INIT SET_OUTPUT(Z_DIR_PIN)
83
+#define Z_DIR_WRITE(STATE) WRITE(Z_DIR_PIN,STATE)
84
+#define Z_DIR_READ READ(Z_DIR_PIN)
85
+
86
+#define Z_ENABLE_INIT SET_OUTPUT(Z_ENABLE_PIN)
87
+#define Z_ENABLE_WRITE(STATE) WRITE(Z_ENABLE_PIN,STATE)
88
+#define Z_ENABLE_READ READ(Z_ENABLE_PIN)
89
+
90
+// Z2 motor
91
+#define Z2_STEP_INIT SET_OUTPUT(Z2_STEP_PIN)
92
+#define Z2_STEP_WRITE(STATE) WRITE(Z2_STEP_PIN,STATE)
93
+#define Z2_STEP_READ READ(Z2_STEP_PIN)
94
+
95
+#define Z2_DIR_INIT SET_OUTPUT(Z2_DIR_PIN)
96
+#define Z2_DIR_WRITE(STATE) WRITE(Z2_DIR_PIN,STATE)
97
+#define Z2_DIR_READ READ(Z2_DIR_PIN)
98
+
99
+#define Z2_ENABLE_INIT SET_OUTPUT(Z2_ENABLE_PIN)
100
+#define Z2_ENABLE_WRITE(STATE) WRITE(Z2_ENABLE_PIN,STATE)
101
+#define Z2_ENABLE_READ READ(Z2_ENABLE_PIN)
102
+
103
+// E0 motor
104
+#define E0_STEP_INIT SET_OUTPUT(E0_STEP_PIN)
105
+#define E0_STEP_WRITE(STATE) WRITE(E0_STEP_PIN,STATE)
106
+#define E0_STEP_READ READ(E0_STEP_PIN)
107
+
108
+#define E0_DIR_INIT SET_OUTPUT(E0_DIR_PIN)
109
+#define E0_DIR_WRITE(STATE) WRITE(E0_DIR_PIN,STATE)
110
+#define E0_DIR_READ READ(E0_DIR_PIN)
111
+
112
+#define E0_ENABLE_INIT SET_OUTPUT(E0_ENABLE_PIN)
113
+#define E0_ENABLE_WRITE(STATE) WRITE(E0_ENABLE_PIN,STATE)
114
+#define E0_ENABLE_READ READ(E0_ENABLE_PIN)
115
+
116
+// E1 motor
117
+#define E1_STEP_INIT SET_OUTPUT(E1_STEP_PIN)
118
+#define E1_STEP_WRITE(STATE) WRITE(E1_STEP_PIN,STATE)
119
+#define E1_STEP_READ READ(E1_STEP_PIN)
120
+
121
+#define E1_DIR_INIT SET_OUTPUT(E1_DIR_PIN)
122
+#define E1_DIR_WRITE(STATE) WRITE(E1_DIR_PIN,STATE)
123
+#define E1_DIR_READ READ(E1_DIR_PIN)
124
+
125
+#define E1_ENABLE_INIT SET_OUTPUT(E1_ENABLE_PIN)
126
+#define E1_ENABLE_WRITE(STATE) WRITE(E1_ENABLE_PIN,STATE)
127
+#define E1_ENABLE_READ READ(E1_ENABLE_PIN)
128
+
129
+// E2 motor
130
+#define E2_STEP_INIT SET_OUTPUT(E2_STEP_PIN)
131
+#define E2_STEP_WRITE(STATE) WRITE(E2_STEP_PIN,STATE)
132
+#define E2_STEP_READ READ(E2_STEP_PIN)
133
+
134
+#define E2_DIR_INIT SET_OUTPUT(E2_DIR_PIN)
135
+#define E2_DIR_WRITE(STATE) WRITE(E2_DIR_PIN,STATE)
136
+#define E2_DIR_READ READ(E2_DIR_PIN)
137
+
138
+#define E2_ENABLE_INIT SET_OUTPUT(E2_ENABLE_PIN)
139
+#define E2_ENABLE_WRITE(STATE) WRITE(E2_ENABLE_PIN,STATE)
140
+#define E2_ENABLE_READ READ(E2_ENABLE_PIN)
141
+
142
+// E3 motor
143
+#define E3_STEP_INIT SET_OUTPUT(E3_STEP_PIN)
144
+#define E3_STEP_WRITE(STATE) WRITE(E3_STEP_PIN,STATE)
145
+#define E3_STEP_READ READ(E3_STEP_PIN)
146
+
147
+#define E3_DIR_INIT SET_OUTPUT(E3_DIR_PIN)
148
+#define E3_DIR_WRITE(STATE) WRITE(E3_DIR_PIN,STATE)
149
+#define E3_DIR_READ READ(E3_DIR_PIN)
150
+
151
+#define E3_ENABLE_INIT SET_OUTPUT(E3_ENABLE_PIN)
152
+#define E3_ENABLE_WRITE(STATE) WRITE(E3_ENABLE_PIN,STATE)
153
+#define E3_ENABLE_READ READ(E3_ENABLE_PIN)
154
+
155
+
156
+#endif

読み込み中…
キャンセル
保存