Skip to content

Commit

Permalink
Workaround for boards not supported by Enable Interrupts
Browse files Browse the repository at this point in the history
Signed-off-by: Sara Damiano <[email protected]>
  • Loading branch information
SRGDamia1 committed May 16, 2024
1 parent d245046 commit 1696601
Show file tree
Hide file tree
Showing 18 changed files with 42 additions and 60 deletions.
4 changes: 0 additions & 4 deletions examples/DRWI_2G/DRWI_2G.ino
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
// The Arduino library is needed for every Arduino program.
#include <Arduino.h>

// EnableInterrupt is used by ModularSensors for external and pin change
// interrupts and must be explicitly included in the main program.
#include <EnableInterrupt.h>

// Include the main header for ModularSensors
#include <ModularSensors.h>
/** End [includes] */
Expand Down
4 changes: 0 additions & 4 deletions examples/DRWI_DigiLTE/DRWI_DigiLTE.ino
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
// The Arduino library is needed for every Arduino program.
#include <Arduino.h>

// EnableInterrupt is used by ModularSensors for external and pin change
// interrupts and must be explicitly included in the main program.
#include <EnableInterrupt.h>

// Include the main header for ModularSensors
#include <ModularSensors.h>
/** End [includes] */
Expand Down
4 changes: 0 additions & 4 deletions examples/DRWI_Mayfly1/DRWI_Mayfly1.ino
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@
// The Arduino library is needed for every Arduino program.
#include <Arduino.h>

// EnableInterrupt is used by ModularSensors for external and pin change
// interrupts and must be explicitly included in the main program.
#include <EnableInterrupt.h>

// Include the main header for ModularSensors
#include <ModularSensors.h>
/** End [includes] */
Expand Down
4 changes: 0 additions & 4 deletions examples/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@
// The Arduino library is needed for every Arduino program.
#include <Arduino.h>

// EnableInterrupt is used by ModularSensors for external and pin change
// interrupts and must be explicitly included in the main program.
#include <EnableInterrupt.h>

// Include the main header for ModularSensors
#include <ModularSensors.h>
/** End [includes] */
Expand Down
4 changes: 0 additions & 4 deletions examples/DRWI_NoCellular/DRWI_NoCellular.ino
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
// The Arduino library is needed for every Arduino program.
#include <Arduino.h>

// EnableInterrupt is used by ModularSensors for external and pin change
// interrupts and must be explicitly included in the main program.
#include <EnableInterrupt.h>

// Include the main header for ModularSensors
#include <ModularSensors.h>
/** End [includes] */
Expand Down
4 changes: 0 additions & 4 deletions examples/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@
// The Arduino library is needed for every Arduino program.
#include <Arduino.h>

// EnableInterrupt is used by ModularSensors for external and pin change
// interrupts and must be explicitly included in the main program.
#include <EnableInterrupt.h>

// Include the main header for ModularSensors
#include <ModularSensors.h>
/** End [includes] */
Expand Down
4 changes: 0 additions & 4 deletions examples/baro_rho_correction/baro_rho_correction.ino
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@
// The Arduino library is needed for every Arduino program.
#include <Arduino.h>

// EnableInterrupt is used by ModularSensors for external and pin change
// interrupts and must be explicitly included in the main program.
#include <EnableInterrupt.h>

// Include the main header for ModularSensors
#include <ModularSensors.h>
/** End [includes] */
Expand Down
4 changes: 0 additions & 4 deletions examples/data_saving/data_saving.ino
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
// The Arduino library is needed for every Arduino program.
#include <Arduino.h>

// EnableInterrupt is used by ModularSensors for external and pin change
// interrupts and must be explicitly included in the main program.
#include <EnableInterrupt.h>

// Include the main header for ModularSensors
#include <ModularSensors.h>
/** End [includes] */
Expand Down
4 changes: 0 additions & 4 deletions examples/double_logger/double_logger.ino
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
// The Arduino library is needed for every Arduino program.
#include <Arduino.h>

// EnableInterrupt is used by ModularSensors for external and pin change
// interrupts and must be explicitly included in the main program.
#include <EnableInterrupt.h>

// Include the main header for ModularSensors
#include <ModularSensors.h>
/** End [includes] */
Expand Down
4 changes: 0 additions & 4 deletions examples/logging_to_MMW/logging_to_MMW.ino
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
// The Arduino library is needed for every Arduino program.
#include <Arduino.h>

// EnableInterrupt is used by ModularSensors for external and pin change
// interrupts and must be explicitly included in the main program.
#include <EnableInterrupt.h>

// Include the main header for ModularSensors
#include <ModularSensors.h>
/** End [includes] */
Expand Down
4 changes: 0 additions & 4 deletions examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
// The Arduino library is needed for every Arduino program.
#include <Arduino.h>

// EnableInterrupt is used by ModularSensors for external and pin change
// interrupts and must be explicitly included in the main program.
#include <EnableInterrupt.h>

// Include the main header for ModularSensors
#include <ModularSensors.h>
/** End [includes] */
Expand Down
4 changes: 0 additions & 4 deletions examples/menu_a_la_carte/menu_a_la_carte.ino
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@
// The Arduino library is needed for every Arduino program.
#include <Arduino.h>

// EnableInterrupt is used by ModularSensors for external and pin change
// interrupts and must be explicitly included in the main program.
#include <EnableInterrupt.h>

// Include the main header for ModularSensors
#include <ModularSensors.h>
/** End [includes] */
Expand Down
4 changes: 0 additions & 4 deletions examples/simple_logging/simple_logging.ino
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
// The Arduino library is needed for every Arduino program.
#include <Arduino.h>

// EnableInterrupt is used by ModularSensors for external and pin change
// interrupts and must be explicitly included in the main program.
#include <EnableInterrupt.h>

// Include the main header for ModularSensors
#include <ModularSensors.h>
/** End [includes] */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
// The Arduino library is needed for every Arduino program.
#include <Arduino.h>

// EnableInterrupt is used by ModularSensors for external and pin change
// interrupts and must be explicitly included in the main program.
#include <EnableInterrupt.h>

// Include the main header for ModularSensors
#include <ModularSensors.h>
/** End [includes] */
Expand Down
2 changes: 1 addition & 1 deletion src/LoggerBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
#define LIBCALL_ENABLEINTERRUPT
// To handle external and pin change interrupts
#include <EnableInterrupt.h>
#include "ModSensorInterrupts.h"
// For all i2c communication, including with the real time clock
#include <Wire.h>

Expand Down
29 changes: 29 additions & 0 deletions src/ModSensorInterrupts.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* @file ModSensorInterrupts.h
* @copyright Stroud Water Research Center
* Part of the EnviroDIY ModularSensors library for Arduino.
* This library is published under the BSD-3 license.
* @author Sara Geleskie Damiano <[email protected]>
*
* @brief A work-around for the AVR interrupt library not supporting SAMD
* boards. That libary isn't necessary for them.
*/


// Header Guards
#ifndef SRC_MODSENSORINTERRUPTS_H_
#define SRC_MODSENSORINTERRUPTS_H_

#if defined(__AVR__) || defined(ARDUINO_ARCH_AVR) || defined __SAM3U4E__ || \
defined __SAM3X8E__ || defined __SAM3X8H__ || defined ARDUINO_SAMD_ZERO || \
defined __SAMD21G18A__ || defined __SAMD21J18A__
// #define LIBCALL_ENABLEINTERRUPT // To prevent compiler/linker crashes
#include <EnableInterrupt.h> // To handle external and pin change interrupts
#else
#define enableInterrupt(pin, userFunc, mode) \
attachInterrupt(pin, userFunc, mode)
#define disableInterrupt(pin) detachInterrupt(pin)
#endif


#endif // SRC_MODSENSORINTERRUPTS_H_
5 changes: 4 additions & 1 deletion src/ModularSensors.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* This library is published under the BSD-3 license.
* @author Sara Geleskie Damiano <[email protected]>
*
* @brief A simple include file for the Arduino command line interface (CLI).s
* @brief A simple include file for the Arduino command line interface (CLI).
*/

// Header Guards
Expand All @@ -21,6 +21,9 @@
*/
#define MODULAR_SENSORS_VERSION "0.35.0"

// To support interrupts
#include "ModSensorInterrupts.h"

// To get all of the base classes for ModularSensors, include LoggerBase.
// NOTE: Individual sensor definitions must be included separately.
#include "LoggerBase.h"
Expand Down
10 changes: 8 additions & 2 deletions src/sensors/SDI12Sensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@
* @brief Implements the SDI12Sensors class.
*/

#define LIBCALL_ENABLEINTERRUPT // To prevent compiler/linker crashes
#include <EnableInterrupt.h> // To handle external and pin change interrupts
/**
* @brief To prevent compiler/linker crashes with enable interrupt library, we
* must define LIBCALL_ENABLEINTERRUPT before importing EnableInterrupt within a
* library.
*/
#define LIBCALL_ENABLEINTERRUPT
// To handle external and pin change interrupts
#include "ModSensorInterrupts.h"

#include "SDI12Sensors.h"

Expand Down

0 comments on commit 1696601

Please sign in to comment.