• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Winner Microelectronics Co., Ltd. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @file    wm_debug.h
18  *
19  * @brief   debug Module APIs
20  *
21  * @author  dave
22  *
23  * Copyright (c) 2014 Winner Microelectronics Co., Ltd.
24  */
25 #ifndef WM_DEBUG_H
26 #define WM_DEBUG_H
27 
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include "wm_config.h"
31 #include "wm_osal.h"
32 
33 /* 0x00000000 - 0x80000000 */
34 /** Define the debugging switch: on */
35 #define TLS_DBG_ON                  1
36 /** Define the debugging switch: off */
37 #define TLS_DBG_OFF                 0
38 
39 #define TLS_DBG_SIMPLE              1
40 
41 /* 0x0000000F - 0x00000001 */
42 /** Define the debugging level: info */
43 #define TLS_DBG_LEVEL_INFO          TLS_DBG_OFF
44 /** Define the debugging level: warning */
45 #define TLS_DBG_LEVEL_WARNING       TLS_DBG_OFF
46 /** Define the debugging level: error */
47 #define TLS_DBG_LEVEL_ERR           TLS_DBG_OFF
48 /** Define the debugging level: dump */
49 #define TLS_DBG_LEVEL_DUMP          TLS_DBG_OFF
50 
51 /** general debug info switch, default: off */
52 #define TLS_GENERAL_DBG             TLS_DBG_OFF
53 
54 #if TLS_DBG_SIMPLE
55 #define __TLS_DBGPRT_INFO(fmt, ...)       printf(fmt, ##__VA_ARGS__)
56 #define __TLS_DBGPRT_WARNING(fmt, ...)    printf(fmt, ##__VA_ARGS__)
57 #define __TLS_DBGPRT_ERR(fmt, ...)        printf(fmt, ##__VA_ARGS__)
58 #else
59 #define __TLS_DBGPRT_INFO(fmt, ...)                     \
60 do {                                                         \
61     u32 time = tls_os_get_time();                     \
62     printf("[WM_I] <%d.%02d> %s : "fmt, (time/100), (time%100), __func__, ##__VA_ARGS__); \
63 } while (0)
64 
65 #define __TLS_DBGPRT_WARNING(fmt, ...)                     \
66 do {                                                         \
67     u32 time = tls_os_get_time();                     \
68     printf("[WM_W] <%d.%02d> %s : "fmt, (time/100), (time%100), __func__, ##__VA_ARGS__); \
69 } while (0)
70 
71 #define __TLS_DBGPRT_ERR(fmt, ...)                     \
72 do {                                                         \
73     u32 time = tls_os_get_time();                     \
74     printf("[WM_E] <%d.%02d> %s : "fmt, (time/100), (time%100), __func__, ##__VA_ARGS__); \
75 } while (0)
76 #endif
77 
78 /**
79  * @defgroup System_APIs System APIs
80  * @brief System APIs
81  */
82 
83 /**
84  * @addtogroup System_APIs
85  * @{
86  */
87 
88 /**
89  * @defgroup DEBUG_APIs DEBUG APIs
90  * @brief DEBUG APIs
91  */
92 
93 /**
94  * @addtogroup DEBUG_APIs
95  * @{
96  */
97 
98 #if (TLS_GENERAL_DBG && TLS_DBG_LEVEL_INFO)
99 /** Print information of the info level */
100 #define TLS_DBGPRT_INFO(f, a...)     __TLS_DBGPRT_INFO(f, ##a)
101 #else
102 /** Print information of the info level */
103 #define TLS_DBGPRT_INFO(f, a...)
104 #endif
105 
106 #if (TLS_GENERAL_DBG && TLS_DBG_LEVEL_WARNING)
107 /** Print information of the warning level */
108 #define TLS_DBGPRT_WARNING(f, a...)  __TLS_DBGPRT_WARNING(f, ##a)
109 #else
110 /** Print information of the warning level */
111 #define TLS_DBGPRT_WARNING(f, a...)
112 #endif
113 
114 #if (TLS_GENERAL_DBG && TLS_DBG_LEVEL_ERR)
115 /** Print information of the error level */
116 #define TLS_DBGPRT_ERR(f, a...)      __TLS_DBGPRT_ERR(f, ##a)
117 #else
118 /** Print information of the error level */
119 #define TLS_DBGPRT_ERR(f, a...)
120 #endif
121 
122 #if (TLS_GENERAL_DBG && TLS_DBG_LEVEL_DUMP)
123 /**
124  * @brief          dump memory
125  *
126  * @param[in]      *p     pointer the memory
127  * @param[in]      len    length of memory
128  *
129  * @return         None
130  *
131  * @note           None
132  */
133 void    TLS_DBGPRT_DUMP(char *p, u32 len);
134 #else
135 /** Print information of the dump level */
136 #define TLS_DBGPRT_DUMP(p, len)
137 #endif
138 
139 /**
140  * @}
141  */
142 
143 /**
144  * @}
145  */
146 
147 #endif /* end of WM_DEBUG_H */
148 
149