From 8d538b3935842204c7a545184df302958fc2015d Mon Sep 17 00:00:00 2001 From: Karl Palsson Date: Fri, 16 Oct 2015 21:56:42 +0000 Subject: stub adc on/off test code. Needs a pot on PA0, should get the temperature input working as well. --- shared/trace.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ shared/trace.h | 30 +++++++++++++++++++++++++++++ shared/trace_stdio.c | 34 +++++++++++++++++++++++++++++++++ 3 files changed, 118 insertions(+) create mode 100644 shared/trace.c create mode 100644 shared/trace.h create mode 100644 shared/trace_stdio.c (limited to 'shared') diff --git a/shared/trace.c b/shared/trace.c new file mode 100644 index 0000000..9e05d9a --- /dev/null +++ b/shared/trace.c @@ -0,0 +1,54 @@ +#include +#include +#include +#include +#include "trace.h" + +void trace_send_blocking8(int stimulus_port, char c) { + if (!(ITM_TER[0] & (1< + */ + +#ifndef TRACE_H +#define TRACE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void trace_send_blocking8(int stimulus_port, char c); +void trace_send8(int stimulus_port, char c); + +void trace_send_blocking16(int stimulus_port, uint16_t val); +void trace_send16(int stimulus_port, uint16_t val); + +void trace_send_blocking32(int stimulus_port, uint32_t val); +void trace_send32(int stimulus_port, uint32_t val); + + +#ifdef __cplusplus +} +#endif + +#endif /* TRACE_H */ + 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 + */ + +#include +#include +#include + +#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; +} + + -- cgit