]> git.sur5r.net Git - openocd/blob - src/target/armv7m_trace.h
eae72f5570cc12500f736574fcd0b3a1cae7ffbe
[openocd] / src / target / armv7m_trace.h
1 /***************************************************************************
2  *   Copyright (C) 2015  Paul Fertser <fercerpav@gmail.com>                *
3  *                                                                         *
4  *   This program is free software; you can redistribute it and/or modify  *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                   *
8  *                                                                         *
9  *   This program is distributed in the hope that it will be useful,       *
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12  *   GNU General Public License for more details.                          *
13  ***************************************************************************/
14
15 #ifndef ARMV7M_TRACE_H
16 #define ARMV7M_TRACE_H
17
18 #include <target/target.h>
19 #include <command.h>
20
21 /**
22  * @file
23  * Holds the interface to TPIU, ITM and DWT configuration functions.
24  */
25
26 enum trace_config_type {
27         DISABLED,       /**< tracing is disabled */
28         EXTERNAL,       /**< trace output is captured externally */
29         INTERNAL        /**< trace output is handled by OpenOCD adapter driver */
30 };
31
32 enum tpio_pin_protocol {
33         SYNC,                   /**< synchronous trace output */
34         ASYNC_MANCHESTER,       /**< asynchronous output with Manchester coding */
35         ASYNC_UART              /**< asynchronous output with NRZ coding */
36 };
37
38 enum itm_ts_prescaler {
39         ITM_TS_PRESCALE1,       /**< no prescaling for the timestamp counter */
40         ITM_TS_PRESCALE4,       /**< refclock divided by 4 for the timestamp counter */
41         ITM_TS_PRESCALE16,      /**< refclock divided by 16 for the timestamp counter */
42         ITM_TS_PRESCALE64,      /**< refclock divided by 64 for the timestamp counter */
43 };
44
45 struct armv7m_trace_config {
46         /** Currently active trace capture mode */
47         enum trace_config_type config_type;
48
49         /** Currently active trace output mode */
50         enum tpio_pin_protocol pin_protocol;
51         /** TPIU formatter enable/disable (in async mode) */
52         bool formatter;
53         /** Synchronous output port width */
54         uint32_t port_size;
55
56         /** Bitmask of currenty enabled ITM stimuli */
57         uint32_t itm_ter[8];
58         /** Identifier for multi-source trace stream formatting */
59         unsigned int trace_bus_id;
60         /** Prescaler for the timestamp counter */
61         enum itm_ts_prescaler itm_ts_prescale;
62         /** Enable differential timestamps */
63         bool itm_diff_timestamps;
64         /** Enable async timestamps model */
65         bool itm_async_timestamps;
66         /** Enable synchronisation packet transmission (for sync port only) */
67         bool itm_synchro_packets;
68
69         /** Current frequency of TRACECLKIN (usually matches HCLK) */
70         unsigned int traceclkin_freq;
71         /** Current frequency of trace port */
72         unsigned int trace_freq;
73         /** Handle to output trace data in INTERNAL capture mode */
74         FILE *trace_file;
75 };
76
77 extern const struct command_registration armv7m_trace_command_handlers[];
78
79 /**
80  * Configure hardware accordingly to the current TPIU target settings
81  */
82 int armv7m_trace_tpiu_config(struct target *target);
83 /**
84  * Configure hardware accordingly to the current ITM target settings
85  */
86 int armv7m_trace_itm_config(struct target *target);
87
88 #endif