1 /* USER CODE BEGIN Header */
2 /**
3   ******************************************************************************
4   * @file    log_module.h
5   * @author  MCD Application Team
6   * @brief   Header file of the log module.
7   ******************************************************************************
8   * @attention
9   *
10   * Copyright (c) 2024 STMicroelectronics.
11   * All rights reserved.
12   *
13   * This software is licensed under terms that can be found in the LICENSE file
14   * in the root directory of this software component.
15   * If no LICENSE file comes with this software, it is provided AS-IS.
16   *
17   ******************************************************************************
18   */
19 /* USER CODE END Header */
20 
21 /* Define to prevent recursive inclusion -------------------------------------*/
22 #ifndef LOG_MODULE_CONF_H
23 #define LOG_MODULE_CONF_H
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 /* Includes ------------------------------------------------------------------*/
30 #include "app_conf.h"
31 
32 /* Private includes ----------------------------------------------------------*/
33 /* USER CODE BEGIN Includes */
34 
35 /* USER CODE END Includes */
36 
37 /* Module configuration ------------------------------------------------------*/
38 /**
39  * @brief  When this define is set to 0, there is no time stamp added to the trace data.
40  *         When this define is set to 1, the time stamp is added to the trace data,
41  *         according to the function registered with Log_Module_RegisterTimeStampFunction.
42  */
43 #define LOG_INSERT_TIME_STAMP_INSIDE_THE_TRACE    CFG_LOG_INSERT_TIME_STAMP_INSIDE_THE_TRACE
44 
45 /**
46  * @brief  When this define is set to 0, the color of the trace data remains the same for all regions.
47  *         When this define is set to 1, the color added to the trace data is based on LOG_COLOR_DEFAULT_CONFIGURATION.
48  */
49 #define LOG_INSERT_COLOR_INSIDE_THE_TRACE         CFG_LOG_INSERT_COLOR_INSIDE_THE_TRACE
50 
51 /**
52  * @brief  When this define is set to 0, the trace data is not modified.
53  *         When this define is set to 1, if there is no ENDOFLINE_CHAR as last
54  *         character in the trace data, then one is added.
55  */
56 #define LOG_INSERT_EOL_INSIDE_THE_TRACE           CFG_LOG_INSERT_EOL_INSIDE_THE_TRACE
57 
58 /* USER CODE BEGIN Module configuration */
59 
60 /* USER CODE END Module configuration */
61 
62 /* Private defines -----------------------------------------------------------*/
63 /* These defines are related to the UTIL_ADV_TRACE. Do not modify them please. */
64 #define LOG_MODULE_MIN_VERBOSE_LEVEL    (0)
65 #define LOG_MODULE_MAX_VERBOSE_LEVEL    (0xFFFFFFFF)
66 #define LOG_MODULE_MIN_REGION_VALUE     (0)
67 #define LOG_MODULE_ALL_REGION_MASK      (0xFFFFFFFF)
68 
69 /* USER CODE BEGIN PD */
70 
71 /* USER CODE END PD */
72 
73 /* Exported types ------------------------------------------------------------*/
74 /* Log module types */
75 /**
76  * @brief  Customizable enum describing the verbose levels used by the log module.
77  *         The levels include the lower levels in the logs.
78  *
79  *         E.g. LOG_VERBOSE_ERROR means LOG_VERBOSE_ERROR logs will be printed,
80  *         as well as LOG_VERBOSE_INFO, but not the others with higher values.
81  *
82  *         The min and max ranges are defined by LOG_MODULE_MIN_VERBOSE_LEVEL
83  *         and LOG_MODULE_MAX_VERBOSE_LEVEL.
84  *
85  *         The user can add its own levels but must NOT add a value to the said
86  *         levels. Verbose levels are handled by the UTIL_ADV_TRACE.
87  */
88 typedef enum
89 {
90   LOG_VERBOSE_INFO = LOG_MODULE_MIN_VERBOSE_LEVEL,
91   /* USER CODE BEGIN Log_Verbose_Level_t_0 */
92 
93   /* USER CODE END Log_Verbose_Level_t_0 */
94   LOG_VERBOSE_ERROR,
95   /* USER CODE BEGIN Log_Verbose_Level_t_1 */
96 
97   /* USER CODE END Log_Verbose_Level_t_1 */
98   LOG_VERBOSE_WARNING,
99   /* USER CODE BEGIN Log_Verbose_Level_t_2 */
100 
101   /* USER CODE END Log_Verbose_Level_t_2 */
102   LOG_VERBOSE_DEBUG,
103   /* USER CODE BEGIN Log_Verbose_Level_t_3 */
104 
105   /* USER CODE END Log_Verbose_Level_t_3 */
106   LOG_VERBOSE_ALL_LOGS = LOG_MODULE_MAX_VERBOSE_LEVEL,
107 } Log_Verbose_Level_t;
108 
109 /**
110  * @brief  Customizable enum describing the regions used by the log module.
111  *         Regions are used to separate the logs into different places.
112  *
113  *         Let's say you have a Task 1 and a Task 2.
114  *         Both of them have Info and Debug logs.
115  *
116  *         By using them as such, i.e. with the same regions, you'll
117  *         print the logs of the 2 tasks as long as the verbose is Info or Debug.
118  *
119  *         If you create a region for Task 1 and another for Task 2, you can
120  *         split the logs between them, and, if needed, only print the Debug
121  *         logs for Task 1 only (i.e. Task 1 logs for Info and Debug).
122  *
123  *         Behind the scenes is a mask into which each region is a bit.
124  *         The user can add its own regions but must NOT add a value to them.
125  *         The log module handles the mask on its own.
126  */
127 typedef enum
128 {
129   LOG_REGION_BLE = LOG_MODULE_MIN_REGION_VALUE,
130   LOG_REGION_SYSTEM,
131   LOG_REGION_APP,
132   LOG_REGION_LINKLAYER,
133   LOG_REGION_MAC,
134   LOG_REGION_ZIGBEE,
135   LOG_REGION_THREAD,
136   LOG_REGION_RTOS,
137   /* USER CODE BEGIN Log_Region_t */
138 
139   /* USER CODE END Log_Region_t */
140   LOG_REGION_ALL_REGIONS = LOG_MODULE_ALL_REGION_MASK,
141 } Log_Region_t;
142 
143 typedef enum
144 {
145   LOG_COLOR_NONE          = 0,     /* Initialization */
146   LOG_COLOR_CODE_DEFAULT  = 37,    /* White */
147   LOG_COLOR_CODE_RED      = 91,
148   LOG_COLOR_CODE_GREEN    = 92,
149   LOG_COLOR_CODE_YELLOW   = 93,
150   LOG_COLOR_CODE_CYAN     = 96,
151   /* USER CODE BEGIN Log_Color_t */
152 
153   /* USER CODE END Log_Color_t */
154 } Log_Color_t;
155 
156 /* USER CODE BEGIN ET */
157 
158 /* USER CODE END ET */
159 
160 /* Exported macro ------------------------------------------------------------*/
161 /* Display 64 bits number for all compiler. */
162 /* Example : LOG_INFO_APP( "New Device : " LOG_DISPLAY64() " installed in %d seconds", LOG_NUMBER64( dlDevice ), iTime ); */
163 #define LOG_DISPLAY64()             "0x%08X%08X"
164 #define LOG_NUMBER64( number )      (uint32_t)( number >> 32u ), (uint32_t)( number )
165 
166 /* Module API - Log macros for each region */
167 /* LOG_REGION_BLE */
168 #if (CFG_LOG_SUPPORTED != 0)
169 #define LOG_INFO_BLE(...)         Log_Module_Print( LOG_VERBOSE_INFO, LOG_REGION_BLE, __VA_ARGS__)
170 #define LOG_ERROR_BLE(...)        Log_Module_Print( LOG_VERBOSE_ERROR, LOG_REGION_BLE, __VA_ARGS__)
171 #define LOG_WARNING_BLE(...)      Log_Module_Print( LOG_VERBOSE_WARNING, LOG_REGION_BLE, __VA_ARGS__)
172 #define LOG_DEBUG_BLE(...)        Log_Module_Print( LOG_VERBOSE_DEBUG, LOG_REGION_BLE, __VA_ARGS__)
173 #else /* (CFG_LOG_SUPPORTED != 0) */
174 #define LOG_INFO_BLE(...)         do {} while(0)
175 #define LOG_ERROR_BLE(...)        do {} while(0)
176 #define LOG_WARNING_BLE(...)      do {} while(0)
177 #define LOG_DEBUG_BLE(...)        do {} while(0)
178 #endif /* (CFG_LOG_SUPPORTED != 0) */
179 
180 /* USER CODE BEGIN LOG_REGION_BLE */
181 /**
182  * Add inside this user section your defines to match the new verbose levels you
183  * created into Log_Verbose_Level_t.
184  * Example :
185  * #define LOG_CUSTOM_BLE(...)      Log_Module_Print( LOG_VERBOSE_CUSTOM, LOG_REGION_BLE, __VA_ARGS__);
186  *
187  * You don't need to update all regions with your custom values.
188  * Do it accordingly to your needs. E.g you might not need LOG_VERBOSE_CUSTOM for a System region.
189  */
190 
191 /* USER CODE END LOG_REGION_BLE */
192 
193 /* LOG_REGION_SYSTEM */
194 #if (CFG_LOG_SUPPORTED != 0)
195 #define LOG_INFO_SYSTEM(...)      Log_Module_Print( LOG_VERBOSE_INFO, LOG_REGION_SYSTEM, __VA_ARGS__)
196 #define LOG_ERROR_SYSTEM(...)     Log_Module_Print( LOG_VERBOSE_ERROR, LOG_REGION_SYSTEM, __VA_ARGS__)
197 #define LOG_WARNING_SYSTEM(...)   Log_Module_Print( LOG_VERBOSE_WARNING, LOG_REGION_SYSTEM, __VA_ARGS__)
198 #define LOG_DEBUG_SYSTEM(...)     Log_Module_Print( LOG_VERBOSE_DEBUG, LOG_REGION_SYSTEM, __VA_ARGS__)
199 #else /* (CFG_LOG_SUPPORTED != 0) */
200 #define LOG_INFO_SYSTEM(...)      do {} while(0)
201 #define LOG_ERROR_SYSTEM(...)     do {} while(0)
202 #define LOG_WARNING_SYSTEM(...)   do {} while(0)
203 #define LOG_DEBUG_SYSTEM(...)     do {} while(0)
204 #endif /* (CFG_LOG_SUPPORTED != 0) */
205 
206 /* USER CODE BEGIN LOG_REGION_SYSTEM */
207 /**
208  * Add inside this user section your defines to match the new verbose levels you
209  * created into Log_Verbose_Level_t.
210  * Example :
211  * #define LOG_CUSTOM_SYSTEM(...)      Log_Module_Print( LOG_VERBOSE_CUSTOM, LOG_REGION_SYSTEM, __VA_ARGS__);
212  *
213  * You don't need to update all regions with your custom values.
214  * Do it accordingly to your needs. E.g you might not need LOG_VERBOSE_CUSTOM for a System region.
215  */
216 
217 /* USER CODE END LOG_REGION_SYSTEM */
218 
219 /* LOG_REGION_APP */
220 #if (CFG_LOG_SUPPORTED != 0)
221 #define LOG_INFO_APP(...)         Log_Module_Print( LOG_VERBOSE_INFO, LOG_REGION_APP, __VA_ARGS__)
222 #define LOG_ERROR_APP(...)        Log_Module_Print( LOG_VERBOSE_ERROR, LOG_REGION_APP, __VA_ARGS__)
223 #define LOG_WARNING_APP(...)      Log_Module_Print( LOG_VERBOSE_WARNING, LOG_REGION_APP, __VA_ARGS__)
224 #define LOG_DEBUG_APP(...)        Log_Module_Print( LOG_VERBOSE_DEBUG, LOG_REGION_APP, __VA_ARGS__)
225 #else /* (CFG_LOG_SUPPORTED != 0) */
226 #define LOG_INFO_APP(...)         do {} while(0)
227 #define LOG_ERROR_APP(...)        do {} while(0)
228 #define LOG_WARNING_APP(...)      do {} while(0)
229 #define LOG_DEBUG_APP(...)        do {} while(0)
230 #endif /* (CFG_LOG_SUPPORTED != 0) */
231 
232 /* USER CODE BEGIN LOG_REGION_APP */
233 /**
234  * Add inside this user section your defines to match the new verbose levels you
235  * created into Log_Verbose_Level_t.
236  * Example :
237  * #define LOG_CUSTOM_APP(...)         Log_Module_Print( LOG_VERBOSE_CUSTOM, LOG_REGION_APP, __VA_ARGS__);
238  *
239  * You don't need to update all regions with your custom values.
240  * Do it accordingly to your needs. E.g you might not need LOG_VERBOSE_CUSTOM for a System region.
241  */
242 
243 /* USER CODE END LOG_REGION_APP */
244 
245 /* LOG_REGION_LINKLAYER */
246 #if (CFG_LOG_SUPPORTED != 0)
247 #define LOG_INFO_LINKLAYER(...)   Log_Module_Print( LOG_VERBOSE_INFO, LOG_REGION_LINKLAYER, __VA_ARGS__)
248 #define LOG_ERROR_LINKLAYER(...)  Log_Module_Print( LOG_VERBOSE_ERROR, LOG_REGION_LINKLAYER, __VA_ARGS__)
249 #define LOG_WARNING_LINKLAYER(...)Log_Module_Print( LOG_VERBOSE_WARNING, LOG_REGION_LINKLAYER, __VA_ARGS__)
250 #define LOG_DEBUG_LINKLAYER(...)  Log_Module_Print( LOG_VERBOSE_DEBUG, LOG_REGION_LINKLAYER, __VA_ARGS__)
251 #else /* (CFG_LOG_SUPPORTED != 0) */
252 #define LOG_INFO_LINKLAYER(...)   do {} while(0)
253 #define LOG_ERROR_LINKLAYER(...)  do {} while(0)
254 #define LOG_WARNING_LINKLAYER(...)do {} while(0)
255 #define LOG_DEBUG_LINKLAYER(...)  do {} while(0)
256 #endif /* (CFG_LOG_SUPPORTED != 0) */
257 
258 /* USER CODE BEGIN LOG_REGION_LINKLAYER */
259 /**
260  * Add inside this user section your defines to match the new verbose levels you
261  * created into Log_Verbose_Level_t.
262  * Example :
263  * #define LOG_CUSTOM_LINKLAYER(...)         Log_Module_Print( LOG_VERBOSE_CUSTOM, LOG_REGION_LINKLAYER, __VA_ARGS__);
264  *
265  * You don't need to update all regions with your custom values.
266  * Do it accordingly to your needs. E.g you might not need LOG_VERBOSE_CUSTOM for a System region.
267  */
268 
269 /* USER CODE END LOG_REGION_LINKLAYER */
270 
271 /* USER CODE BEGIN APP_LOG_USER_DEFINES */
272 /**
273  * Add inside this user section your defines to match the new regions you
274  * created into Log_Region_t.
275  * Example :
276 #if (CFG_LOG_SUPPORTED != 0)
277 #define LOG_INFO_CUSTOM(...)      Log_Module_Print( LOG_VERBOSE_INFO, LOG_REGION_CUSTOM, __VA_ARGS__)
278 #define LOG_ERROR_CUSTOM(...)     Log_Module_Print( LOG_VERBOSE_ERROR, LOG_REGION_CUSTOM, __VA_ARGS__)
279 #define LOG_WARNING_CUSTOM(...)   Log_Module_Print( LOG_VERBOSE_WARNING, LOG_REGION_CUSTOM, __VA_ARGS__)
280 #define LOG_DEBUG_CUSTOM(...)     Log_Module_Print( LOG_VERBOSE_DEBUG, LOG_REGION_CUSTOM, __VA_ARGS__)
281 #else
282 #define LOG_INFO_CUSTOM(...)      do {} while(0)
283 #define LOG_ERROR_CUSTOM(...)     do {} while(0)
284 #define LOG_WARNING_CUSTOM(...)   do {} while(0)
285 #define LOG_DEBUG_CUSTOM(...)     do {} while(0)
286 #endif
287  */
288 /* USER CODE END APP_LOG_USER_DEFINES */
289 
290 #ifdef __cplusplus
291 }
292 #endif
293 
294 #endif /* LOG_MODULE_CONF_H */
295