From 41a5c1d2cfe976790f54e1a5c7629be4d9617c29 Mon Sep 17 00:00:00 2001
From: schneider <schneider@muc.ccc.de>
Date: Mon, 29 Jul 2019 21:37:56 +0000
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 a4af99db4..90e14efae 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