1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cpu/atmega_common: implement irq_is_enabled()

This commit is contained in:
Hauke Petersen 2019-03-06 18:03:09 +01:00
parent d4181b91fa
commit 48e2d6e8f9

View File

@ -103,6 +103,21 @@ __attribute__((always_inline)) static inline int irq_is_in(void)
return (state & AVR8_STATE_FLAG_ISR);
}
/**
* @brief Test if interrupts are currently enabled
*/
__attribute__((always_inline)) static inline int irq_is_enabled(void)
{
uint8_t mask;
__asm__ volatile(
"in %[dest], __SREG__" "\n\t"
: [dest] "=r"(mask)
: /* no inputs */
: "memory"
);
return mask & (1 << 7);
}
#ifdef __cplusplus
}
#endif