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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
//*****************************************************************************
//
// am_hal_tpiu.h
//! @file
//!
//! @brief Definitions and structures for working with the TPIU.
//!
//! @addtogroup tpiu2 Trace Port Interface Unit (TPIU)
//! @ingroup apollo2hal
//! @{
//
//*****************************************************************************
//*****************************************************************************
//
// Copyright (c) 2017, Ambiq Micro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision 1.2.11 of the AmbiqSuite Development Package.
//
//*****************************************************************************
#ifndef AM_HAL_TPIU_H
#define AM_HAL_TPIU_H
#include <stdint.h>
//*****************************************************************************
//
// TPIU bit rate defines.
//
//*****************************************************************************
#define AM_HAL_TPIU_BAUD_57600 (115200 / 2)
#define AM_HAL_TPIU_BAUD_115200 (115200 * 1)
#define AM_HAL_TPIU_BAUD_230400 (115200 * 2)
#define AM_HAL_TPIU_BAUD_460800 (115200 * 4)
#define AM_HAL_TPIU_BAUD_500000 (1000000 / 2)
#define AM_HAL_TPIU_BAUD_1M (1000000 * 1)
#define AM_HAL_TPIU_BAUD_2M (1000000 * 2)
#define AM_HAL_TPIU_BAUD_DEFAULT (AM_HAL_TPIU_BAUD_1M)
//*****************************************************************************
//
// TPIU register defines.
//
//*****************************************************************************
#define AM_HAL_TPIU_SSPSR 0xE0040000 //! Supported Parallel Port Sizes
#define AM_HAL_TPIU_CSPSR 0xE0040004 //! Current Parallel Port Size
#define AM_HAL_TPIU_ACPR 0xE0040010 //! Asynchronous Clock Prescaler
#define AM_HAL_TPIU_SPPR 0xE00400F0 //! Selected Pin Protocol
#define AM_HAL_TPIU_TYPE 0xE0040FC8 //! TPIU Type
//*****************************************************************************
//
// TPIU ACPR defines.
//
//*****************************************************************************
#define AM_HAL_TPIU_ACPR_SWOSCALER_M 0x0000FFFF //! SWO baud rate prescalar
//*****************************************************************************
//
// TPIU_SPPR TXMODE defines.
//
//*****************************************************************************
#define AM_HAL_TPIU_SPPR_PARALLEL 0x00000000
#define AM_HAL_TPIU_SPPR_MANCHESTER 0x00000001
#define AM_HAL_TPIU_SPPR_NRZ 0x00000002
//*****************************************************************************
//
// TPIU Type defines
//
//*****************************************************************************
#define AM_HAL_TPIU_TYPE_NRZVALID 0x00000800
#define AM_HAL_TPIU_TYPE_MANCVALID 0x00000400
#define AM_HAL_TPIU_TYPE_PTINVALID 0x00000200
#define AM_HAL_TPIU_TYPE_FIFOSZ_M 0x000001C0
//*****************************************************************************
//
// TPIU Clock defines
//
//*****************************************************************************
#define AM_HAL_TPIU_TRACECLKIN_6MHZ AM_REG_MCUCTRL_TPIUCTRL_TPIUCLKSEL(0)
#define AM_HAL_TPIU_TRACECLKIN_3MHZ AM_REG_MCUCTRL_TPIUCTRL_TPIUCLKSEL(1)
#define AM_HAL_TPIU_TRACECLKIN_1_5MHZ AM_REG_MCUCTRL_TPIUCTRL_TPIUCLKSEL(2)
#define AM_HAL_TPIU_TRACECLKIN_750KHZ AM_REG_MCUCTRL_TPIUCTRL_TPIUCLKSEL(3)
//*****************************************************************************
//
//! @brief Structure used for configuring the TPIU
//
//*****************************************************************************
typedef struct
{
//
// If ui32SetItmBaud is non-zero, the ITM frequency is set to the given
// frequency, and is based on a divide-by-8 HFRC TPIU clock.
// If zero, other structure members are used to set the TPIU configuration.
//
uint32_t ui32SetItmBaud;
//
//! MCU Control TRACECLKIN clock freq.
//!
//! Valid values for ui32TraceClkIn are:
//!
//! AM_HAL_TPIU_TRACECLKIN_6MHZ
//! AM_HAL_TPIU_TRACECLKIN_3MHZ
//! AM_HAL_TPIU_TRACECLKIN_1_5MHZ
//! AM_HAL_TPIU_TRACECLKIN_750KHZ
//
uint32_t ui32TraceClkIn;
//
//! Protocol to use for the TPIU
//!
//! Valid values for ui32PinProtocol are:
//!
//! AM_HAL_TPIU_SPPR_PARALLEL
//! AM_HAL_TPIU_SPPR_MANCHESTER
//! AM_HAL_TPIU_SPPR_NRZ
//
uint32_t ui32PinProtocol;
//
//! Desired width of the TPIU parallel port
//
uint32_t ui32ParallelPortSize;
//
//! Desired Clock prescaler value
//
uint32_t ui32ClockPrescaler;
}
am_hal_tpiu_config_t;
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
// External function definitions
//
//*****************************************************************************
extern void am_hal_tpiu_clock_enable(void);
extern void am_hal_tpiu_clock_disable(void);
extern void am_hal_tpiu_port_width_set(uint32_t ui32PortWidth);
extern uint32_t am_hal_tpiu_supported_port_width_get(void);
extern uint32_t am_hal_tpiu_port_width_get(void);
extern void am_hal_tpiu_configure(am_hal_tpiu_config_t *psConfig);
extern void am_hal_tpiu_enable(am_hal_tpiu_config_t *psConfig);
extern void am_hal_tpiu_disable(void);
#ifdef __cplusplus
}
#endif
#endif // AM_HAL_TPIU_H
//*****************************************************************************
//
// End Doxygen group.
//! @}
//
//*****************************************************************************
|