summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-07-12 15:21:49 +0200
committerDaniel Friesel <derf@finalrewind.org>2018-07-12 15:21:49 +0200
commit7f6b7ecfb0fb60a08dcc6c174d313eee052a94dc (patch)
tree2c69d2960de501b148cff3ee6bce7184ae88ec51 /src/arch
parent2419fe236b1b9da1f134586fd1999264b360fc36 (diff)
MSP430: Call loop() from main function to avoid nested interrupts
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/msp430fr5969lp/arch.cc18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/arch/msp430fr5969lp/arch.cc b/src/arch/msp430fr5969lp/arch.cc
index 8281e66..aee46f3 100644
--- a/src/arch/msp430fr5969lp/arch.cc
+++ b/src/arch/msp430fr5969lp/arch.cc
@@ -67,11 +67,24 @@ void Arch::setup(void)
extern void wakeup();
#endif
+#if defined(WITH_LOOP)
+extern void loop();
+volatile char run_loop = 0;
+#endif
+
void Arch::idle_loop(void)
{
while (1) {
__eint();
- __bis_SR_register(LPM0_bits);
+ asm volatile("nop");
+ __bis_SR_register(LPM2_bits);
+ asm volatile("nop");
+#if defined(WITH_LOOP)
+ if (run_loop) {
+ loop();
+ run_loop = 0;
+ }
+#endif
#ifdef WITH_WAKEUP
wakeup();
#endif
@@ -83,13 +96,12 @@ Arch arch;
#if defined(WITH_LOOP) || defined(TIMER_S)
#include "driver/uptime.h"
-extern void loop();
__attribute__((interrupt(TIMER1_A1_VECTOR))) __attribute__((wakeup)) void handle_timer0_overflow()
{
if (TA1IV == 0x0e) {
#ifdef WITH_LOOP
- loop();
+ run_loop = 1;
#endif
#ifdef TIMER_S
uptime.tick_s();