From fd4ef233c6d9b312c3582466c68390a16ddf15fa Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Thu, 21 May 2020 21:46:37 +0800 Subject: nrf: port: add memory barrier before wfi ARM recommends issuing a DSB instruction propr to issuing WFI, as it is required on many parts suchas Cortex-M7. This is effectively a no-op on the Cortex-M4 used in most NRF parts, however it ensures that we won't be surprised when new parts come out. See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dai0321a/BIHICBGB.html for more information. Signed-off-by: Sean Cross --- ports/nrf/supervisor/port.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index aa138e481..36725293c 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -273,8 +273,10 @@ void port_sleep_until_interrupt(void) { // available, even though the actual handler won't fire until // we re-enable interrupts. common_hal_mcu_disable_interrupts(); - if (!tud_task_event_ready()) + if (!tud_task_event_ready()) { + __DSB(); __WFI(); + } common_hal_mcu_enable_interrupts(); } } -- cgit v1.2.3