Merge pull request #9435 from thinkyhead/cleanup_binary_deleteme

[1.1.x] Separate 32-bit wide bit macros
This commit is contained in:
Scott Lahteine 2018-02-01 22:44:18 -06:00 committed by GitHub
commit 65c2f3bb65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 6 deletions

View File

@ -48,7 +48,7 @@ class SPI<MISO_PIN, MOSI_PIN, SCK_PIN> {
}
FORCE_INLINE static uint8_t receive() {
SPDR = 0;
for (;!TEST(SPSR, SPIF););
while (!TEST(SPSR, SPIF)) { /* nada */ }
return SPDR;
}

View File

@ -136,7 +136,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) {
#if ENABLED(DEBUG_GCODE_PARSER)
if (codenum == 800) {
@ -151,7 +151,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

View File

@ -101,13 +101,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))
// Macro to check that a number if a power if 2
#define IS_POWER_OF_2(x) ((x) && !((x) & ((x) - 1)))