AM275 FreeRTOS SDK  11.00.00
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
DebugP.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018-2025 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * 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
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef DEBUGP_H
34 #define DEBUGP_H
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /* ========================================================================== */
41 /* Include Files */
42 /* ========================================================================== */
43 
44 #include <stdint.h>
45 #include <stdbool.h>
46 
47 /* ========================================================================== */
48 /* Macros & Typedefs */
49 /* ========================================================================== */
50 
68 #define DebugP_LOG_ZONE_ALWAYS_ON (0x0001U)
69 
72 #define DebugP_LOG_ZONE_ERROR (0x0002U)
73 
76 #define DebugP_LOG_ZONE_WARN (0x0004U)
77 
80 #define DebugP_LOG_ZONE_INFO (0x0008U)
81 
87 #define DebugP_SHM_LOG_SIZE ((2U*1024U) - 16U)
88 
92 #define DebugP_MEM_LOG_SIZE ( 4*1024U )
93 
94 
101 #define DebugP_SHM_LOG_IS_VALID (0x12345678U)
102 
106 #define UNSIGNED_INTEGERVAL_TWO (2U)
107 
111 #define UNSIGNED_INTEGERVAL_THREE (3U)
112 
116 #define CARRIAGE_RETURN_ASCII (13U)
117 
121 typedef struct {
122 
123  uint32_t isValid;
124  uint32_t rdIndex;
125  uint32_t wrIndex;
126  uint32_t rsv;
127  uint8_t buffer[DebugP_SHM_LOG_SIZE];
128 
129 } DebugP_ShmLog;
130 
136 #ifndef DebugP_ASSERT_ENABLED
137 
142 #define DebugP_ASSERT_ENABLED 1
143 #endif
144 
145 #ifndef DebugP_LOG_ENABLED
146 
151 #define DebugP_LOG_ENABLED 1
152 #endif
153 
156 #if DebugP_ASSERT_ENABLED
157 
160 void _DebugP_assert(int32_t expression, const char *file, const char *function, int32_t line, const char *expressionString);
161 
165 void _DebugP_assertNoLog(int32_t expression);
166 
183 #define DebugP_assert(expression) \
184  do { \
185  _DebugP_assert(expression, \
186  __FILE__, __FUNCTION__, __LINE__, #expression); \
187  } while((bool)0)
188 
199 #define DebugP_assertNoLog(expression) (_DebugP_assertNoLog(expression))
200 
203 #else
204 #define DebugP_assert(expression)
205 #define DebugP_assertNoLog(expression)
206 #endif
207 
208 #if DebugP_LOG_ENABLED
209 
220 void _DebugP_logZone(uint32_t logZone, char *format, ...);
221 
235 #define DebugP_log(format, ...) \
236  do { \
237  _DebugP_logZone(DebugP_LOG_ZONE_ALWAYS_ON, format, ##__VA_ARGS__); \
238  } while((bool)0)
239 
247 #define DebugP_logError(format, ...) \
248  do { \
249  _DebugP_logZone(DebugP_LOG_ZONE_ERROR, "ERROR: %s:%d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__); \
250  } while((bool)0)
251 
259 #define DebugP_logWarn(format, ...) \
260  do { \
261  _DebugP_logZone(DebugP_LOG_ZONE_WARN, "WARNING: %s:%d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__); \
262  } while((bool)0)
263 
271 #define DebugP_logInfo(format, ...) \
272  do { \
273  _DebugP_logZone(DebugP_LOG_ZONE_INFO, "INFO: %s:%d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__); \
274  } while((bool)0)
275 
278 #else
279 #define DebugP_log(format, ...)
280 #define DebugP_logError(format, ...)
281 #define DebugP_logWarn(format, ...)
282 #define DebugP_logInfo(format, ...)
283 #endif
284 
285 /* ========================================================================== */
286 /* Function Declarations */
287 /* ========================================================================== */
288 
296 uint32_t DebugP_logZoneEnable(uint32_t logZoneMask);
297 
305 uint32_t DebugP_logZoneDisable(uint32_t logZoneMask);
306 
312 void DebugP_logZoneRestore(uint32_t logZoneMask);
313 
321 void DebugP_shmLogWriterInit(DebugP_ShmLog *shmLog, uint16_t selfCoreId);
322 
328 
334 
346 void DebugP_shmLogWriterPutChar(char character);
347 
348 
357 void DebugP_uartLogWriterPutChar(char character);
358 
367 void DebugP_shmLogReaderInit(DebugP_ShmLog *shmLog, uint16_t numCores);
368 
375 void DebugP_shmLogRead(void);
376 
387 void DebugP_memLogWriterInit(uint16_t selfCoreId);
388 
394 
400 
414 void DebugP_memLogWriterPutChar(char character);
415 
424 void DebugP_uartSetDrvIndex(uint32_t uartDrvIndex);
425 
437 int32_t DebugP_scanf(char *format, ...);
438 
455 int32_t DebugP_readLine(char *lineBuf, uint32_t bufSize);
456 
459 #ifdef __cplusplus
460 }
461 #endif
462 
463 #endif /* DEBUGP_H */
DebugP_ShmLog::wrIndex
uint32_t wrIndex
Definition: DebugP.h:125
_DebugP_assertNoLog
void _DebugP_assertNoLog(int32_t expression)
Actual function that is called for assert's by DebugP_assertNoLog.
DebugP_shmLogWriterPutChar
void DebugP_shmLogWriterPutChar(char character)
Write a character to shared memory log.
DebugP_logZoneDisable
uint32_t DebugP_logZoneDisable(uint32_t logZoneMask)
Disable log zones.
DebugP_shmLogWriterResume
void DebugP_shmLogWriterResume(void)
Resumes shared memory log writer for this core.
DebugP_logZoneEnable
uint32_t DebugP_logZoneEnable(uint32_t logZoneMask)
Enable log zones.
DebugP_memLogWriterInit
void DebugP_memLogWriterInit(uint16_t selfCoreId)
Initialize log write to write to memory trace buffer.
DebugP_shmLogWriterInit
void DebugP_shmLogWriterInit(DebugP_ShmLog *shmLog, uint16_t selfCoreId)
Initialize shared memory log writer for this core.
DebugP_memLogWriterPause
void DebugP_memLogWriterPause(void)
Pauses memory trace log for this core.
DebugP_shmLogReaderInit
void DebugP_shmLogReaderInit(DebugP_ShmLog *shmLog, uint16_t numCores)
Initialize log reader to read from shared memory and log to console via DebugP_log.
DebugP_ShmLog::isValid
uint32_t isValid
Definition: DebugP.h:123
_DebugP_assert
void _DebugP_assert(int32_t expression, const char *file, const char *function, int32_t line, const char *expressionString)
Actual function that is called for assert's by DebugP_assert.
DebugP_scanf
int32_t DebugP_scanf(char *format,...)
Read a formatted string from the selected UART driver.
DebugP_ShmLog::rsv
uint32_t rsv
Definition: DebugP.h:126
DebugP_readLine
int32_t DebugP_readLine(char *lineBuf, uint32_t bufSize)
Read a string from the selected UART driver.
_DebugP_logZone
void _DebugP_logZone(uint32_t logZone, char *format,...)
Function to log a string to the enabled console for a given zone.
DebugP_memLogWriterPutChar
void DebugP_memLogWriterPutChar(char character)
Write a character to trace buffer.
DebugP_uartSetDrvIndex
void DebugP_uartSetDrvIndex(uint32_t uartDrvIndex)
Set UART driver index to use for character read and write form UART.
DebugP_uartLogWriterPutChar
void DebugP_uartLogWriterPutChar(char character)
Write a character to UART terminal.
DebugP_shmLogRead
void DebugP_shmLogRead(void)
Reads logs from shared memory.
DebugP_logZoneRestore
void DebugP_logZoneRestore(uint32_t logZoneMask)
Restire zone mask returned from DebugP_logZoneDisable or DebugP_logZoneEnable.
DebugP_ShmLog::rdIndex
uint32_t rdIndex
Definition: DebugP.h:124
DebugP_shmLogWriterPause
void DebugP_shmLogWriterPause(void)
Pauses shared memory log writer for this core.
DebugP_ShmLog
Data structure describing log in shared memory.
Definition: DebugP.h:121
DebugP_SHM_LOG_SIZE
#define DebugP_SHM_LOG_SIZE
size of shared memory log for a CPU
Definition: DebugP.h:87
DebugP_memLogWriterResume
void DebugP_memLogWriterResume(void)
Resumes memory trace log for this core.