From 87b076bfc1c80237f00390f9c53be51efd18989b Mon Sep 17 00:00:00 2001 From: Stefan de Bruijn Date: Sat, 7 Nov 2020 10:00:36 +0100 Subject: [PATCH] Fixed a few bugs (backport) --- Grbl_Esp32/src/Pins/GPIOPinDetail.cpp | 11 +++++++---- Grbl_Esp32/src/Pins/PinLookup.cpp | 12 ++++++------ Grbl_Esp32/src/Report.h | 4 ++-- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Grbl_Esp32/src/Pins/GPIOPinDetail.cpp b/Grbl_Esp32/src/Pins/GPIOPinDetail.cpp index c9e6b752..e61e30ce 100644 --- a/Grbl_Esp32/src/Pins/GPIOPinDetail.cpp +++ b/Grbl_Esp32/src/Pins/GPIOPinDetail.cpp @@ -151,10 +151,13 @@ namespace Pins { } // If the pin is ActiveLow, we should take that into account here: - if (value.has(PinAttributes::InitialOn)) { - __digitalWrite(_index, HIGH ^ _readWriteMask); - } else { - __digitalWrite(_index, LOW ^ _readWriteMask); + if (value.has(PinAttributes::Output)) { + if (value.has(PinAttributes::InitialOn)) { + __digitalWrite(_index, HIGH ^ _readWriteMask); + } + else { + __digitalWrite(_index, LOW ^ _readWriteMask); + } } __pinMode(_index, pinModeValue); diff --git a/Grbl_Esp32/src/Pins/PinLookup.cpp b/Grbl_Esp32/src/Pins/PinLookup.cpp index 11ccdc6c..44479552 100644 --- a/Grbl_Esp32/src/Pins/PinLookup.cpp +++ b/Grbl_Esp32/src/Pins/PinLookup.cpp @@ -55,16 +55,16 @@ void IRAM_ATTR digitalWrite(uint8_t pin, uint8_t val) { void IRAM_ATTR pinMode(uint8_t pin, uint8_t mode) { Pins::PinAttributes attr = Pins::PinAttributes::None; - if (mode & OUTPUT) { - attr = attr | Pins::PinAttributes::Output; - } - if (mode & INPUT) { + if ((mode & INPUT) == INPUT) { attr = attr | Pins::PinAttributes::Input; } - if (mode & INPUT_PULLUP) { + if ((mode & OUTPUT) == OUTPUT) { + attr = attr | Pins::PinAttributes::Output; + } + if ((mode & PULLUP) == PULLUP) { attr = attr | Pins::PinAttributes::PullUp; } - if (mode & INPUT_PULLDOWN) { + if ((mode & PULLDOWN) == PULLDOWN) { attr = attr | Pins::PinAttributes::PullDown; } diff --git a/Grbl_Esp32/src/Report.h b/Grbl_Esp32/src/Report.h index 9ec9d1ed..de383920 100644 --- a/Grbl_Esp32/src/Report.h +++ b/Grbl_Esp32/src/Report.h @@ -24,8 +24,8 @@ // Define status reporting boolean enable bit flags in status_report_mask enum RtStatus { - Position = 0, - Buffer = 1, + Position = bit(0), + Buffer = bit(1), }; const char* errorString(Error errorNumber);