1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-09-02 02:42:36 +02:00

Got rid of unwanted PU flag. Fixed nasty bug in GPIO code.

This commit is contained in:
Stefan de Bruijn
2020-11-07 20:22:10 +01:00
parent 35959344bd
commit b0488c9446
2 changed files with 5 additions and 12 deletions

View File

@@ -263,12 +263,6 @@ void limits_init() {
for (int gang_index = 0; gang_index < 2; gang_index++) { for (int gang_index = 0; gang_index < 2; gang_index++) {
Pin pin; Pin pin;
if ((pin = LimitPins[axis][gang_index]->get()) != Pin::UNDEFINED) { 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); pin.setAttr(mode);
limit_mask |= bit(axis); limit_mask |= bit(axis);
if (hard_limits->get()) { if (hard_limits->get()) {

View File

@@ -77,7 +77,7 @@ namespace Pins {
} }
GPIOPinDetail::GPIOPinDetail(uint8_t index, PinOptionsParser options) : 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: // NOTE:
// //
// RAII is very important here! If we throw an exception in the constructor, the resources // 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, Assert(!_attributes.conflictsWith(value) || _index == 1 || _index == 3,
"Attributes on this pin have been set before, and there's a conflict."); "Attributes on this pin have been set before, and there's a conflict.");
_attributes = value;
// Handle attributes: // Handle attributes:
uint8_t pinModeValue = 0; uint8_t pinModeValue = 0;
@@ -144,10 +142,11 @@ namespace Pins {
pinModeValue |= OUTPUT; pinModeValue |= OUTPUT;
} }
// PU/PD should be specified by the user. Code has nothing to do with them: // PU/PD should be specified by the user. Code has nothing to do with it. Well except for this little
if (_attributes.has(PinAttributes::PullUp)) { // detail called external libraries of course...
if (_attributes.has(PinAttributes::PullUp) || value.has(PinAttributes::PullUp)) {
pinModeValue |= PULLUP; pinModeValue |= PULLUP;
} else if (_attributes.has(PinAttributes::PullDown)) { } else if (_attributes.has(PinAttributes::PullDown) || value.has(PinAttributes::PullDown)) {
pinModeValue |= PULLDOWN; pinModeValue |= PULLDOWN;
} }