diff --git a/arm/lock.h b/arm/lock.h index bd6c6b6..ac06a17 100644 --- a/arm/lock.h +++ b/arm/lock.h @@ -3,13 +3,11 @@ #include "aum1_cm1.h" struct InterruptLock { - bool was_locked; + uint32_t old_primask; - InterruptLock() : was_locked(__get_PRIMASK() != 0) { __disable_irq(); } + InterruptLock() : old_primask(__get_PRIMASK()) { __disable_irq(); } ~InterruptLock() { - if (!was_locked) { - __enable_irq(); - } + __set_PRIMASK(old_primask); } };