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;
~ExternalOff()
Re-enable the selected external interrupts.
Definition: InterruptUtils.h:170
All external interrupts.
Definition: InterruptUtils.h:134
PinChangeOff(uint8_t whichOnesToTurnOff=kPinChangeInterruptMask)
Suppress some or all of the pin change interrupts when the object is instantiated.
Definition: InterruptUtils.h:231
Pin change interrupt 1.
Definition: InterruptUtils.h:207
ExternalOff(uint8_t whichOnesToTurnOff=kExternalInterruptMask)
Suppress some or all of the external interrupts when the object is instantiated.
Definition: InterruptUtils.h:157
Pin change interrupt 0.
Definition: InterruptUtils.h:206
~AllOff()
Re-enable interrupts, restoring the interrupt state as it was when the object was instantiated...
Definition: InterruptUtils.h:83
External interrupt 0.
Definition: InterruptUtils.h:122
External interrupt 6 (ATmega2560 only)
Definition: InterruptUtils.h:130
External interrupt 1.
Definition: InterruptUtils.h:123
All pin change interrupts.
Definition: InterruptUtils.h:209
This namespace bundles various utility classes designed to suppress selected interrupts using the RAI...
Definition: InterruptUtils.h:54
Pin change interrupt 2.
Definition: InterruptUtils.h:208
This class defines an object that disables selected pin change interrupts during its lifetime...
Definition: InterruptUtils.h:219
External interrupt 4 (ATmega2560 only)
Definition: InterruptUtils.h:128
~PinChangeOff()
Re-enable the selected pin change interrupts.
Definition: InterruptUtils.h:243
PinChangeInterrupts
This enum lists the pin change interrupts that can be suppressed (disabled). To pass more than one pi...
Definition: InterruptUtils.h:204
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:144
External interrupt 7 (ATmega2560 only)
Definition: InterruptUtils.h:131
External interrupt 2 (ATmega2560 only)
Definition: InterruptUtils.h:126
External interrupt 5 (ATmega2560 only)
Definition: InterruptUtils.h:129
This class defines an object that disables all interrupts during its lifetime. Interrupt state is res...
Definition: InterruptUtils.h:63
ExternalInterrupts
This enum lists the external interrupts that can be suppressed (disabled). To pass more than one exte...
Definition: InterruptUtils.h:120
External interrupt 3 (ATmega2560 only)
Definition: InterruptUtils.h:127