Skip to content
Snippets Groups Projects
Unverified Commit ed1ab107 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

msp430fr5969: sleep: restore interrupt state

parent d326c7e5
No related merge requests found
......@@ -86,6 +86,13 @@ extern void loop();
volatile char run_loop = 0;
#endif
inline static unsigned int irq_enabled()
{
unsigned int sr;
__asm__ __volatile__("mov SR, %0" : "=r" (sr) : );
return sr & GIE;
}
volatile bool sleep_done = false;
// max delay: 262 ms @ 16 MHz
......@@ -95,6 +102,7 @@ void Arch::sleep_ms(unsigned int const ms)
if (ms == 0) {
return;
}
int int_enabled = irq_enabled();
sleep_done = false;
#if F_CPU == 16000000UL
TA3CTL = TASSEL__SMCLK | ID__8; // /8
......@@ -121,7 +129,9 @@ void Arch::sleep_ms(unsigned int const ms)
asm volatile("nop");
__bis_SR_register(GIE | LPM2_bits);
asm volatile("nop");
__dint();
if (!int_enabled) {
__dint();
}
}
TA3CTL = TASSEL__SMCLK;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment