From 24135451e8161eca75ceafc1a62854ffa4b14ca8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20David=20Ib=C3=A1=C3=B1ez?= Date: Thu, 7 Oct 2021 19:35:14 +0200 Subject: [PATCH 1/3] Use RIOT's gpio to handle pin change interrupts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: J. David Ibáñez --- src/SDI12.cpp | 8 +++++--- src/SDI12.h | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/SDI12.cpp b/src/SDI12.cpp index f88fc56..477b16d 100644 --- a/src/SDI12.cpp +++ b/src/SDI12.cpp @@ -345,10 +345,11 @@ void SDI12::setPinInterrupts(bool enable) { // We don't detach the function from the interrupt for AVR processors } #else + gpio_t pin = arduino_pinmap[_dataPin]; if (enable) { - return; + gpio_init_int(pin, GPIO_IN, GPIO_BOTH, handleInterrupt, NULL); } else { - return; + gpio_irq_disable(pin); } #endif } @@ -552,7 +553,8 @@ void ICACHE_RAM_ATTR SDI12::handleInterrupt() { if (_activeObject) _activeObject->receiveISR(); } #else -void SDI12::handleInterrupt() { +void SDI12::handleInterrupt(void *arg) { + (void)arg; if (_activeObject) _activeObject->receiveISR(); } #endif diff --git a/src/SDI12.h b/src/SDI12.h index 06eb7ab..9ac77f7 100644 --- a/src/SDI12.h +++ b/src/SDI12.h @@ -972,10 +972,10 @@ class SDI12 : public Stream { * * On espressif boards (ESP8266 and ESP32), the ISR must be stored in IRAM */ - static void handleInterrupt(); + static void handleInterrupt(void *arg = NULL); /** on AVR boards, uncomment to use your own PCINT ISRs */ - // #define SDI12_EXTERNAL_PCINT + #define SDI12_EXTERNAL_PCINT /**@}*/ }; -- 2.34.1