Orbcode Trace functions library
tpiu.h
Go to the documentation of this file.
1 
3 #pragma once
4 #include <stdbool.h>
5 #include <stdint.h>
6 
7 #if !defined(TPI)
8 # error \
9  "TPI not defined. Include tpiu.h AFTER core_cmX.h (typically after including device-specific header)"
10 #endif
11 
12 #ifdef __cplusplus
13 extern "C"
14 {
15 #endif
16 
33  typedef enum
34  {
40 
46 
52  } TpiuProtocol;
53 
57  typedef struct
58  {
67 
79 
88 
94  uint8_t TracePortWidth;
95  } TpiuOptions;
96 
107  static inline void TpiuSetup(const TpiuOptions* options);
108 
111  void TpiuSetup(const TpiuOptions* options)
112  {
113  CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; // Enable ITM and DWT
114 
115  TPI->ACPR = options->SwoPrescaler - 1;
116  TPI->SPPR = (int)options->Protocol;
117  TPI->CSPSR = 1 << (options->TracePortWidth - 1);
118 
119  if(options->FormattingEnabled)
120  {
121  TPI->FFCR |= TPI_FFCR_EnFCont_Msk;
122  }
123  else
124  {
125  TPI->FFCR &= ~TPI_FFCR_EnFCont_Msk;
126  }
127  }
128 
129 #ifdef __cplusplus
130 }
131 #endif
TpiuProtocol
Available trace protocols.
Definition: tpiu.h:34
static void TpiuSetup(const TpiuOptions *options)
Configure TPIU component.
Definition: tpiu.h:111
@ TpiuProtocolSwoManchester
Manchester encoded data Use tool like Orbtrace to receive data. Single pin, lower bandwitdh,...
Definition: tpiu.h:45
@ TpiuProtocolParallel
Parallel trace port 1-4 bits Use tool like Orbtrace to receive data. Good for transmitting lots of in...
Definition: tpiu.h:39
@ TpiuProtocolSwoUart
UART (NRZ) encoded data Use any UART adapter to receive data. Single pin, easy to access,...
Definition: tpiu.h:51
TPIU configuration options.
Definition: tpiu.h:58
TpiuProtocol Protocol
Selected protocol.
Definition: tpiu.h:66
bool FormattingEnabled
Include TPIU framining in output data.
Definition: tpiu.h:78
int SwoPrescaler
Prescaler for SWO output data.
Definition: tpiu.h:87
uint8_t TracePortWidth
Number of bits in parallel trace port.
Definition: tpiu.h:94