From 5fb2441afd4b5d08fcb8a0b85e30b2539f1ed03e Mon Sep 17 00:00:00 2001
From: ch3 <ch3@mailbox.org>
Date: Thu, 11 Jul 2019 23:53:14 +0200
Subject: [PATCH] feat(epicardium api): Set GPIO pins for evaluating timings

---
 epicardium/api/caller.c     | 2 ++
 epicardium/api/common.h     | 5 +++++
 epicardium/api/dispatcher.c | 2 ++
 epicardium/support.c        | 1 +
 4 files changed, 10 insertions(+)

diff --git a/epicardium/api/caller.c b/epicardium/api/caller.c
index f1ba675f..c914159b 100644
--- a/epicardium/api/caller.c
+++ b/epicardium/api/caller.c
@@ -7,6 +7,7 @@
 
 void *_api_call_start(api_id_t id, uintptr_t size)
 {
+	GPIO_OutSet(&debug_pin_1);
 	while (SEMA_GetSema(_API_SEMAPHORE) == E_BUSY) {
 	}
 
@@ -32,6 +33,7 @@ void *_api_call_transact(void *buffer)
 	API_CALL_MEM->call_flag = _API_FLAG_CALLING;
 	SEMA_FreeSema(_API_SEMAPHORE);
 
+	GPIO_OutSet(&debug_pin_0);
 	/* Notify the dispather of the new call */
 	__SEV();
 	__WFE();
diff --git a/epicardium/api/common.h b/epicardium/api/common.h
index a929f301..f1581370 100644
--- a/epicardium/api/common.h
+++ b/epicardium/api/common.h
@@ -1,5 +1,6 @@
 #include <stdint.h>
 #include <stdbool.h>
+#include "gpio.h"
 
 /*
  * Semaphore used for API synchronization.
@@ -7,6 +8,10 @@
  */
 #define _API_SEMAPHORE    0
 
+static const gpio_cfg_t debug_pin_0 = {PORT_0, PIN_22, GPIO_FUNC_OUT, GPIO_PAD_NONE};
+static const gpio_cfg_t debug_pin_1 = {PORT_0, PIN_21, GPIO_FUNC_OUT, GPIO_PAD_NONE};
+
+
 /* Type of API IDs */
 typedef uint32_t api_id_t;
 
diff --git a/epicardium/api/dispatcher.c b/epicardium/api/dispatcher.c
index 4675c8d4..92f21315 100644
--- a/epicardium/api/dispatcher.c
+++ b/epicardium/api/dispatcher.c
@@ -55,6 +55,8 @@ api_id_t api_dispatcher_exec()
 		return 0;
 	}
 
+	GPIO_OutClr(&debug_pin_1);
+
 	api_id_t id = API_CALL_MEM->id;
 	__api_dispatch_call(id, API_CALL_MEM->buffer);
 	API_CALL_MEM->call_flag = _API_FLAG_RETURNED;
diff --git a/epicardium/support.c b/epicardium/support.c
index 534506ba..d04055e2 100644
--- a/epicardium/support.c
+++ b/epicardium/support.c
@@ -29,6 +29,7 @@ void pre_idle_sleep(TickType_t xExpectedIdleTime)
 		__asm volatile("dsb" ::: "memory");
 		__asm volatile("wfe");
 		__asm volatile("isb");
+		GPIO_OutClr(&debug_pin_0);
 	}
 }
 
-- 
GitLab