LogSinkITM.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020-2023 Texas Instruments Incorporated - https://www.ti.com
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 /*!*****************************************************************************
34  * @file LogSinkITM.h
35  * @brief <b>PRELIMINARY</b> LogSinkITM interface
36  *
37  * <b>WARNING</b> These APIs are <b>PRELIMINARY</b>, and subject to
38  * change in the next few months.
39  *
40  * The LogSinkITM module is a sink that can be used in conjunction with the
41  * Log.h API. The API defined in this file should not be used directly, but
42  * is made available to the Logging framework and used as a transport layer
43  * for Log.h
44  *
45  * To use the ITM sink, ensure that the correct library for your
46  * device is linked in and include this header file as follows:
47  * @code
48  * #include <ti/log/LogSinkITM.h>
49  * @endcode
50  *
51  * Additionally, LogSinkITM_init must be called before LogSinkITM can be used.
52  * @code
53  * // Initialize ITM sink
54  * LogSinkITM_init();
55  * @endcode
56  *
57  * This module implements two functions that are required by the Log API:
58  * - printf(const Log_Module *handle, uint32_t header, uint32_t index, uint32_t numArgs, ...);
59  * - buf(const Log_Module *handle, uint32_t header, uint32_t index, uint8_t *data, size_t size);
60  *
61  * Whenever a log-statement is invoked, that uses LogSinkITM as its sink, the functions above are ultimately invoked.
62  *
63  * @anchor ti_log_LogSinkITM_Overview
64  * # Overview
65  * LogSinkITM is a sink/transport layer that is able to output log-statements over ITM.
66  * It uses the ITM driver to stream data out onto a user-selectable pin, which can be received and processed
67  * by a host-side tool. For more information about the host-side tool, see tools/log/tiutils.
68  * For more information about the Log API, see the @ref log "Log documentation"
69  *
70  * @anchor ti_log_LogSinkITM_Channels
71  * # ITM Channels
72  * LogSinkITM uses certain channels for different purposes. Seperate channels are used for data transfer,
73  * time synchronization, etc. For a complete overview, refer to LogSinkITM_StimulusPorts
74  *
75  * @anchor ti_log_LogSinkITM_Timestamps
76  * # ITM Timestamps
77  * Timestamps are automatically generated by the ITM hardware, and a synchronization timestamp is sent
78  * over the time-sync channel when the ITM sink is initiated. The timestamp is taken from the RTC, but the format
79  * depends on the device. Refer to TimestampP.h for implementation details
80  *
81  * ============================================================================
82  */
83 
84 #ifndef ti_log_LogSinkITM__include
85 #define ti_log_LogSinkITM__include
86 
87 #include <stdint.h>
88 #include <ti/log/Log.h>
89 
90 #if defined(__cplusplus)
91 extern "C" {
92 #endif
93 
94 #define Log_TI_LOG_SINK_ITM_VERSION 0.1.0
95 
96 /*
97  * ======== LogSinkITM_StimulusPorts ========
98  */
99 typedef enum
100 {
117 
118  /* Ports 16-31 reserved for LogSinkITM and dependents */
136 
137 /*
138  * ======== LogSinkITM_ControlWord ========
139  */
141 {
144 
145 /*
146  * ======== LogSinkITM_Instance ========
147  */
148 typedef struct LogSinkITM_Instance
149 {
150  uint32_t serial;
152 
153 /*
154  * ======== LogSinkITM_Handle ========
155  */
157 
158 /*
159  * ======== LogSinkITM_init ========
160  */
161 extern void LogSinkITM_init(void);
162 
163 /*
164  * ======== LogSinkITM_finalize ========
165  */
166 extern void LogSinkITM_finalize(void);
167 
168 /*
169  * ======== LogSinkITM_printf ========
170  */
171 extern void ti_log_LogSinkITM_printf(const Log_Module *handle, uint32_t header, uint32_t index, uint32_t numArgs, ...);
172 
173 /*
174  * ======== LogSinkITM_buf ========
175  */
176 extern void ti_log_LogSinkITM_buf(const Log_Module *handle,
177  uint32_t header,
178  uint32_t index,
179  uint8_t *data,
180  size_t size);
181 
182 /*
183  * Helpers to define/use instance. ITM is a singleton so no arguments are taken.
184  */
185 #define Log_SINK_ITM_DEFINE() LogSinkITM_Instance LogSinkITM_singletonConfig = {.serial = 0}
186 #define Log_SINK_ITM_USE() extern LogSinkITM_Instance LogSinkITM_singletonConfig
187 #define Log_MODULE_INIT_SINK_ITM(name, _levels) \
188  { \
189  .sinkConfig = &LogSinkITM_singletonConfig, .printf = ti_log_LogSinkITM_printf, .buf = ti_log_LogSinkITM_buf, \
190  .levels = _levels, \
191  }
192 
194 
195 #if defined(__cplusplus)
196 }
197 #endif
198 
199 #endif /* ti_log_LogSinkITM__include */
Port 9. Reserved for future use.
Definition: LogSinkITM.h:110
_Log_DEFINE_LOG_VERSION(LogSinkITM, 0.1.0)
Port 20. Reserved for raw ITM data.
Definition: LogSinkITM.h:123
Port 3. Reserved for future use.
Definition: LogSinkITM.h:104
Definition: LogSinkITM.h:148
Port 31. Reserved for logger control/info packets.
Definition: LogSinkITM.h:134
LogSinkITM_Instance * LogSinkITM_Handle
Definition: LogSinkITM.h:156
void ti_log_LogSinkITM_printf(const Log_Module *handle, uint32_t header, uint32_t index, uint32_t numArgs,...)
Port 1. Reserved for future use.
Definition: LogSinkITM.h:102
Port 2. Reserved for future use.
Definition: LogSinkITM.h:103
Port 29. Reserved for logger header messages.
Definition: LogSinkITM.h:132
void ti_log_LogSinkITM_buf(const Log_Module *handle, uint32_t header, uint32_t index, uint8_t *data, size_t size)
Port 5. Reserved for future use.
Definition: LogSinkITM.h:106
Port 12. Used to notify logger states.
Definition: LogSinkITM.h:113
void LogSinkITM_finalize(void)
Port 22. Reserved for raw ITM data.
Definition: LogSinkITM.h:125
Port 0. Reserved for future use.
Definition: LogSinkITM.h:101
Port 7. Reserved for future use.
Definition: LogSinkITM.h:108
LogSinkITM_StimulusPorts
Definition: LogSinkITM.h:99
Port 14. Reserved for logger header messages.
Definition: LogSinkITM.h:115
Port 6. Reserved for future use.
Definition: LogSinkITM.h:107
struct LogSinkITM_Instance LogSinkITM_Instance
Port 8. Reserved for future use.
Definition: LogSinkITM.h:109
Port 26. Reserved for raw ITM data.
Definition: LogSinkITM.h:129
Port 16. Reserved for raw ITM data.
Definition: LogSinkITM.h:119
Port 27. Reserved for raw ITM data.
Definition: LogSinkITM.h:130
void LogSinkITM_init(void)
Port 13. Reserved for future use.
Definition: LogSinkITM.h:114
#define Log_TI_LOG_SINK_ITM_VERSION
Definition: LogSinkITM.h:94
Port 10. Reserved for future use.
Definition: LogSinkITM.h:111
Port 17. Reserved for raw ITM data.
Definition: LogSinkITM.h:120
uint32_t serial
Definition: LogSinkITM.h:150
Port 15. Reserved for logger main data transfer.
Definition: LogSinkITM.h:116
Port 4. Reserved for future use.
Definition: LogSinkITM.h:105
Port 11. Reserved for logger time sync.
Definition: LogSinkITM.h:112
LogSinkITM_ControlWord
Definition: LogSinkITM.h:140
Port 25. Reserved for raw ITM data.
Definition: LogSinkITM.h:128
Port 18. Reserved for raw ITM data.
Definition: LogSinkITM.h:121
Port 30. Reserved for logger time sync.
Definition: LogSinkITM.h:133
Port 24. Reserved for raw ITM data.
Definition: LogSinkITM.h:127
Definition: LogSinkITM.h:142
Port 21. Reserved for raw ITM data.
Definition: LogSinkITM.h:124
Port 19. Reserved for raw ITM data.
Definition: LogSinkITM.h:122
Port 23. Reserved for raw ITM data.
Definition: LogSinkITM.h:126
Port 28. Reserved for logger main data transfer.
Definition: LogSinkITM.h:131
© Copyright 1995-2023, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale