summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Shawcroft <scott@adafruit.com>2020-05-26 14:54:24 -0700
committerGitHub <noreply@github.com>2020-05-26 14:54:24 -0700
commitc917270da7d3a84fac047addd376103b981185ad (patch)
treea752ab0918df02050194f3e73ad45dca13aed96b
parentffe0e0edc371cad05ee6cc1bc8cd7b7a77bd2145 (diff)
parente79340601fc051183d6cc243c43da7f2e75249ae (diff)
Merge pull request #2956 from hathach/fix-samd-wfi
fix racing issue for SAMD when executing WFI
-rw-r--r--ports/atmel-samd/supervisor/port.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c
index eadd3e8f5..2b3e9826f 100644
--- a/ports/atmel-samd/supervisor/port.c
+++ b/ports/atmel-samd/supervisor/port.c
@@ -69,6 +69,7 @@
#include "samd/events.h"
#include "samd/external_interrupts.h"
#include "samd/dma.h"
+#include "shared-bindings/microcontroller/__init__.h"
#include "shared-bindings/rtc/__init__.h"
#include "reset.h"
@@ -496,7 +497,12 @@ void port_sleep_until_interrupt(void) {
(void) __get_FPSCR();
}
#endif
- __WFI();
+ common_hal_mcu_disable_interrupts();
+ if (!tud_task_event_ready()) {
+ __DSB();
+ __WFI();
+ }
+ common_hal_mcu_enable_interrupts();
}
/**