From 45f84c2d35fa0bb22d50669a88f5dc9405165427 Mon Sep 17 00:00:00 2001
From: schneider <schneider@blinkenlichts.net>
Date: Sat, 27 Jul 2019 13:55:03 +0200
Subject: [PATCH] hack(FreeRTOS): Do not call WFE when a debugger is active

---
 epicardium/support.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/epicardium/support.c b/epicardium/support.c
index a4af99db..a757db6d 100644
--- a/epicardium/support.c
+++ b/epicardium/support.c
@@ -27,9 +27,11 @@ void pre_idle_sleep(TickType_t xExpectedIdleTime)
 		 * TODO: Ensure this is actually correct and does not have any
 		 * race conditions.
 		 */
-		__asm volatile("dsb" ::: "memory");
-		__asm volatile("wfe");
-		__asm volatile("isb");
+		if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk == 0)) {
+			__asm volatile("dsb" ::: "memory");
+			__asm volatile("wfe");
+			__asm volatile("isb");
+		}
 	}
 }
 
-- 
GitLab