Browse Source

Use _BV32 to avoid name conflict

Scott Lahteine 6 years ago
parent
commit
f5cfdf6efe

+ 2
- 2
Marlin/src/HAL/HAL_LPC1768/WInterrupts.cpp View File

130
   }
130
   }
131
 }
131
 }
132
 
132
 
133
-bool isPowerOf2(unsigned int n) {
134
-  return n == 1 || (n & (n - 1)) == 0;
133
+constexpr bool isPowerOf2(const uint16_t n) {
134
+  return IS_POWER_OF_2(n);
135
 }
135
 }
136
 
136
 
137
 #if 0
137
 #if 0

+ 1
- 1
Marlin/src/HAL/HAL_STM32F7/HAL_STM32F7.h View File

98
   #define NUM_SERIAL 1
98
   #define NUM_SERIAL 1
99
 #endif
99
 #endif
100
 
100
 
101
-#define _BV(b) (1UL << (b))
101
+#define _BV(b) (1 << (b))
102
 
102
 
103
 /**
103
 /**
104
  * TODO: review this to return 1 for pins that are not analog input
104
  * TODO: review this to return 1 for pins that are not analog input

+ 1
- 1
Marlin/src/HAL/HAL_STM32F7/fastio_STM32F7.h View File

29
 #ifndef _FASTIO_STM32F7_H
29
 #ifndef _FASTIO_STM32F7_H
30
 #define _FASTIO_STM32F7_H
30
 #define _FASTIO_STM32F7_H
31
 
31
 
32
-#define _BV(b) (1UL << (b))
32
+#define _BV(b) (1 << (b))
33
 
33
 
34
 #define READ(IO)              digitalRead(IO)
34
 #define READ(IO)              digitalRead(IO)
35
 #define WRITE(IO, v)          digitalWrite(IO,v)
35
 #define WRITE(IO, v)          digitalWrite(IO,v)

+ 8
- 3
Marlin/src/core/macros.h View File

95
 #define STRINGIFY(M) STRINGIFY_(M)
95
 #define STRINGIFY(M) STRINGIFY_(M)
96
 
96
 
97
 // Macros for bit masks
97
 // Macros for bit masks
98
-#undef _BV // Marlin needs 32-bit unsigned!
99
-#define _BV(b) (1UL << (b))
100
-#define TEST(n,b) (((n)&_BV(b))!=0)
98
+#undef _BV
99
+#define _BV(b) (1<<(b))
100
+#define TEST(n,b) !!((n)&_BV(b))
101
 #define SBI(n,b) (n |= _BV(b))
101
 #define SBI(n,b) (n |= _BV(b))
102
 #define CBI(n,b) (n &= ~_BV(b))
102
 #define CBI(n,b) (n &= ~_BV(b))
103
 #define SET_BIT(n,b,value) (n) ^= ((-value)^(n)) & (_BV(b))
103
 #define SET_BIT(n,b,value) (n) ^= ((-value)^(n)) & (_BV(b))
104
 
104
 
105
+#define _BV32(b) (1UL << (b))
106
+#define TEST32(n,b) !!((n)&_BV32(b))
107
+#define SBI32(n,b) (n |= _BV32(b))
108
+#define CBI32(n,b) (n &= ~_BV32(b))
109
+
105
 // Macros for maths shortcuts
110
 // Macros for maths shortcuts
106
 #ifndef M_PI
111
 #ifndef M_PI
107
   #define M_PI 3.14159265358979323846
112
   #define M_PI 3.14159265358979323846

+ 3
- 3
Marlin/src/gcode/parser.h View File

108
     static void set(const char c, char * const ptr) {
108
     static void set(const char c, char * const ptr) {
109
       const uint8_t ind = LETTER_BIT(c);
109
       const uint8_t ind = LETTER_BIT(c);
110
       if (ind >= COUNT(param)) return;           // Only A-Z
110
       if (ind >= COUNT(param)) return;           // Only A-Z
111
-      SBI(codebits, ind);                        // parameter exists
111
+      SBI32(codebits, ind);                      // parameter exists
112
       param[ind] = ptr ? ptr - command_ptr : 0;  // parameter offset or 0
112
       param[ind] = ptr ? ptr - command_ptr : 0;  // parameter offset or 0
113
       #if ENABLED(DEBUG_GCODE_PARSER)
113
       #if ENABLED(DEBUG_GCODE_PARSER)
114
         if (codenum == 800) {
114
         if (codenum == 800) {
125
     static bool seen(const char c) {
125
     static bool seen(const char c) {
126
       const uint8_t ind = LETTER_BIT(c);
126
       const uint8_t ind = LETTER_BIT(c);
127
       if (ind >= COUNT(param)) return false; // Only A-Z
127
       if (ind >= COUNT(param)) return false; // Only A-Z
128
-      const bool b = TEST(codebits, ind);
128
+      const bool b = TEST32(codebits, ind);
129
       if (b) {
129
       if (b) {
130
         char * const ptr = command_ptr + param[ind];
130
         char * const ptr = command_ptr + param[ind];
131
         value_ptr = param[ind] && valid_float(ptr) ? ptr : (char*)NULL;
131
         value_ptr = param[ind] && valid_float(ptr) ? ptr : (char*)NULL;
135
 
135
 
136
     static bool seen_any() { return !!codebits; }
136
     static bool seen_any() { return !!codebits; }
137
 
137
 
138
-    #define SEEN_TEST(L) TEST(codebits, LETTER_BIT(L))
138
+    #define SEEN_TEST(L) TEST32(codebits, LETTER_BIT(L))
139
 
139
 
140
   #else // !FASTER_GCODE_PARSER
140
   #else // !FASTER_GCODE_PARSER
141
 
141
 

Loading…
Cancel
Save