Browse Source

Define tmc variables where needed (#13918)

Ludy 6 years ago
parent
commit
c837e9250c
2 changed files with 16 additions and 14 deletions
  1. 15
    13
      Marlin/src/feature/tmc_util.cpp
  2. 1
    1
      buildroot/share/tests/LPC1769-tests

+ 15
- 13
Marlin/src/feature/tmc_util.cpp View File

@@ -85,12 +85,15 @@
85 85
     #endif
86 86
 
87 87
     static TMC_driver_data get_driver_data(TMC2130Stepper &st) {
88
-      constexpr uint16_t SG_RESULT_bm = 0x3FF; // 0:9
89
-      constexpr uint8_t STEALTH_bp = 14, CS_ACTUAL_sb = 16;
90
-      constexpr uint32_t CS_ACTUAL_bm = 0x1F0000; // 16:20
91
-      constexpr uint8_t STALL_GUARD_bp = 24, OT_bp = 25, OTPW_bp = 26;
88
+      constexpr uint8_t OT_bp = 25, OTPW_bp = 26;
92 89
       constexpr uint32_t S2G_bm = 0x18000000;
93
-      constexpr uint8_t STST_bp = 31;
90
+      #if ENABLED(TMC_DEBUG)
91
+        constexpr uint16_t SG_RESULT_bm = 0x3FF; // 0:9
92
+        constexpr uint8_t STEALTH_bp = 14;
93
+        constexpr uint32_t CS_ACTUAL_bm = 0x1F0000; // 16:20
94
+        constexpr uint8_t STALL_GUARD_bp = 24;
95
+        constexpr uint8_t STST_bp = 31;
96
+      #endif
94 97
       TMC_driver_data data;
95 98
       data.drv_status = st.DRV_STATUS();
96 99
       #ifdef __AVR__
@@ -112,13 +115,13 @@
112 115
           data.is_standstill = !!(spart & _BV(STST_bp - 24));
113 116
           data.sg_result_reasonable = !data.is_standstill; // sg_result has no reasonable meaning while standstill
114 117
         #endif
115
-        UNUSED(CS_ACTUAL_sb);
116 118
       #else // !__AVR__
117 119
 
118 120
         data.is_ot = !!(data.drv_status & _BV(OT_bp));
119 121
         data.is_otpw = !!(data.drv_status & _BV(OTPW_bp));
120 122
         data.is_s2g = !!(data.drv_status & S2G_bm);
121 123
         #if ENABLED(TMC_DEBUG)
124
+          constexpr uint8_t CS_ACTUAL_sb = 16;
122 125
           data.sg_result = data.drv_status & SG_RESULT_bm;
123 126
           data.is_stealth = !!(data.drv_status & _BV(STEALTH_bp));
124 127
           data.cs_actual = (data.drv_status & CS_ACTUAL_bm) >> CS_ACTUAL_sb;
@@ -143,15 +146,14 @@
143 146
     static TMC_driver_data get_driver_data(TMC2208Stepper &st) {
144 147
       constexpr uint8_t OTPW_bp = 0, OT_bp = 1;
145 148
       constexpr uint8_t S2G_bm = 0b11110; // 2..5
146
-      constexpr uint8_t CS_ACTUAL_sb = 16;
147
-      constexpr uint32_t CS_ACTUAL_bm = 0x1F0000; // 16:20
148
-      constexpr uint8_t STEALTH_bp = 30, STST_bp = 31;
149 149
       TMC_driver_data data;
150 150
       data.drv_status = st.DRV_STATUS();
151 151
       data.is_otpw = !!(data.drv_status & _BV(OTPW_bp));
152 152
       data.is_ot = !!(data.drv_status & _BV(OT_bp));
153 153
       data.is_s2g = !!(data.drv_status & S2G_bm);
154 154
       #if ENABLED(TMC_DEBUG)
155
+        constexpr uint32_t CS_ACTUAL_bm = 0x1F0000; // 16:20
156
+        constexpr uint8_t STEALTH_bp = 30, STST_bp = 31;
155 157
         #ifdef __AVR__
156 158
           // 8-bit optimization saves up to 12 bytes of PROGMEM per axis
157 159
           uint8_t spart = data.drv_status >> 16;
@@ -159,8 +161,8 @@
159 161
           spart = data.drv_status >> 24;
160 162
           data.is_stealth = !!(spart & _BV(STEALTH_bp - 24));
161 163
           data.is_standstill = !!(spart & _BV(STST_bp - 24));
162
-          UNUSED(CS_ACTUAL_sb);
163 164
         #else
165
+          constexpr uint8_t CS_ACTUAL_sb = 16;
164 166
           data.cs_actual = (data.drv_status & CS_ACTUAL_bm) >> CS_ACTUAL_sb;
165 167
           data.is_stealth = !!(data.drv_status & _BV(STEALTH_bp));
166 168
           data.is_standstill = !!(data.drv_status & _BV(STST_bp));
@@ -181,11 +183,8 @@
181 183
     #endif
182 184
 
183 185
     static TMC_driver_data get_driver_data(TMC2660Stepper &st) {
184
-      constexpr uint8_t STALL_GUARD_bp = 0;
185 186
       constexpr uint8_t OT_bp = 1, OTPW_bp = 2;
186 187
       constexpr uint8_t S2G_bm = 0b11000;
187
-      constexpr uint8_t STST_bp = 7, SG_RESULT_sp = 10;
188
-      constexpr uint32_t SG_RESULT_bm = 0xFFC00; // 10:19
189 188
       TMC_driver_data data;
190 189
       data.drv_status = st.DRVSTATUS();
191 190
       uint8_t spart = data.drv_status & 0xFF;
@@ -193,6 +192,9 @@
193 192
       data.is_ot = !!(spart & _BV(OT_bp));
194 193
       data.is_s2g = !!(data.drv_status & S2G_bm);
195 194
       #if ENABLED(TMC_DEBUG)
195
+        constexpr uint8_t STALL_GUARD_bp = 0;
196
+        constexpr uint8_t STST_bp = 7, SG_RESULT_sp = 10;
197
+        constexpr uint32_t SG_RESULT_bm = 0xFFC00; // 10:19
196 198
         data.is_stall = !!(spart & _BV(STALL_GUARD_bp));
197 199
         data.is_standstill = !!(spart & _BV(STST_bp));
198 200
         data.sg_result = (data.drv_status & SG_RESULT_bm) >> SG_RESULT_sp;

+ 1
- 1
buildroot/share/tests/LPC1769-tests View File

@@ -47,7 +47,7 @@ opt_disable Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN
47 47
 opt_set X_DRIVER_TYPE TMC2130
48 48
 opt_set Y_DRIVER_TYPE TMC2130
49 49
 opt_set Z_DRIVER_TYPE TMC2130
50
-opt_enable TMC_USE_SW_SPI MONITOR_DRIVER_STATUS STEALTHCHOP HYBRID_THRESHOLD TMC_DEBUG \
50
+opt_enable TMC_USE_SW_SPI MONITOR_DRIVER_STATUS STEALTHCHOP_XY STEALTHCHOP_Z HYBRID_THRESHOLD TMC_DEBUG \
51 51
            SENSORLESS_PROBING X_STALL_SENSITIVITY Y_STALL_SENSITIVITY Z_STALL_SENSITIVITY
52 52
 exec_test $1 $2 "Delta Config (generic) + BOARD_COHESION3D_REMIX + UBL + EEPROM_SETTINGS + SENSORLESS_PROBING"
53 53
 

Loading…
Cancel
Save