Procházet zdrojové kódy

Move TMC2130 g-codes to cpp

Scott Lahteine před 7 roky
rodič
revize
2e89685154

+ 4
- 17
Marlin/src/Marlin.cpp Zobrazit soubor

@@ -95,6 +95,10 @@
95 95
   #include "HAL/HAL_endstop_interrupts.h"
96 96
 #endif
97 97
 
98
+#if ENABLED(HAVE_TMC2130)
99
+  #include "feature/tmc2130.h"
100
+#endif
101
+
98 102
 #if ENABLED(SDSUPPORT)
99 103
   CardReader card;
100 104
 #endif
@@ -114,10 +118,6 @@
114 118
   #include "feature/bedlevel/bedlevel.h"
115 119
 #endif
116 120
 
117
-#if ENABLED(SENSORLESS_HOMING)
118
-  #include "feature/tmc2130.h"
119
-#endif
120
-
121 121
 #if ENABLED(ADVANCED_PAUSE_FEATURE) && ENABLED(PAUSE_PARK_NO_STEPPER_TIMEOUT)
122 122
   #include "feature/pause.h"
123 123
 #endif
@@ -359,19 +359,6 @@ void quickstop_stepper() {
359 359
   SYNC_PLAN_POSITION_KINEMATIC();
360 360
 }
361 361
 
362
-#if ENABLED(HAVE_TMC2130)
363
-  #include "feature/tmc2130.h"
364
-  #include "gcode/feature/trinamic/M906.h"
365
-  #include "gcode/feature/trinamic/M911.h"
366
-  #include "gcode/feature/trinamic/M912.h"
367
-  #if ENABLED(HYBRID_THRESHOLD)
368
-    #include "gcode/feature/trinamic/M913.h"
369
-  #endif
370
-  #if ENABLED(SENSORLESS_HOMING)
371
-    #include "gcode/feature/trinamic/M914.h"
372
-  #endif
373
-#endif
374
-
375 362
 #include "gcode/feature/digipot/M907.h"
376 363
 
377 364
 #if HAS_DIGIPOTSS || ENABLED(DAC_STEPPER_CURRENT)

Marlin/src/gcode/feature/trinamic/M906.h → Marlin/src/gcode/feature/trinamic/M906.cpp Zobrazit soubor

@@ -20,12 +20,20 @@
20 20
  *
21 21
  */
22 22
 
23
-static void tmc2130_get_current(TMC2130Stepper &st, const char name) {
23
+#include "../../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(HAVE_TMC2130)
26
+
27
+#include "../../gcode.h"
28
+#include "../../../feature/tmc2130.h"
29
+#include "../../../module/stepper_indirection.h"
30
+
31
+inline void tmc2130_get_current(TMC2130Stepper &st, const char name) {
24 32
   SERIAL_CHAR(name);
25 33
   SERIAL_ECHOPGM(" axis driver current: ");
26 34
   SERIAL_ECHOLN(st.getCurrent());
27 35
 }
28
-static void tmc2130_set_current(TMC2130Stepper &st, const char name, const int mA) {
36
+inline void tmc2130_set_current(TMC2130Stepper &st, const char name, const int mA) {
29 37
   st.setCurrent(mA, R_SENSE, HOLD_MULTIPLIER);
30 38
   tmc2130_get_current(st, name);
31 39
 }
@@ -37,7 +45,7 @@ static void tmc2130_set_current(TMC2130Stepper &st, const char name, const int m
37 45
  * S1: Enable automatic current control
38 46
  * S0: Disable
39 47
  */
40
-void gcode_M906() {
48
+void GcodeSuite::M906() {
41 49
   uint16_t values[XYZE];
42 50
   LOOP_XYZE(i)
43 51
     values[i] = parser.intval(axis_codes[i]);
@@ -63,3 +71,5 @@ void gcode_M906() {
63 71
     if (parser.seen('S')) auto_current_control = parser.value_bool();
64 72
   #endif
65 73
 }
74
+
75
+#endif // HAVE_TMC2130

Marlin/src/gcode/feature/trinamic/M911.h → Marlin/src/gcode/feature/trinamic/M911.cpp Zobrazit soubor

@@ -20,7 +20,15 @@
20 20
  *
21 21
  */
22 22
 
23
-static void tmc2130_report_otpw(TMC2130Stepper &st, const char name) {
23
+#include "../../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(HAVE_TMC2130)
26
+
27
+#include "../../gcode.h"
28
+#include "../../../feature/tmc2130.h"
29
+#include "../../../module/stepper_indirection.h"
30
+
31
+inline void tmc2130_report_otpw(TMC2130Stepper &st, const char name) {
24 32
   SERIAL_CHAR(name);
25 33
   SERIAL_ECHOPGM(" axis temperature prewarn triggered: ");
26 34
   serialprintPGM(st.getOTPW() ? PSTR("true") : PSTR("false"));
@@ -31,7 +39,7 @@ static void tmc2130_report_otpw(TMC2130Stepper &st, const char name) {
31 39
  * M911: Report TMC2130 stepper driver overtemperature pre-warn flag
32 40
  * The flag is held by the library and persist until manually cleared by M912
33 41
  */
34
-void gcode_M911() {
42
+void GcodeSuite::M911() {
35 43
   const bool reportX = parser.seen('X'), reportY = parser.seen('Y'), reportZ = parser.seen('Z'), reportE = parser.seen('E'),
36 44
            reportAll = (!reportX && !reportY && !reportZ && !reportE) || (reportX && reportY && reportZ && reportE);
37 45
   #if ENABLED(X_IS_TMC2130)
@@ -47,3 +55,5 @@ void gcode_M911() {
47 55
     if (reportE || reportAll) tmc2130_report_otpw(stepperE0, 'E');
48 56
   #endif
49 57
 }
58
+
59
+#endif // HAVE_TMC2130

Marlin/src/gcode/feature/trinamic/M912.h → Marlin/src/gcode/feature/trinamic/M912.cpp Zobrazit soubor

@@ -20,7 +20,15 @@
20 20
  *
21 21
  */
22 22
 
23
-static void tmc2130_clear_otpw(TMC2130Stepper &st, const char name) {
23
+#include "../../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(HAVE_TMC2130)
26
+
27
+#include "../../gcode.h"
28
+#include "../../../feature/tmc2130.h"
29
+#include "../../../module/stepper_indirection.h"
30
+
31
+inline void tmc2130_clear_otpw(TMC2130Stepper &st, const char name) {
24 32
   st.clear_otpw();
25 33
   SERIAL_CHAR(name);
26 34
   SERIAL_ECHOLNPGM(" prewarn flag cleared");
@@ -29,7 +37,7 @@ static void tmc2130_clear_otpw(TMC2130Stepper &st, const char name) {
29 37
 /**
30 38
  * M912: Clear TMC2130 stepper driver overtemperature pre-warn flag held by the library
31 39
  */
32
-void gcode_M912() {
40
+void GcodeSuite::M912() {
33 41
   const bool clearX = parser.seen('X'), clearY = parser.seen('Y'), clearZ = parser.seen('Z'), clearE = parser.seen('E'),
34 42
            clearAll = (!clearX && !clearY && !clearZ && !clearE) || (clearX && clearY && clearZ && clearE);
35 43
   #if ENABLED(X_IS_TMC2130)
@@ -45,3 +53,5 @@ void gcode_M912() {
45 53
     if (clearE || clearAll) tmc2130_clear_otpw(stepperE0, 'E');
46 54
   #endif
47 55
 }
56
+
57
+#endif // HAVE_TMC2130

Marlin/src/gcode/feature/trinamic/M913.h → Marlin/src/gcode/feature/trinamic/M913.cpp Zobrazit soubor

@@ -20,12 +20,21 @@
20 20
  *
21 21
  */
22 22
 
23
-static void tmc2130_get_pwmthrs(TMC2130Stepper &st, const char name, const uint16_t spmm) {
23
+#include "../../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(HAVE_TMC2130) && ENABLED(HYBRID_THRESHOLD)
26
+
27
+#include "../../gcode.h"
28
+#include "../../../feature/tmc2130.h"
29
+#include "../../../module/planner.h"
30
+#include "../../../module/stepper_indirection.h"
31
+
32
+inline void tmc2130_get_pwmthrs(TMC2130Stepper &st, const char name, const uint16_t spmm) {
24 33
   SERIAL_CHAR(name);
25 34
   SERIAL_ECHOPGM(" stealthChop max speed set to ");
26 35
   SERIAL_ECHOLN(12650000UL * st.microsteps() / (256 * st.stealth_max_speed() * spmm));
27 36
 }
28
-static void tmc2130_set_pwmthrs(TMC2130Stepper &st, const char name, const int32_t thrs, const uint32_t spmm) {
37
+inline void tmc2130_set_pwmthrs(TMC2130Stepper &st, const char name, const int32_t thrs, const uint32_t spmm) {
29 38
   st.stealth_max_speed(12650000UL * st.microsteps() / (256 * thrs * spmm));
30 39
   tmc2130_get_pwmthrs(st, name, spmm);
31 40
 }
@@ -33,7 +42,7 @@ static void tmc2130_set_pwmthrs(TMC2130Stepper &st, const char name, const int32
33 42
 /**
34 43
  * M913: Set HYBRID_THRESHOLD speed.
35 44
  */
36
-void gcode_M913() {
45
+void GcodeSuite::M913() {
37 46
   uint16_t values[XYZE];
38 47
   LOOP_XYZE(i)
39 48
     values[i] = parser.intval(axis_codes[i]);
@@ -55,3 +64,5 @@ void gcode_M913() {
55 64
     else tmc2130_get_pwmthrs(stepperE0, 'E', planner.axis_steps_per_mm[E_AXIS]);
56 65
   #endif
57 66
 }
67
+
68
+#endif // HAVE_TMC2130 && HYBRID_THRESHOLD

Marlin/src/gcode/feature/trinamic/M914.h → Marlin/src/gcode/feature/trinamic/M914.cpp Zobrazit soubor

@@ -20,12 +20,20 @@
20 20
  *
21 21
  */
22 22
 
23
-static void tmc2130_get_sgt(TMC2130Stepper &st, const char name) {
23
+#include "../../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(HAVE_TMC2130) && ENABLED(SENSORLESS_HOMING)
26
+
27
+#include "../../gcode.h"
28
+#include "../../../feature/tmc2130.h"
29
+#include "../../../module/stepper_indirection.h"
30
+
31
+inline void tmc2130_get_sgt(TMC2130Stepper &st, const char name) {
24 32
   SERIAL_CHAR(name);
25 33
   SERIAL_ECHOPGM(" driver homing sensitivity set to ");
26 34
   SERIAL_ECHOLN(st.sgt());
27 35
 }
28
-static void tmc2130_set_sgt(TMC2130Stepper &st, const char name, const int8_t sgt_val) {
36
+inline void tmc2130_set_sgt(TMC2130Stepper &st, const char name, const int8_t sgt_val) {
29 37
   st.sgt(sgt_val);
30 38
   tmc2130_get_sgt(st, name);
31 39
 }
@@ -33,7 +41,7 @@ static void tmc2130_set_sgt(TMC2130Stepper &st, const char name, const int8_t sg
33 41
 /**
34 42
  * M914: Set SENSORLESS_HOMING sensitivity.
35 43
  */
36
-void gcode_M914() {
44
+void GcodeSuite::M914() {
37 45
   #if ENABLED(X_IS_TMC2130)
38 46
     if (parser.seen(axis_codes[X_AXIS])) tmc2130_set_sgt(stepperX, 'X', parser.value_int());
39 47
     else tmc2130_get_sgt(stepperX, 'X');
@@ -43,3 +51,5 @@ void gcode_M914() {
43 51
     else tmc2130_get_sgt(stepperY, 'Y');
44 52
   #endif
45 53
 }
54
+
55
+#endif // HAVE_TMC2130 && SENSORLESS_HOMING

+ 5
- 26
Marlin/src/gcode/gcode.cpp Zobrazit soubor

@@ -122,11 +122,6 @@ extern void gcode_M165();
122 122
 extern void gcode_M350();
123 123
 extern void gcode_M351();
124 124
 extern void gcode_M355();
125
-extern void gcode_M906();
126
-extern void gcode_M911();
127
-extern void gcode_M912();
128
-extern void gcode_M913();
129
-extern void gcode_M914();
130 125
 extern void gcode_M907();
131 126
 extern void gcode_M908();
132 127
 extern void gcode_M909();
@@ -660,12 +655,6 @@ void GcodeSuite::process_next_command() {
660 655
         case 900: M900(); break;  // M900: Set advance K factor.
661 656
       #endif
662 657
 
663
-      #if ENABLED(HAVE_TMC2130)
664
-        case 906: // M906: Set motor current in milliamps using axis codes X, Y, Z, E
665
-          gcode_M906();
666
-          break;
667
-      #endif
668
-
669 658
       case 907: // M907: Set digital trimpot motor current using axis codes.
670 659
         gcode_M907();
671 660
         break;
@@ -691,24 +680,14 @@ void GcodeSuite::process_next_command() {
691 680
       #endif // HAS_DIGIPOTSS || DAC_STEPPER_CURRENT
692 681
 
693 682
       #if ENABLED(HAVE_TMC2130)
694
-        case 911: // M911: Report TMC2130 prewarn triggered flags
695
-          gcode_M911();
696
-          break;
697
-
698
-        case 912: // M911: Clear TMC2130 prewarn triggered flags
699
-          gcode_M912();
700
-          break;
701
-
683
+        case 906: M906(); break;    // M906: Set motor current in milliamps using axis codes X, Y, Z, E
684
+        case 911: M911(); break;    // M911: Report TMC2130 prewarn triggered flags
685
+        case 912: M912(); break;    // M912: Clear TMC2130 prewarn triggered flags
702 686
         #if ENABLED(HYBRID_THRESHOLD)
703
-          case 913: // M913: Set HYBRID_THRESHOLD speed.
704
-            gcode_M913();
705
-            break;
687
+          case 913: M913(); break;  // M913: Set HYBRID_THRESHOLD speed.
706 688
         #endif
707
-
708 689
         #if ENABLED(SENSORLESS_HOMING)
709
-          case 914: // M914: Set SENSORLESS_HOMING sensitivity.
710
-            gcode_M914();
711
-            break;
690
+          case 914: M914(); break;  // M914: Set SENSORLESS_HOMING sensitivity.
712 691
         #endif
713 692
       #endif
714 693
 

Loading…
Zrušit
Uložit