Disables then re-enables interrupts based on variable scope. Ensures you don't forget to re-enable interrupts. Use Wisely!
intdisabler.h
- Committer:
- Tomo2k
- Date:
- 2014-04-23
- Revision:
- 0:cd6400023513
File content as of revision 0:cd6400023513:
/* (C) 2014 Richard Thompson (Tomo2k) This software is Apache 2.0 licenced for this to be reused. That said, it's trivial and rather obvious! */ #pragma once #include "mbed.h" //! Disable then Enable interrupts using variable scope. //! Ensures always re-enabled regardless of method exit class IntDisabler { public: //! Disable Interrupts IntDisabler() { __disable_irq(); } //! Enables Interrupts on destruction ~IntDisabler() { __enable_irq(); } private: // Disable copy IntDisabler & operator=(const IntDisabler&); IntDisabler(const IntDisabler &); };