Synopsis
#include <inavr.h> unsigned char __disable_interrupt(void);
Description
__disable_interrupt disables global interrupts by clearing the I bit in the status register and returns the value of the status register before the I bit is cleared. You can restore the state of the I bit from the value returned from __disable_interrupt by using the __restore_interrupt intrinsic function.
__disable_interrupt is an intrinsic function and produces inline code.
Example
void critical_function(void) { // Disable interrupts and save interrupt enable state unsigned char state = __disable_interrupt(); // Critical processing here // Restore interrupt enable state from saved value __restore_interrupt(state); }
Portability
__disable_interrupt can be used on any AVR device.