You've already forked ArduinoLowPower
mirror of
https://github.com/arduino-libraries/ArduinoLowPower.git
synced 2025-10-16 02:46:40 +03:00
Add support for ADC wakeup interrupt on SAMD21
This can be used to configure the ADC window interrupt on the SAMD21. It uses OSCULP32K via GCLK6 to clock the ADC while in sleep mode (the same as used for the EIC). Note that attachAdcInterrupt()/detachAdcInterrupt() should be called immediately before/after LowPower.sleep() otherwise analogRead() will not work as expected. There is also an example (AdcWakeup.ino) which is much like the ExternalWakeup example but uses the ADC interrupt instead.
This commit is contained in:
@@ -28,6 +28,16 @@ typedef enum{
|
||||
ANALOG_COMPARATOR_WAKEUP = 3
|
||||
} wakeup_reason;
|
||||
|
||||
#ifdef ARDUINO_ARCH_SAMD
|
||||
enum adc_interrupt
|
||||
{
|
||||
ADC_INT_BETWEEN,
|
||||
ADC_INT_OUTSIDE,
|
||||
ADC_INT_ABOVE_MIN,
|
||||
ADC_INT_BELOW_MAX,
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
class ArduinoLowPowerClass {
|
||||
public:
|
||||
@@ -68,10 +78,17 @@ class ArduinoLowPowerClass {
|
||||
wakeup_reason wakeupReason();
|
||||
#endif
|
||||
|
||||
#ifdef ARDUINO_ARCH_SAMD
|
||||
void attachAdcInterrupt(uint32_t pin, voidFuncPtr callback, adc_interrupt mode, uint16_t lo, uint16_t hi);
|
||||
void detachAdcInterrupt();
|
||||
#endif
|
||||
|
||||
private:
|
||||
void setAlarmIn(uint32_t millis);
|
||||
#ifdef ARDUINO_ARCH_SAMD
|
||||
RTCZero rtc;
|
||||
voidFuncPtr adc_cb;
|
||||
friend void ADC_Handler();
|
||||
#endif
|
||||
#ifdef BOARD_HAS_COMPANION_CHIP
|
||||
void (*companionSleepCB)(bool);
|
||||
|
Reference in New Issue
Block a user