Use _BV32 to avoid name conflict

This commit is contained in:
Scott Lahteine 2018-02-01 00:06:44 -06:00
parent 6339b506c0
commit f5cfdf6efe
5 changed files with 15 additions and 10 deletions

View File

@ -130,8 +130,8 @@ extern "C" void GpioDisableInt(const uint32_t port, const uint32_t pin) {
} }
} }
bool isPowerOf2(unsigned int n) { constexpr bool isPowerOf2(const uint16_t n) {
return n == 1 || (n & (n - 1)) == 0; return IS_POWER_OF_2(n);
} }
#if 0 #if 0

View File

@ -98,7 +98,7 @@
#define NUM_SERIAL 1 #define NUM_SERIAL 1
#endif #endif
#define _BV(b) (1UL << (b)) #define _BV(b) (1 << (b))
/** /**
* TODO: review this to return 1 for pins that are not analog input * TODO: review this to return 1 for pins that are not analog input

View File

@ -29,7 +29,7 @@
#ifndef _FASTIO_STM32F7_H #ifndef _FASTIO_STM32F7_H
#define _FASTIO_STM32F7_H #define _FASTIO_STM32F7_H
#define _BV(b) (1UL << (b)) #define _BV(b) (1 << (b))
#define READ(IO) digitalRead(IO) #define READ(IO) digitalRead(IO)
#define WRITE(IO, v) digitalWrite(IO,v) #define WRITE(IO, v) digitalWrite(IO,v)

View File

@ -95,13 +95,18 @@
#define STRINGIFY(M) STRINGIFY_(M) #define STRINGIFY(M) STRINGIFY_(M)
// Macros for bit masks // Macros for bit masks
#undef _BV // Marlin needs 32-bit unsigned! #undef _BV
#define _BV(b) (1UL << (b)) #define _BV(b) (1<<(b))
#define TEST(n,b) (((n)&_BV(b))!=0) #define TEST(n,b) !!((n)&_BV(b))
#define SBI(n,b) (n |= _BV(b)) #define SBI(n,b) (n |= _BV(b))
#define CBI(n,b) (n &= ~_BV(b)) #define CBI(n,b) (n &= ~_BV(b))
#define SET_BIT(n,b,value) (n) ^= ((-value)^(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 // Macros for maths shortcuts
#ifndef M_PI #ifndef M_PI
#define M_PI 3.14159265358979323846 #define M_PI 3.14159265358979323846

View File

@ -108,7 +108,7 @@ public:
static void set(const char c, char * const ptr) { static void set(const char c, char * const ptr) {
const uint8_t ind = LETTER_BIT(c); const uint8_t ind = LETTER_BIT(c);
if (ind >= COUNT(param)) return; // Only A-Z 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 param[ind] = ptr ? ptr - command_ptr : 0; // parameter offset or 0
#if ENABLED(DEBUG_GCODE_PARSER) #if ENABLED(DEBUG_GCODE_PARSER)
if (codenum == 800) { if (codenum == 800) {
@ -125,7 +125,7 @@ public:
static bool seen(const char c) { static bool seen(const char c) {
const uint8_t ind = LETTER_BIT(c); const uint8_t ind = LETTER_BIT(c);
if (ind >= COUNT(param)) return false; // Only A-Z if (ind >= COUNT(param)) return false; // Only A-Z
const bool b = TEST(codebits, ind); const bool b = TEST32(codebits, ind);
if (b) { if (b) {
char * const ptr = command_ptr + param[ind]; char * const ptr = command_ptr + param[ind];
value_ptr = param[ind] && valid_float(ptr) ? ptr : (char*)NULL; value_ptr = param[ind] && valid_float(ptr) ? ptr : (char*)NULL;
@ -135,7 +135,7 @@ public:
static bool seen_any() { return !!codebits; } 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 #else // !FASTER_GCODE_PARSER