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  * It is called from Board_init().
53  * @code
54  * // Initialize ITM sink
55  * LogSinkITM_init();
56  * @endcode
57  *
58  * This module implements two functions that are required by the Log API:
59  * - printf(const Log_Module *handle, uint32_t header, uint32_t index, uint32_t numArgs, ...);
60  * - buf(const Log_Module *handle, uint32_t header, uint32_t index, uint8_t *data, size_t size);
61  *
62  * Whenever a log-statement is invoked, that uses LogSinkITM as its sink, the functions above are ultimately invoked.
63  *
64  * @anchor ti_log_LogSinkITM_Overview
65  * # Overview
66  * LogSinkITM is a sink/transport layer that is able to output log-statements over ITM.
67  * It uses the ITM driver to stream data out onto a user-selectable pin, which can be received and processed
68  * by a host-side tool. For more information about the host-side tool, see tools/log/tiutils.
69  * For more information about the Log API, see the @ref log "Log documentation"
70  *
71  * @anchor ti_log_LogSinkITM_Channels
72  * # ITM Channels
73  * LogSinkITM uses certain channels for different purposes. Seperate channels are used for data transfer,
74  * time synchronization, etc. For a complete overview, refer to LogSinkITM_StimulusPorts
75  *
76  * @anchor ti_log_LogSinkITM_Timestamps
77  * # ITM Timestamps
78  * Timestamps are automatically generated by the ITM hardware, and a synchronization timestamp is sent
79  * over the time-sync channel when the ITM sink is initiated. The timestamp is taken from the RTC, but the format
80  * depends on the device. Refer to TimestampP.h for implementation details
81  *
82  * ============================================================================
83  */
84 
85 #ifndef ti_log_LogSinkITM__include
86 #define ti_log_LogSinkITM__include
87 
88 #include <stdint.h>
89 #include <ti/log/Log.h>
90 
91 #if defined(__cplusplus)
92 extern "C" {
93 #endif
94 
95 #define Log_TI_LOG_SINK_ITM_VERSION 0.1.0
96 
97 /*
98  * ======== LogSinkITM_StimulusPorts ========
99  */
100 typedef enum
101 {
118 
119  /* Ports 16-31 reserved for LogSinkITM and dependents */
137 
138 /*
139  * ======== LogSinkITM_ControlWord ========
140  */
142 {
145 
146 /*
147  * ======== LogSinkITM_Instance ========
148  */
149 typedef struct LogSinkITM_Instance
150 {
151  uint32_t serial;
153 
154 /*
155  * ======== LogSinkITM_Handle ========
156  */
158 
159 /*
160  * ======== LogSinkITM_init ========
161  */
162 extern void LogSinkITM_init(void);
163 
164 /*
165  * ======== LogSinkITM_finalize ========
166  */
167 extern void LogSinkITM_finalize(void);
168 
169 /*
170  * ======== LogSinkITM_printf ========
171  */
172 extern void ti_log_LogSinkITM_printf(const Log_Module *handle, uint32_t header, uint32_t index, uint32_t numArgs, ...);
173 
174 /*
175  * ======== LogSinkITM_buf ========
176  */
177 extern void ti_log_LogSinkITM_buf(const Log_Module *handle,
178  uint32_t header,
179  uint32_t index,
180  uint8_t *data,
181  size_t size);
182 
183 /*
184  * Helpers to define/use instance. ITM is a singleton so no arguments are taken.
185  */
186 #define Log_SINK_ITM_DEFINE() LogSinkITM_Instance LogSinkITM_singletonConfig = {.serial = 0}
187 #define Log_SINK_ITM_USE() extern LogSinkITM_Instance LogSinkITM_singletonConfig
188 #define Log_MODULE_INIT_SINK_ITM(name, _levels) \
189  { \
190  .sinkConfig = &LogSinkITM_singletonConfig, .printf = ti_log_LogSinkITM_printf, .buf = ti_log_LogSinkITM_buf, \
191  .levels = _levels, \
192  }
193 
195 
196 #if defined(__cplusplus)
197 }
198 #endif
199 
200 #endif /* ti_log_LogSinkITM__include */
Port 9. Reserved for future use.
Definition: LogSinkITM.h:111
_Log_DEFINE_LOG_VERSION(LogSinkITM, 0.1.0)
Port 20. Reserved for raw ITM data.
Definition: LogSinkITM.h:124
Port 3. Reserved for future use.
Definition: LogSinkITM.h:105
Definition: LogSinkITM.h:149
Port 31. Reserved for logger control/info packets.
Definition: LogSinkITM.h:135
LogSinkITM_Instance * LogSinkITM_Handle
Definition: LogSinkITM.h:157
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:103
Port 2. Reserved for future use.
Definition: LogSinkITM.h:104
Port 29. Reserved for logger header messages.
Definition: LogSinkITM.h:133
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:107
Port 12. Used to notify logger states.
Definition: LogSinkITM.h:114
void LogSinkITM_finalize(void)
Port 22. Reserved for raw ITM data.
Definition: LogSinkITM.h:126
Port 0. Reserved for future use.
Definition: LogSinkITM.h:102
Port 7. Reserved for future use.
Definition: LogSinkITM.h:109
LogSinkITM_StimulusPorts
Definition: LogSinkITM.h:100
Port 14. Reserved for logger header messages.
Definition: LogSinkITM.h:116
Port 6. Reserved for future use.
Definition: LogSinkITM.h:108
struct LogSinkITM_Instance LogSinkITM_Instance
Port 8. Reserved for future use.
Definition: LogSinkITM.h:110
Port 26. Reserved for raw ITM data.
Definition: LogSinkITM.h:130
Port 16. Reserved for raw ITM data.
Definition: LogSinkITM.h:120
Port 27. Reserved for raw ITM data.
Definition: LogSinkITM.h:131
void LogSinkITM_init(void)
Port 13. Reserved for future use.
Definition: LogSinkITM.h:115
#define Log_TI_LOG_SINK_ITM_VERSION
Definition: LogSinkITM.h:95
Port 10. Reserved for future use.
Definition: LogSinkITM.h:112
Port 17. Reserved for raw ITM data.
Definition: LogSinkITM.h:121
uint32_t serial
Definition: LogSinkITM.h:151
Port 15. Reserved for logger main data transfer.
Definition: LogSinkITM.h:117
Port 4. Reserved for future use.
Definition: LogSinkITM.h:106
Port 11. Reserved for logger time sync.
Definition: LogSinkITM.h:113
LogSinkITM_ControlWord
Definition: LogSinkITM.h:141
Port 25. Reserved for raw ITM data.
Definition: LogSinkITM.h:129
Port 18. Reserved for raw ITM data.
Definition: LogSinkITM.h:122
Port 30. Reserved for logger time sync.
Definition: LogSinkITM.h:134
Port 24. Reserved for raw ITM data.
Definition: LogSinkITM.h:128
Definition: LogSinkITM.h:143
Port 21. Reserved for raw ITM data.
Definition: LogSinkITM.h:125
Port 19. Reserved for raw ITM data.
Definition: LogSinkITM.h:123
Port 23. Reserved for raw ITM data.
Definition: LogSinkITM.h:127
Port 28. Reserved for logger main data transfer.
Definition: LogSinkITM.h:132
© Copyright 1995-2024, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale