Skip to content

Commit c917270

Browse files
authored
Merge pull request #2956 from hathach/fix-samd-wfi
fix racing issue for SAMD when executing WFI
2 parents ffe0e0e + e793406 commit c917270

File tree

1 file changed

+7
-1
lines changed
  • ports/atmel-samd/supervisor

1 file changed

+7
-1
lines changed

ports/atmel-samd/supervisor/port.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
#include "samd/events.h"
7070
#include "samd/external_interrupts.h"
7171
#include "samd/dma.h"
72+
#include "shared-bindings/microcontroller/__init__.h"
7273
#include "shared-bindings/rtc/__init__.h"
7374
#include "reset.h"
7475

@@ -496,7 +497,12 @@ void port_sleep_until_interrupt(void) {
496497
(void) __get_FPSCR();
497498
}
498499
#endif
499-
__WFI();
500+
common_hal_mcu_disable_interrupts();
501+
if (!tud_task_event_ready()) {
502+
__DSB();
503+
__WFI();
504+
}
505+
common_hal_mcu_enable_interrupts();
500506
}
501507

502508
/**

0 commit comments

Comments
 (0)