36#ifndef InterruptUtils_h
37#define InterruptUtils_h
43#include <util/atomic.h>
86 if ( mSreg &
static_cast<uint8_t
>(1 << SREG_I) )
104#if defined(__AVR_ATmega328P__)
105#define kExternalInterruptMask 0x03
106#elif defined(__AVR_ATmega2560__)
107#define kExternalInterruptMask 0xFF
109#error "Undefined AVR processor type"
125#if defined(__AVR_ATmega2560__)
157 ExternalOff( uint8_t whichOnesToTurnOff = kExternalInterruptMask )
158 : mExternalInterruptsToSuppress( whichOnesToTurnOff & kExternalInterruptMask )
161 EIMSK &= ~(mExternalInterruptsToSuppress);
173 EIMSK |= mExternalInterruptsToSuppress;
179 uint8_t mExternalInterruptsToSuppress;
188#if defined(__AVR_ATmega328P__)
189#define kPinChangeInterruptMask 0x07
190#elif defined(__AVR_ATmega2560__)
191#define kPinChangeInterruptMask 0x07
193#error "Undefined AVR processor type"
232 : mPinChangeInterruptsToSuppress( whichOnesToTurnOff & kPinChangeInterruptMask )
235 PCICR &= ~(mPinChangeInterruptsToSuppress);
246 PCICR |= mPinChangeInterruptsToSuppress;
252 uint8_t mPinChangeInterruptsToSuppress;
This class defines an object that disables all interrupts during its lifetime. Interrupt state is res...
Definition InterruptUtils.h:64
~AllOff()
Re-enable interrupts, restoring the interrupt state as it was when the object was instantiated.
Definition InterruptUtils.h:83
AllOff()
Suppress all interrupts when the object is instantiated.
Definition InterruptUtils.h:71
This class defines an object that disables selected external interrupts during its lifetime....
Definition InterruptUtils.h:145
~ExternalOff()
Re-enable the selected external interrupts.
Definition InterruptUtils.h:170
ExternalOff(uint8_t whichOnesToTurnOff=kExternalInterruptMask)
Suppress some or all of the external interrupts when the object is instantiated.
Definition InterruptUtils.h:157
This class defines an object that disables selected pin change interrupts during its lifetime....
Definition InterruptUtils.h:220
PinChangeOff(uint8_t whichOnesToTurnOff=kPinChangeInterruptMask)
Suppress some or all of the pin change interrupts when the object is instantiated.
Definition InterruptUtils.h:231
~PinChangeOff()
Re-enable the selected pin change interrupts.
Definition InterruptUtils.h:243
This namespace bundles various utility classes designed to suppress selected interrupts using the RAI...
Definition InterruptUtils.h:55
PinChangeInterrupts
This enum lists the pin change interrupts that can be suppressed (disabled). To pass more than one pi...
Definition InterruptUtils.h:205
@ kPinChangeInterruptAll
All pin change interrupts.
Definition InterruptUtils.h:209
@ kPinChangeInterrupt1
Pin change interrupt 1.
Definition InterruptUtils.h:207
@ kPinChangeInterrupt0
Pin change interrupt 0.
Definition InterruptUtils.h:206
@ kPinChangeInterrupt2
Pin change interrupt 2.
Definition InterruptUtils.h:208
ExternalInterrupts
This enum lists the external interrupts that can be suppressed (disabled). To pass more than one exte...
Definition InterruptUtils.h:121
@ kExternalInterrupt5
External interrupt 5 (ATmega2560 only)
Definition InterruptUtils.h:129
@ kExternalInterrupt1
External interrupt 1.
Definition InterruptUtils.h:123
@ kExternalInterrupt2
External interrupt 2 (ATmega2560 only)
Definition InterruptUtils.h:126
@ kExternalInterrupt4
External interrupt 4 (ATmega2560 only)
Definition InterruptUtils.h:128
@ kExternalInterruptAll
All external interrupts.
Definition InterruptUtils.h:134
@ kExternalInterrupt6
External interrupt 6 (ATmega2560 only)
Definition InterruptUtils.h:130
@ kExternalInterrupt0
External interrupt 0.
Definition InterruptUtils.h:122
@ kExternalInterrupt7
External interrupt 7 (ATmega2560 only)
Definition InterruptUtils.h:131
@ kExternalInterrupt3
External interrupt 3 (ATmega2560 only)
Definition InterruptUtils.h:127