summaryrefslogtreecommitdiff
path: root/shared/trace.c
blob: 9e05d9a035ebe4ad7d1e3cd6c88af3343a53024c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <stdint.h>
#include <libopencm3/cm3/common.h>
#include <libopencm3/cm3/memorymap.h>
#include <libopencm3/cm3/itm.h>
#include "trace.h"

void trace_send_blocking8(int stimulus_port, char c) {
	if (!(ITM_TER[0] & (1<<stimulus_port))) {
		return;
	}
	while (!(ITM_STIM8(stimulus_port) & ITM_STIM_FIFOREADY))
		;
	ITM_STIM8(stimulus_port) = c;
}

void trace_send8(int stimulus_port, char val) {
	if (!(ITM_TER[0] & (1<<stimulus_port))) {
		return;
	}
	ITM_STIM8(stimulus_port) = val;
}

void trace_send_blocking16(int stimulus_port, uint16_t val) {
	if (!(ITM_TER[0] & (1<<stimulus_port))) {
		return;
	}
	while (!(ITM_STIM16(stimulus_port) & ITM_STIM_FIFOREADY))
		;
	ITM_STIM16(stimulus_port) = val;
}

void trace_send16(int stimulus_port, uint16_t val) {
	if (!(ITM_TER[0] & (1<<stimulus_port))) {
		return;
	}
	ITM_STIM16(stimulus_port) = val;
}


void trace_send_blocking32(int stimulus_port, uint32_t val) {
	if (!(ITM_TER[0] & (1<<stimulus_port))) {
		return;
	}
	while (!(ITM_STIM32(stimulus_port) & ITM_STIM_FIFOREADY))
		;
	ITM_STIM32(stimulus_port) = val;
}

void trace_send32(int stimulus_port, uint32_t val) {
	if (!(ITM_TER[0] & (1<<stimulus_port))) {
		return;
	}
	ITM_STIM32(stimulus_port) = val;
}