소스 검색

General cleanup, use _BV

Scott Lahteine 3 년 전
부모
커밋
b41f41589a

+ 1
- 1
Marlin/src/HAL/DUE/fastio.h 파일 보기

@@ -50,7 +50,7 @@
50 50
 #define PWM_PIN(P)              WITHIN(P, 2, 13)
51 51
 
52 52
 #ifndef MASK
53
-  #define MASK(PIN) (1 << PIN)
53
+  #define MASK(PIN) _BV(PIN)
54 54
 #endif
55 55
 
56 56
 /**

+ 1
- 1
Marlin/src/HAL/DUE/timers.cpp 파일 보기

@@ -121,7 +121,7 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num) {
121 121
 
122 122
 // missing from CMSIS: Check if interrupt is enabled or not
123 123
 static bool NVIC_GetEnabledIRQ(IRQn_Type IRQn) {
124
-  return (NVIC->ISER[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F))) != 0;
124
+  return TEST(NVIC->ISER[uint32_t(IRQn) >> 5], uint32_t(IRQn) & 0x1F);
125 125
 }
126 126
 
127 127
 bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {

+ 1
- 1
Marlin/src/HAL/ESP32/Servo.h 파일 보기

@@ -30,7 +30,7 @@ class Servo {
30 30
                    MAX_PULSE_WIDTH = 2400,  // Longest pulse sent to a servo
31 31
                    TAU_MSEC = 20,
32 32
                    TAU_USEC = (TAU_MSEC * 1000),
33
-                   MAX_COMPARE = ((1 << 16) - 1), // 65535
33
+                   MAX_COMPARE = _BV(16) - 1, // 65535
34 34
                    CHANNEL_MAX_NUM = 16;
35 35
 
36 36
 public:

+ 1
- 1
Marlin/src/HAL/LPC1768/eeprom_flash.cpp 파일 보기

@@ -25,7 +25,7 @@
25 25
  * Emulate EEPROM storage using Flash Memory
26 26
  *
27 27
  * Use a single 32K flash sector to store EEPROM data. To reduce the
28
- * number of erase operations a simple "levelling" scheme is used that
28
+ * number of erase operations a simple "leveling" scheme is used that
29 29
  * maintains a number of EEPROM "slots" within the larger flash sector.
30 30
  * Each slot is used in turn and the entire sector is only erased when all
31 31
  * slots have been used.

+ 1
- 1
Marlin/src/HAL/LPC1768/timers.h 파일 보기

@@ -152,7 +152,7 @@ FORCE_INLINE static void HAL_timer_disable_interrupt(const uint8_t timer_num) {
152 152
 
153 153
 // This function is missing from CMSIS
154 154
 FORCE_INLINE static bool NVIC_GetEnableIRQ(IRQn_Type IRQn) {
155
-  return (NVIC->ISER[((uint32_t)IRQn) >> 5] & (1 << ((uint32_t)IRQn) & 0x1F)) != 0;
155
+  return TEST(NVIC->ISER[uint32_t(IRQn) >> 5], uint32_t(IRQn) & 0x1F);
156 156
 }
157 157
 
158 158
 FORCE_INLINE static bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {

+ 1
- 1
Marlin/src/HAL/SAMD51/fastio.h 파일 보기

@@ -31,7 +31,7 @@
31 31
  */
32 32
 
33 33
 #ifndef MASK
34
-  #define MASK(PIN) (1 << PIN)
34
+  #define MASK(PIN) _BV(PIN)
35 35
 #endif
36 36
 
37 37
 /**

+ 1
- 1
Marlin/src/HAL/SAMD51/timers.cpp 파일 보기

@@ -157,7 +157,7 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num) {
157 157
 
158 158
 // missing from CMSIS: Check if interrupt is enabled or not
159 159
 static bool NVIC_GetEnabledIRQ(IRQn_Type IRQn) {
160
-  return (NVIC->ISER[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F))) != 0;
160
+  return TEST(NVIC->ISER[uint32_t(IRQn) >> 5], uint32_t(IRQn) & 0x1F);
161 161
 }
162 162
 
163 163
 bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {

+ 1
- 1
Marlin/src/HAL/STM32F1/Servo.cpp 파일 보기

@@ -45,7 +45,7 @@ uint8_t ServoCount = 0;
45 45
  *
46 46
  * This uses the smallest prescaler that allows an overflow < 2^16.
47 47
  */
48
-#define MAX_OVERFLOW    UINT16_MAX //((1 << 16) - 1)
48
+#define MAX_OVERFLOW    UINT16_MAX // _BV(16) - 1
49 49
 #define CYC_MSEC        (1000 * CYCLES_PER_MICROSECOND)
50 50
 #define TAU_MSEC        20
51 51
 #define TAU_USEC        (TAU_MSEC * 1000)

+ 1
- 1
Marlin/src/HAL/TEENSY31_32/fastio.h 파일 보기

@@ -28,7 +28,7 @@
28 28
  */
29 29
 
30 30
 #ifndef MASK
31
-  #define MASK(PIN) (1 << PIN)
31
+  #define MASK(PIN) _BV(PIN)
32 32
 #endif
33 33
 
34 34
 #define GPIO_BITBAND_ADDR(reg, bit) (((uint32_t)&(reg) - 0x40000000) * 32 + (bit) * 4 + 0x42000000)

+ 1
- 1
Marlin/src/HAL/TEENSY35_36/fastio.h 파일 보기

@@ -28,7 +28,7 @@
28 28
  */
29 29
 
30 30
 #ifndef MASK
31
-  #define MASK(PIN) (1 << PIN)
31
+  #define MASK(PIN) _BV(PIN)
32 32
 #endif
33 33
 
34 34
 #define GPIO_BITBAND_ADDR(reg, bit) (((uint32_t)&(reg) - 0x40000000) * 32 + (bit) * 4 + 0x42000000)

+ 6
- 8
Marlin/src/HAL/shared/Marduino.h 파일 보기

@@ -28,9 +28,9 @@
28 28
 #undef DISABLED       // Redefined by ESP32
29 29
 #undef M_PI           // Redefined by all
30 30
 #undef _BV            // Redefined by some
31
-#undef sq             // Redefined by teensy3/wiring.h
32 31
 #undef SBI            // Redefined by arduino/const_functions.h
33 32
 #undef CBI            // Redefined by arduino/const_functions.h
33
+#undef sq             // Redefined by teensy3/wiring.h
34 34
 #undef UNUSED         // Redefined by stm32f4xx_hal_def.h
35 35
 
36 36
 #include <Arduino.h>  // NOTE: If included earlier then this line is a NOOP
@@ -40,18 +40,16 @@
40 40
 
41 41
 #undef _BV
42 42
 #define _BV(b) (1UL << (b))
43
-
44
-#undef sq
45
-#define sq(x) ((x)*(x))
46
-
47 43
 #ifndef SBI
48
-  #define SBI(A,B) (A |= (1 << (B)))
44
+  #define SBI(A,B) (A |= _BV(B))
49 45
 #endif
50
-
51 46
 #ifndef CBI
52
-  #define CBI(A,B) (A &= ~(1 << (B)))
47
+  #define CBI(A,B) (A &= ~_BV(B))
53 48
 #endif
54 49
 
50
+#undef sq
51
+#define sq(x) ((x)*(x))
52
+
55 53
 #ifndef __AVR__
56 54
   #ifndef strchr_P // Some platforms define a macro (DUE, teensy35)
57 55
     inline const char* strchr_P(const char *s, int c) { return strchr(s,c); }

+ 29
- 40
Marlin/src/HAL/shared/backtrace/unwarmbytab.cpp 파일 보기

@@ -128,11 +128,8 @@ static UnwResult UnwTabStateInit(const UnwindCallbacks *cb, UnwTabState *ucb, ui
128 128
  * Execute unwinding instructions
129 129
  */
130 130
 static UnwResult UnwTabExecuteInstructions(const UnwindCallbacks *cb, UnwTabState *ucb) {
131
-
132 131
   int instruction;
133
-  uint32_t mask;
134
-  uint32_t reg;
135
-  uint32_t vsp;
132
+  uint32_t mask, reg, vsp;
136 133
 
137 134
   /* Consume all instruction byte */
138 135
   while ((instruction = UnwTabGetNextInstruction(cb, ucb)) != -1) {
@@ -140,12 +137,12 @@ static UnwResult UnwTabExecuteInstructions(const UnwindCallbacks *cb, UnwTabStat
140 137
     if ((instruction & 0xC0) == 0x00) { // ARM_EXIDX_CMD_DATA_POP
141 138
       /* vsp = vsp + (xxxxxx << 2) + 4 */
142 139
       ucb->vrs[13] += ((instruction & 0x3F) << 2) + 4;
143
-    } else
144
-    if ((instruction & 0xC0) == 0x40) { // ARM_EXIDX_CMD_DATA_PUSH
140
+    }
141
+    else if ((instruction & 0xC0) == 0x40) { // ARM_EXIDX_CMD_DATA_PUSH
145 142
       /* vsp = vsp - (xxxxxx << 2) - 4 */
146 143
       ucb->vrs[13] -= ((instruction & 0x3F) << 2) - 4;
147
-    } else
148
-    if ((instruction & 0xF0) == 0x80) {
144
+    }
145
+    else if ((instruction & 0xF0) == 0x80) {
149 146
       /* pop under mask {r15-r12},{r11-r4} or refuse to unwind */
150 147
       instruction = instruction << 8 | UnwTabGetNextInstruction(cb, ucb);
151 148
 
@@ -171,17 +168,17 @@ static UnwResult UnwTabExecuteInstructions(const UnwindCallbacks *cb, UnwTabStat
171 168
       }
172 169
 
173 170
       /* Patch up the vrs sp if it was in the mask */
174
-      if ((instruction & (1 << (13 - 4))) != 0)
171
+      if (instruction & (1 << (13 - 4)))
175 172
         ucb->vrs[13] = vsp;
176
-
177
-    } else
178
-    if ((instruction & 0xF0) == 0x90 && // ARM_EXIDX_CMD_REG_TO_SP
179
-        instruction != 0x9D &&
180
-        instruction != 0x9F) {
173
+    }
174
+    else if ((instruction & 0xF0) == 0x90 // ARM_EXIDX_CMD_REG_TO_SP
175
+           && instruction != 0x9D
176
+           && instruction != 0x9F
177
+    ) {
181 178
       /* vsp = r[nnnn] */
182 179
       ucb->vrs[13] = ucb->vrs[instruction & 0x0F];
183
-    } else
184
-    if ((instruction & 0xF0) == 0xA0) { // ARM_EXIDX_CMD_REG_POP
180
+    }
181
+    else if ((instruction & 0xF0) == 0xA0) { // ARM_EXIDX_CMD_REG_POP
185 182
       /* pop r4-r[4+nnn] or pop r4-r[4+nnn], r14*/
186 183
       vsp = ucb->vrs[13];
187 184
 
@@ -204,8 +201,8 @@ static UnwResult UnwTabExecuteInstructions(const UnwindCallbacks *cb, UnwTabStat
204 201
 
205 202
       ucb->vrs[13] = vsp;
206 203
 
207
-    } else
208
-    if (instruction == 0xB0) { // ARM_EXIDX_CMD_FINISH
204
+    }
205
+    else if (instruction == 0xB0) { // ARM_EXIDX_CMD_FINISH
209 206
       /* finished */
210 207
       if (ucb->vrs[15] == 0)
211 208
         ucb->vrs[15] = ucb->vrs[14];
@@ -213,8 +210,8 @@ static UnwResult UnwTabExecuteInstructions(const UnwindCallbacks *cb, UnwTabStat
213 210
       /* All done unwinding */
214 211
       return UNWIND_SUCCESS;
215 212
 
216
-    } else
217
-    if (instruction == 0xB1) { // ARM_EXIDX_CMD_REG_POP
213
+    }
214
+    else if (instruction == 0xB1) { // ARM_EXIDX_CMD_REG_POP
218 215
       /* pop register under mask {r3,r2,r1,r0} */
219 216
       vsp = ucb->vrs[13];
220 217
       mask = UnwTabGetNextInstruction(cb, ucb);
@@ -234,16 +231,15 @@ static UnwResult UnwTabExecuteInstructions(const UnwindCallbacks *cb, UnwTabStat
234 231
       }
235 232
       ucb->vrs[13] = (uint32_t)vsp;
236 233
 
237
-    } else
238
-    if (instruction == 0xB2) { // ARM_EXIDX_CMD_DATA_POP
234
+    }
235
+    else if (instruction == 0xB2) { // ARM_EXIDX_CMD_DATA_POP
239 236
       /* vps = vsp + 0x204 + (uleb128 << 2) */
240 237
       ucb->vrs[13] += 0x204 + (UnwTabGetNextInstruction(cb, ucb) << 2);
241
-
242
-    } else
243
-    if (instruction == 0xB3 || // ARM_EXIDX_CMD_VFP_POP
244
-      instruction == 0xC8 ||
245
-      instruction == 0xC9) {
246
-
238
+    }
239
+    else if (instruction == 0xB3 // ARM_EXIDX_CMD_VFP_POP
240
+          || instruction == 0xC8
241
+          || instruction == 0xC9
242
+    ) {
247 243
       /* pop VFP double-precision registers */
248 244
       vsp = ucb->vrs[13];
249 245
 
@@ -266,27 +262,20 @@ static UnwResult UnwTabExecuteInstructions(const UnwindCallbacks *cb, UnwTabStat
266 262
       }
267 263
 
268 264
       ucb->vrs[13] = vsp;
269
-
270
-    } else
271
-    if ((instruction & 0xF8) == 0xB8 ||
272
-        (instruction & 0xF8) == 0xD0) {
273
-
265
+    }
266
+    else if ((instruction & 0xF8) == 0xB8 || (instruction & 0xF8) == 0xD0) {
274 267
       /* Pop VFP double precision registers D[8]-D[8+nnn] */
275 268
       ucb->vrs[14] = 0x80 | (instruction & 0x07);
276
-
277
-      if ((instruction & 0xF8) == 0xD0) {
269
+      if ((instruction & 0xF8) == 0xD0)
278 270
         ucb->vrs[14] = 1 << 17;
279
-      }
280
-
281
-    } else
271
+    }
272
+    else
282 273
       return UNWIND_UNSUPPORTED_DWARF_INSTR;
283 274
   }
284
-
285 275
   return UNWIND_SUCCESS;
286 276
 }
287 277
 
288 278
 static inline __attribute__((always_inline)) uint32_t read_psp() {
289
-
290 279
   /* Read the current PSP and return its value as a pointer */
291 280
   uint32_t psp;
292 281
 

+ 2
- 6
Marlin/src/core/macros.h 파일 보기

@@ -84,17 +84,13 @@
84 84
 #define _BV(n) (1<<(n))
85 85
 #define TEST(n,b) (!!((n)&_BV(b)))
86 86
 #define SET_BIT_TO(N,B,TF) do{ if (TF) SBI(N,B); else CBI(N,B); }while(0)
87
-
88 87
 #ifndef SBI
89
-  #define SBI(A,B) (A |= (1 << (B)))
88
+  #define SBI(A,B) (A |= _BV(B))
90 89
 #endif
91
-
92 90
 #ifndef CBI
93
-  #define CBI(A,B) (A &= ~(1 << (B)))
91
+  #define CBI(A,B) (A &= ~_BV(B))
94 92
 #endif
95
-
96 93
 #define TBI(N,B) (N ^= _BV(B))
97
-
98 94
 #define _BV32(b) (1UL << (b))
99 95
 #define TEST32(n,b) !!((n)&_BV32(b))
100 96
 #define SBI32(n,b) (n |= _BV32(b))

+ 2
- 2
Marlin/src/feature/direct_stepping.h 파일 보기

@@ -93,8 +93,8 @@ namespace DirectStepping {
93 93
     static constexpr int DIRECTIONAL    = dir ? 1 : 0;
94 94
     static constexpr int SEGMENTS       = segments;
95 95
 
96
-    static constexpr int NUM_SEGMENTS   = 1 << BITS_SEGMENT;
97
-    static constexpr int SEGMENT_STEPS  = (1 << (BITS_SEGMENT - DIRECTIONAL)) - 1;
96
+    static constexpr int NUM_SEGMENTS   = _BV(BITS_SEGMENT);
97
+    static constexpr int SEGMENT_STEPS  = _BV(BITS_SEGMENT - DIRECTIONAL) - 1;
98 98
     static constexpr int TOTAL_STEPS    = SEGMENT_STEPS * SEGMENTS;
99 99
     static constexpr int PAGE_SIZE      = (NUM_AXES * BITS_SEGMENT * SEGMENTS) / 8;
100 100
 

+ 4
- 4
Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp 파일 보기

@@ -86,9 +86,9 @@ namespace Anycubic {
86 86
 
87 87
     safe_delay(200);
88 88
 
89
-    // Enable levelling and Disable end stops during print
89
+    // Enable leveling and Disable end stops during print
90 90
     // as Z home places nozzle above the bed so we need to allow it past the end stops
91
-    injectCommands_P(AC_cmnd_enable_levelling);
91
+    injectCommands_P(AC_cmnd_enable_leveling);
92 92
 
93 93
     // Startup tunes are defined in Tunes.h
94 94
     //PlayTune(BEEPER_PIN, Anycubic_PowerOn, 1);
@@ -762,7 +762,7 @@ namespace Anycubic {
762 762
               selectedmeshpoint.x = selectedmeshpoint.y = 99;
763 763
             }
764 764
           break;
765
-          case 'D':   // Save Z Offset tables and restore levelling state
765
+          case 'D':   // Save Z Offset tables and restore leveling state
766 766
             if (!isPrinting()) {
767 767
               setAxisPosition_mm(1.0,Z);
768 768
               injectCommands_P(PSTR("M500"));
@@ -784,7 +784,7 @@ namespace Anycubic {
784 784
             float Zshift = atof(&panel_command[4]);
785 785
             setSoftEndstopState(false);  // disable endstops
786 786
             // Allow temporary Z position nudging during print
787
-            // From the levelling panel use the all points UI to adjust the print pos.
787
+            // From the leveling panel use the all points UI to adjust the print pos.
788 788
             if (isPrinting()) {
789 789
               #if ACDEBUG(AC_INFO)
790 790
                 SERIAL_ECHOLNPAIR("Change Zoffset from:", live_Zoffset, " to ", live_Zoffset + Zshift);

+ 1
- 1
Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft_defs.h 파일 보기

@@ -105,7 +105,7 @@
105 105
 
106 106
 #define AC_cmnd_manual_load_filament   PSTR("M83\nG1 E50 F700\nM82")   // replace the manual panel commands with something a little faster
107 107
 #define AC_cmnd_manual_unload_filament PSTR("M83\nG1 E-50 F1200\nM82")
108
-#define AC_cmnd_enable_levelling       PSTR("M420 S1 V1")
108
+#define AC_cmnd_enable_leveling        PSTR("M420 S1 V1")
109 109
 #define AC_cmnd_power_loss_recovery    PSTR("G28 X Y R5\nG28 Z")       // Lift, home X and Y then home Z when in 'safe' position
110 110
 
111 111
 namespace Anycubic {

+ 1
- 1
Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp 파일 보기

@@ -56,7 +56,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
56 56
             thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)HEATER_0_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1);
57 57
           }
58 58
         }
59
-        #if !defined(SINGLENOZZLE) && HAS_MULTI_EXTRUDER
59
+        #if DISABLED(SINGLENOZZLE) && HAS_MULTI_EXTRUDER
60 60
           else if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > (HEATER_1_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1))) {
61 61
             thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)HEATER_1_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1);
62 62
           }

+ 0
- 4
Marlin/src/lcd/menu/menu_temperature.cpp 파일 보기

@@ -35,10 +35,6 @@
35 35
   #include "../../module/motion.h"
36 36
 #endif
37 37
 
38
-#if ENABLED(SINGLENOZZLE)
39
-  #include "../../module/tool_change.h"
40
-#endif
41
-
42 38
 //
43 39
 // "Temperature" submenu items
44 40
 //

+ 0
- 4
Marlin/src/lcd/menu/menu_tune.cpp 파일 보기

@@ -38,10 +38,6 @@
38 38
   #include "../../feature/bedlevel/bedlevel.h"
39 39
 #endif
40 40
 
41
-#if ENABLED(SINGLENOZZLE)
42
-  #include "../../module/tool_change.h"
43
-#endif
44
-
45 41
 #if ENABLED(BABYSTEPPING)
46 42
 
47 43
   #include "../../feature/babystep.h"

Loading…
취소
저장