retrolefty:
Now if you do ever have the need to 'protect code' requiring atomic protection that arduino has the needed functions already defined for you that will handle saving and restoring the SREG register:
Er, not really. interrupts() just enables interrupts, it doesn't restore the SREG. They're also just #defined as sei() and cli() and I don't see a reason to further obfuscate code by giving it other names.
However, there does exist code that will properly restore the SREG:
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
// time sensitive code or reading variables shared by interrupt
}
// normal code
http://www.nongnu.org/avr-libc/user-manual/group__util__atomic.html