20#ifndef LIBOPENCM3_CM3_DWT_H
21#define LIBOPENCM3_CM3_DWT_H
47#define DWT_CTRL MMIO32(DWT_BASE + 0x00)
50#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
67#define DWT_CYCCNT MMIO32(DWT_BASE + 0x04)
80#define DWT_CPICNT MMIO32(DWT_BASE + 0x08)
81#define DWT_EXCCNT MMIO32(DWT_BASE + 0x0C)
82#define DWT_SLEEPCNT MMIO32(DWT_BASE + 0x10)
83#define DWT_LSUCNT MMIO32(DWT_BASE + 0x14)
84#define DWT_FOLDCNT MMIO32(DWT_BASE + 0x18)
88#define DWT_PCSR MMIO32(DWT_BASE + 0x1C)
89#define DWT_COMP(n) MMIO32(DWT_BASE + 0x20 + (n) * 16)
90#define DWT_MASK(n) MMIO32(DWT_BASE + 0x24 + (n) * 16)
91#define DWT_FUNCTION(n) MMIO32(DWT_BASE + 0x28 + (n) * 16)
94#define DWT_LSR MMIO32(DWT_BASE + CORESIGHT_LSR_OFFSET)
96#define DWT_LAR MMIO32(DWT_BASE + CORESIGHT_LAR_OFFSET)
105#define DWT_CTRL_NUMCOMP_SHIFT 28
106#define DWT_CTRL_NUMCOMP (0x0F << DWT_CTRL_NUMCOMP_SHIFT)
109#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
111#define DWT_CTRL_NOTRCPKT (1 << 27)
112#define DWT_CTRL_NOEXTTRIG (1 << 26)
113#define DWT_CTRL_NOCYCCNT (1 << 25)
114#define DWT_CTRL_NOPRFCCNT (1 << 24)
116#define DWT_CTRL_CYCEVTENA (1 << 22)
117#define DWT_CTRL_FOLDEVTENA (1 << 21)
118#define DWT_CTRL_LSUEVTENA (1 << 20)
119#define DWT_CTRL_SLEEPEVTENA (1 << 19)
120#define DWT_CTRL_EXCEVTENA (1 << 18)
121#define DWT_CTRL_CPIEVTENA (1 << 17)
122#define DWT_CTRL_EXCTRCENA (1 << 16)
123#define DWT_CTRL_PCSAMPLENA (1 << 12)
125#define DWT_CTRL_SYNCTAP_SHIFT 10
126#define DWT_CTRL_SYNCTAP (3 << DWT_CTRL_SYNCTAP_SHIFT)
127#define DWT_CTRL_SYNCTAP_DISABLED (0 << DWT_CTRL_SYNCTAP_SHIFT)
128#define DWT_CTRL_SYNCTAP_BIT24 (1 << DWT_CTRL_SYNCTAP_SHIFT)
129#define DWT_CTRL_SYNCTAP_BIT26 (2 << DWT_CTRL_SYNCTAP_SHIFT)
130#define DWT_CTRL_SYNCTAP_BIT28 (3 << DWT_CTRL_SYNCTAP_SHIFT)
132#define DWT_CTRL_CYCTAP (1 << 9)
134#define DWT_CTRL_POSTCNT_SHIFT 5
135#define DWT_CTRL_POSTCNT (0x0F << DWT_CTRL_POSTCNT_SHIFT)
137#define DWT_CTRL_POSTPRESET_SHIFT 1
138#define DWT_CTRL_POSTPRESET (0x0F << DWT_CTRL_POSTPRESET_SHIFT)
145#define DWT_CTRL_CYCCNTENA (1 << 0)
151#define DWT_MASKx_MASK 0x0F
155#define DWT_FUNCTIONx_MATCHED (1 << 24)
158#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
160#define DWT_FUNCTIONx_DATAVADDR1_SHIFT 16
161#define DWT_FUNCTIONx_DATAVADDR1 (15 << DWT_FUNCTIONx_DATAVADDR1_SHIFT)
163#define DWT_FUNCTIONx_DATAVADDR0_SHIFT 12
164#define DWT_FUNCTIONx_DATAVADDR0 (15 << DWT_FUNCTIONx_DATAVADDR0_SHIFT)
166#define DWT_FUNCTIONx_DATAVSIZE_SHIFT 10
167#define DWT_FUNCTIONx_DATAVSIZE (3 << DWT_FUNCTIONx_DATAVSIZE_SHIFT)
168#define DWT_FUNCTIONx_DATAVSIZE_BYTE (0 << DWT_FUNCTIONx_DATAVSIZE_SHIFT)
169#define DWT_FUNCTIONx_DATAVSIZE_HALF (1 << DWT_FUNCTIONx_DATAVSIZE_SHIFT)
170#define DWT_FUNCTIONx_DATAVSIZE_WORD (2 << DWT_FUNCTIONx_DATAVSIZE_SHIFT)
172#define DWT_FUNCTIONx_LNK1ENA (1 << 9)
173#define DWT_FUNCTIONx_DATAVMATCH (1 << 8)
174#define DWT_FUNCTIONx_CYCMATCH (1 << 7)
175#define DWT_FUNCTIONx_EMITRANGE (1 << 5)
179#define DWT_FUNCTIONx_FUNCTION 15
180#define DWT_FUNCTIONx_FUNCTION_DISABLED 0
183#if defined(__ARM_ARCH_6M__)
185#define DWT_FUNCTIONx_FUNCTION_PCWATCH 4
186#define DWT_FUNCTIONx_FUNCTION_DWATCH_R 5
187#define DWT_FUNCTIONx_FUNCTION_DWATCH_W 6
188#define DWT_FUNCTIONx_FUNCTION_DWATCH_RW 7
uint32_t dwt_read_cycle_counter(void)
DebugTrace Read the CPU cycle counter.
bool dwt_enable_cycle_counter(void)
DebugTrace Enable the CPU cycle counter.