Skip to content

Commit

Permalink
Reorder AVR interrupt attachment defines (no functional change)
Browse files Browse the repository at this point in the history
Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
  • Loading branch information
SRGDamia1 committed Aug 14, 2024
1 parent 97fbf5d commit 307de77
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/SDI12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,7 @@ uint8_t SDI12::parity_even_bit(uint8_t v) {

// a helper function to switch pin interrupts on or off
void SDI12::setPinInterrupts(bool enable) {
#if defined(ARDUINO_ARCH_SAMD) || defined(ESP32) || defined(ESP8266)
// Merely need to attach the interrupt function to the pin
if (enable) attachInterrupt(digitalPinToInterrupt(_dataPin), handleInterrupt, CHANGE);
// Merely need to detach the interrupt function from the pin
else
detachInterrupt(digitalPinToInterrupt(_dataPin));

#elif defined(__AVR__) && not defined(SDI12_EXTERNAL_PCINT)
#if defined(__AVR__) && not defined(SDI12_EXTERNAL_PCINT)
if (enable) {
// Enable interrupts on the register with the pin of interest
*digitalPinToPCICR(_dataPin) |= (1 << digitalPinToPCICRbit(_dataPin));
Expand All @@ -339,12 +332,20 @@ void SDI12::setPinInterrupts(bool enable) {
}
// We don't detach the function from the interrupt for AVR processors
}
#else
// if using AVR with external interrupts, do nothing
#elif defined(__AVR__)
if (enable) {
return;
} else {
return;
}
// for other boards (SAMD/Espressif/??) use the attachInterrupt function
#else
// Merely need to attach the interrupt function to the pin
if (enable) attachInterrupt(digitalPinToInterrupt(_dataPin), handleInterrupt, CHANGE);
// Merely need to detach the interrupt function from the pin
else
detachInterrupt(digitalPinToInterrupt(_dataPin));
#endif
}

Expand Down

0 comments on commit 307de77

Please sign in to comment.