From b7bcd133470581d7bbdf491b372d14d35edeb32a Mon Sep 17 00:00:00 2001 From: Neil McKechnie Date: Thu, 21 Oct 2021 16:43:42 +0100 Subject: [PATCH] Fix Arduino pin pullup initial state. If an Arduino pin was used as an input (e.g. by EXRAIL) without previously configuring it, the default pullup wouldn't be set up. Now, on first call to the _read() method the pullup will be enabled. --- IODevice.cpp | 14 ++++++++++---- IODevice.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/IODevice.cpp b/IODevice.cpp index 5fd27ff..3456af5 100644 --- a/IODevice.cpp +++ b/IODevice.cpp @@ -327,12 +327,14 @@ IONotifyCallback *IONotifyCallback::first = 0; ArduinoPins::ArduinoPins(VPIN firstVpin, int nPins) { _firstVpin = firstVpin; _nPins = nPins; - uint8_t arrayLen = (_nPins+7)/8; - _pinPullups = (uint8_t *)calloc(2, arrayLen); + int arrayLen = (_nPins+7)/8; + _pinPullups = (uint8_t *)calloc(3, arrayLen); _pinModes = (&_pinPullups[0]) + arrayLen; + _pinInUse = (&_pinPullups[0]) + 2*arrayLen; for (int i=0; i