Synopsis
#include <inavr.h> unsigned __enable_interrupt(void);
Description
__enable_interrupt enables global interrupts by setting the I bit in the status register and returns the value of the status register before the I bit is set. You can restore the state of the I bit from the value returned from __enable_interrupt by using the __restore_interrupt intrinsic function.
__enable_interrupt is an intrinsic function and produces inline code.
Example
void run_with_interrupts_enabled(void)
{
// Enable interrupts and save interrupt enable state
unsigned char state = __enable_interrupt();
// Processing with interrupts enabled here
// Restore interrupt enable state from saved value
__restore_interrupt(state);
}
Portability
__enable_interrupt can be used on any AVR device.