From d8aa40eedfee68db53e6c355949a76359458743a Mon Sep 17 00:00:00 2001
From: Scott Lahteine <github@thinkyhead.com>
Date: Tue, 23 Jan 2018 23:20:57 -0600
Subject: [PATCH] Marlin must override _BV for 32-bit masks!

---
 Marlin/fastio.h | 5 +----
 Marlin/macros.h | 2 ++
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/Marlin/fastio.h b/Marlin/fastio.h
index d5ae8f2ccec..4f7c9648d6c 100644
--- a/Marlin/fastio.h
+++ b/Marlin/fastio.h
@@ -30,7 +30,6 @@
 #define _FASTIO_ARDUINO_H
 
 #include <avr/io.h>
-#include "macros.h"
 
 #define AVR_AT90USB1286_FAMILY (defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1286P__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB646P__)  || defined(__AVR_AT90USB647__))
 #define AVR_ATmega1284_FAMILY (defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(__AVR_ATmega1284P__))
@@ -56,9 +55,7 @@
   #error "Pins for this chip not defined in Arduino.h! If you have a working pins definition, please contribute!"
 #endif
 
-#ifndef _BV
-  #define _BV(PIN) (1UL << PIN)
-#endif
+#include "macros.h"
 
 /**
  * Magic I/O routines
diff --git a/Marlin/macros.h b/Marlin/macros.h
index 253ba6011d9..584d555a835 100644
--- a/Marlin/macros.h
+++ b/Marlin/macros.h
@@ -101,6 +101,8 @@
 #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)
 #define SBI(n,b) (n |= _BV(b))
 #define CBI(n,b) (n &= ~_BV(b))