summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <thach@tinyusb.org>2020-05-25 20:51:02 +0700
committerhathach <thach@tinyusb.org>2020-05-25 20:51:02 +0700
commite79340601fc051183d6cc243c43da7f2e75249ae (patch)
tree43759102af6d99e355ccf042a62fa594cceeaaf9
parent37a7cf99347b98670582fcfbd3177a643a66bee7 (diff)
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();
}
/**