bit _isr_gie; /* Used to store the state of GIE for nested ndi()/nei() */
unsigned char _isr_di; /* Count of nested ndi() */
+void ndi()
+{
+ if (_isr_di++ == 0) {
+ _isr_gie = GIE;
+ di();
+ }
+}
+
+/* Nested enable interrupts inline function. Should be OK even in ISR. */
+void nei()
+{
+ if (--_isr_di == 0 && _isr_gie)
+ ei();
+}
+
void interrupt isr()
{
tmr_isr();