summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2019-11-18 10:51:16 -0600
committerJeff Epler <jepler@gmail.com>2019-11-18 11:01:24 -0600
commit40a47d41dfea885ecfbc6a6fe1fc2ec5124a293b (patch)
tree026fdd86dda894f27e2ade1273d504dc97121b4b
parent7f744a2369a5036cadfa05575da1704f709c98bb (diff)
samd: background: Allow monitoring time taken in background task
If you define MONITOR_BACKGROUND_TASK, then a physical output pin (Metro M4 Express's "SCL" pin by default) will be set HIGH while in the background task and LOW at other times
-rw-r--r--ports/atmel-samd/background.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/ports/atmel-samd/background.c b/ports/atmel-samd/background.c
index 3b698768b..ca91a31de 100644
--- a/ports/atmel-samd/background.c
+++ b/ports/atmel-samd/background.c
@@ -45,6 +45,23 @@ bool stack_ok_so_far = true;
static bool running_background_tasks = false;
+#ifdef MONITOR_BACKGROUND_TASKS
+// PB03 is physical pin "SCL" on the Metro M4 express
+// so you can't use this code AND an i2c peripheral
+// at the same time unless you change this
+STATIC void start_background_task(void) {
+ REG_PORT_DIRSET1 = (1<<3);
+ REG_PORT_OUTSET1 = (1<<3);
+}
+
+STATIC void finish_background_task(void) {
+ REG_PORT_OUTCLR1 = (1<<3);
+}
+#else
+STATIC void start_background_task(void) {}
+STATIC void finish_background_task(void) {}
+#endif
+
void background_tasks_reset(void) {
running_background_tasks = false;
}
@@ -54,6 +71,9 @@ void run_background_tasks(void) {
if (running_background_tasks) {
return;
}
+
+ start_background_task();
+
assert_heap_ok();
running_background_tasks = true;
@@ -73,6 +93,7 @@ void run_background_tasks(void) {
assert_heap_ok();
last_finished_tick = supervisor_ticks_ms64();
+ finish_background_task();
}
bool background_tasks_ok(void) {