From b0488c94468c9d5a1d946516610386c949d17027 Mon Sep 17 00:00:00 2001 From: Stefan de Bruijn Date: Sat, 7 Nov 2020 20:22:10 +0100 Subject: [PATCH] Got rid of unwanted PU flag. Fixed nasty bug in GPIO code. --- Grbl_Esp32/src/Limits.cpp | 6 ------ Grbl_Esp32/src/Pins/GPIOPinDetail.cpp | 11 +++++------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/Grbl_Esp32/src/Limits.cpp b/Grbl_Esp32/src/Limits.cpp index 51f19480..cb239269 100644 --- a/Grbl_Esp32/src/Limits.cpp +++ b/Grbl_Esp32/src/Limits.cpp @@ -263,12 +263,6 @@ void limits_init() { for (int gang_index = 0; gang_index < 2; gang_index++) { Pin pin; if ((pin = LimitPins[axis][gang_index]->get()) != Pin::UNDEFINED) { -#ifndef DISABLE_LIMIT_PIN_PULL_UP - if (pin.capabilities().has(Pins::PinCapabilities::PullUp)) { - mode = mode | Pin::Attr::PullUp; - } -#endif - pin.setAttr(mode); limit_mask |= bit(axis); if (hard_limits->get()) { diff --git a/Grbl_Esp32/src/Pins/GPIOPinDetail.cpp b/Grbl_Esp32/src/Pins/GPIOPinDetail.cpp index 85a37b6f..667afbd5 100644 --- a/Grbl_Esp32/src/Pins/GPIOPinDetail.cpp +++ b/Grbl_Esp32/src/Pins/GPIOPinDetail.cpp @@ -77,7 +77,7 @@ namespace Pins { } GPIOPinDetail::GPIOPinDetail(uint8_t index, PinOptionsParser options) : - PinDetail(index), _capabilities(GetDefaultCapabilities(index)), _attributes(Pins::PinAttributes::Undefined), _readWriteMask(0) { + PinDetail(index), _capabilities(GetDefaultCapabilities(index)), _attributes(Pins::PinAttributes::None), _readWriteMask(0) { // NOTE: // // RAII is very important here! If we throw an exception in the constructor, the resources @@ -133,8 +133,6 @@ namespace Pins { Assert(!_attributes.conflictsWith(value) || _index == 1 || _index == 3, "Attributes on this pin have been set before, and there's a conflict."); - _attributes = value; - // Handle attributes: uint8_t pinModeValue = 0; @@ -144,10 +142,11 @@ namespace Pins { pinModeValue |= OUTPUT; } - // PU/PD should be specified by the user. Code has nothing to do with them: - if (_attributes.has(PinAttributes::PullUp)) { + // PU/PD should be specified by the user. Code has nothing to do with it. Well except for this little + // detail called external libraries of course... + if (_attributes.has(PinAttributes::PullUp) || value.has(PinAttributes::PullUp)) { pinModeValue |= PULLUP; - } else if (_attributes.has(PinAttributes::PullDown)) { + } else if (_attributes.has(PinAttributes::PullDown) || value.has(PinAttributes::PullDown)) { pinModeValue |= PULLDOWN; }