diff --git a/Marlin/src/HAL/HAL_LPC1768/WInterrupts.cpp b/Marlin/src/HAL/HAL_LPC1768/WInterrupts.cpp
index 1c73db03c1c232aacbe258f926832650245adf6c..80de9f369773065a0a9ab60fce7bd2aee512b730 100644
--- a/Marlin/src/HAL/HAL_LPC1768/WInterrupts.cpp
+++ b/Marlin/src/HAL/HAL_LPC1768/WInterrupts.cpp
@@ -130,8 +130,8 @@ extern "C" void GpioDisableInt(const uint32_t port, const uint32_t pin) {
}
}
-bool isPowerOf2(unsigned int n) {
- return n == 1 || (n & (n - 1)) == 0;
+constexpr bool isPowerOf2(const uint16_t n) {
+ return IS_POWER_OF_2(n);
}
#if 0
diff --git a/Marlin/src/HAL/HAL_STM32F7/HAL_STM32F7.h b/Marlin/src/HAL/HAL_STM32F7/HAL_STM32F7.h
index 03ab69a1edb8d08ad5b7903f7650fcb5121aef43..814c21096fb5b6ea3f6458a65031d731c65c0bee 100644
--- a/Marlin/src/HAL/HAL_STM32F7/HAL_STM32F7.h
+++ b/Marlin/src/HAL/HAL_STM32F7/HAL_STM32F7.h
@@ -98,7 +98,7 @@
#define NUM_SERIAL 1
#endif
-#define _BV(b) (1UL << (b))
+#define _BV(b) (1 << (b))
/**
* TODO: review this to return 1 for pins that are not analog input
diff --git a/Marlin/src/HAL/HAL_STM32F7/fastio_STM32F7.h b/Marlin/src/HAL/HAL_STM32F7/fastio_STM32F7.h
index e22acc6670151b46e6320d6b72a9fa65b297f3b4..dd8ca1e57952133699a10ff43d2e942386ba63fd 100644
--- a/Marlin/src/HAL/HAL_STM32F7/fastio_STM32F7.h
+++ b/Marlin/src/HAL/HAL_STM32F7/fastio_STM32F7.h
@@ -29,7 +29,7 @@
#ifndef _FASTIO_STM32F7_H
#define _FASTIO_STM32F7_H
-#define _BV(b) (1UL << (b))
+#define _BV(b) (1 << (b))
#define READ(IO) digitalRead(IO)
#define WRITE(IO, v) digitalWrite(IO,v)
diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h
index 945233a457e948973b2c4dcb74546ab603caac50..342b702d76c876478bfb611048470c274a647841 100644
--- a/Marlin/src/core/macros.h
+++ b/Marlin/src/core/macros.h
@@ -95,13 +95,18 @@
#define STRINGIFY(M) STRINGIFY_(M)
// Macros for bit masks
-#undef _BV // Marlin needs 32-bit unsigned!
-#define _BV(b) (1UL << (b))
-#define TEST(n,b) (((n)&_BV(b))!=0)
+#undef _BV
+#define _BV(b) (1<<(b))
+#define TEST(n,b) !!((n)&_BV(b))
#define SBI(n,b) (n |= _BV(b))
#define CBI(n,b) (n &= ~_BV(b))
#define SET_BIT(n,b,value) (n) ^= ((-value)^(n)) & (_BV(b))
+#define _BV32(b) (1UL << (b))
+#define TEST32(n,b) !!((n)&_BV32(b))
+#define SBI32(n,b) (n |= _BV32(b))
+#define CBI32(n,b) (n &= ~_BV32(b))
+
// Macros for maths shortcuts
#ifndef M_PI
#define M_PI 3.14159265358979323846
diff --git a/Marlin/src/gcode/parser.h b/Marlin/src/gcode/parser.h
index 8d5582a4e419167b7a387b650b7762dd9d6f47a5..d4bd897fbab54cd6d913e266f402025f7615d3d5 100644
--- a/Marlin/src/gcode/parser.h
+++ b/Marlin/src/gcode/parser.h
@@ -108,7 +108,7 @@ public:
static void set(const char c, char * const ptr) {
const uint8_t ind = LETTER_BIT(c);
if (ind >= COUNT(param)) return; // Only A-Z
- SBI(codebits, ind); // parameter exists
+ SBI32(codebits, ind); // parameter exists
param[ind] = ptr ? ptr - command_ptr : 0; // parameter offset or 0
#if ENABLED(DEBUG_GCODE_PARSER)
if (codenum == 800) {
@@ -125,7 +125,7 @@ public:
static bool seen(const char c) {
const uint8_t ind = LETTER_BIT(c);
if (ind >= COUNT(param)) return false; // Only A-Z
- const bool b = TEST(codebits, ind);
+ const bool b = TEST32(codebits, ind);
if (b) {
char * const ptr = command_ptr + param[ind];
value_ptr = param[ind] && valid_float(ptr) ? ptr : (char*)NULL;
@@ -135,7 +135,7 @@ public:
static bool seen_any() { return !!codebits; }
- #define SEEN_TEST(L) TEST(codebits, LETTER_BIT(L))
+ #define SEEN_TEST(L) TEST32(codebits, LETTER_BIT(L))
#else // !FASTER_GCODE_PARSER