summaryrefslogtreecommitdiff
path: root/shared/trace_stdio.c
diff options
context:
space:
mode:
authorKarl Palsson <karlp@tweak.net.au>2015-10-16 21:56:42 +0000
committerKarl Palsson <karlp@tweak.net.au>2015-10-17 02:15:58 +0000
commit8d538b3935842204c7a545184df302958fc2015d (patch)
tree94feaf5cb9d44ba2cfb2ada45e2cd9e9cdcaf7ee /shared/trace_stdio.c
parent0bcc5d5efd70ed4564c141a7f38f78f52ea088a0 (diff)
downloadolsndot-8d538b3935842204c7a545184df302958fc2015d.tar.gz
olsndot-8d538b3935842204c7a545184df302958fc2015d.tar.bz2
olsndot-8d538b3935842204c7a545184df302958fc2015d.zip
stub adc on/off test code.
Needs a pot on PA0, should get the temperature input working as well.
Diffstat (limited to 'shared/trace_stdio.c')
-rw-r--r--shared/trace_stdio.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/shared/trace_stdio.c b/shared/trace_stdio.c
new file mode 100644
index 0000000..2710942
--- /dev/null
+++ b/shared/trace_stdio.c
@@ -0,0 +1,34 @@
+/*
+ * support for stdio output to a trace port
+ * Karl Palsson, 2014 <karlp@remake.is>
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "trace.h"
+
+#ifndef STIMULUS_STDIO
+#define STIMULUS_STDIO 0
+#endif
+
+int _write(int file, char *ptr, int len);
+int _write(int file, char *ptr, int len)
+{
+ int i;
+
+ if (file == STDOUT_FILENO || file == STDERR_FILENO) {
+ for (i = 0; i < len; i++) {
+ if (ptr[i] == '\n') {
+ trace_send_blocking8(STIMULUS_STDIO, '\r');
+ }
+ trace_send_blocking8(STIMULUS_STDIO, ptr[i]);
+ }
+ return i;
+ }
+ errno = EIO;
+ return -1;
+}
+
+