1 /** 2 ****************************************************************************** 3 * @file log.h 4 * @author MCD Application Team 5 * @brief logging services 6 ****************************************************************************** 7 * 8 * @attention 9 * 10 * <h2><center>© Copyright (c) 2019 STMicroelectronics. 11 * All rights reserved.</center></h2> 12 * 13 * This software component is licensed by ST under BSD 3-Clause license, 14 * the "License"; You may not use this file except in compliance with the 15 * License. You may obtain a copy of the License at: 16 * opensource.org/licenses/BSD-3-Clause 17 * 18 * 19 ****************************************************************************** 20 */ 21 22 /** @addtogroup LOG 23 * @{ 24 */ 25 26 /** @addtogroup stm32mp1xx_Log 27 * @{ 28 */ 29 30 /** 31 * @brief Define to prevent recursive inclusion 32 */ 33 #ifndef __LOG_STM32MP1XX_H 34 #define __LOG_STM32MP1XX_H 35 36 #ifdef __cplusplus 37 extern "C" { 38 #endif 39 40 /** @addtogroup STM32MP1xx_Log_Includes 41 * @{ 42 */ 43 #include "stm32mp1xx_hal.h" 44 /** 45 * @} 46 */ 47 48 /** @addtogroup STM32MP1xx_Log_Exported_Constants 49 * @{ 50 */ 51 #if defined (__LOG_TRACE_IO_) 52 #define SYSTEM_TRACE_BUF_SZ 2048 53 #endif 54 55 #define LOGQUIET 0 56 #define LOGERR 1 57 #define LOGWARN 2 58 #define LOGINFO 3 59 #define LOGDBG 4 60 61 #ifndef LOGLEVEL 62 #define LOGLEVEL LOGINFO 63 #endif 64 65 /** 66 * @} 67 */ 68 69 /** @addtogroup STM32MP1xx_Log_Exported_types 70 * @{ 71 */ 72 #if defined (__LOG_TRACE_IO_) 73 extern char system_log_buf[SYSTEM_TRACE_BUF_SZ]; /*!< buffer for debug traces */ 74 #endif /* __LOG_TRACE_IO_ */ 75 /** 76 * @} 77 */ 78 79 /** @addtogroup STM32MP1xx_Log_Exported_Macros 80 * @{ 81 */ 82 #if defined (__LOG_TRACE_IO_) || defined(__LOG_UART_IO_) 83 #if LOGLEVEL >= LOGDBG 84 #define log_dbg(fmt, ...) printf("[%05ld.%03ld][DBG ]" fmt, HAL_GetTick()/1000, HAL_GetTick() % 1000, ##__VA_ARGS__) 85 #else 86 #define log_dbg(fmt, ...) 87 #endif 88 #if LOGLEVEL >= LOGINFO 89 #define log_info(fmt, ...) printf("[%05ld.%03ld][INFO ]" fmt, HAL_GetTick()/1000, HAL_GetTick() % 1000, ##__VA_ARGS__) 90 #else 91 #define log_info(fmt, ...) 92 #endif 93 #if LOGLEVEL >= LOGWARN 94 #define log_warn(fmt, ...) printf("[%05ld.%03ld][WARN ]" fmt, HAL_GetTick()/1000, HAL_GetTick() % 1000, ##__VA_ARGS__) 95 #else 96 #define log_warn(fmt, ...) 97 #endif 98 #if LOGLEVEL >= LOGERR 99 #define log_err(fmt, ...) printf("[%05ld.%03ld][ERR ]" fmt, HAL_GetTick()/1000, HAL_GetTick() % 1000, ##__VA_ARGS__) 100 #else 101 #define log_err(fmt, ...) 102 #endif 103 #else 104 #define log_dbg(fmt, ...) 105 #define log_info(fmt, ...) 106 #define log_warn(fmt, ...) 107 #define log_err(fmt, ...) 108 #endif /* __LOG_TRACE_IO_ */ 109 /** 110 * @} 111 */ 112 113 /** @addtogroup STM32MP1xx_Log_Exported_Functions 114 * @{ 115 */ 116 117 /** 118 * @} 119 */ 120 121 #ifdef __cplusplus 122 } 123 #endif 124 125 #endif /*__LOG_STM32MP1XX_H */ 126 127 /** 128 * @} 129 */ 130 131 /** 132 * @} 133 */ 134 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 135