1 /** 2 ****************************************************************************** 3 * @file dbg_trace.h 4 * @author MCD Application Team 5 * @brief Header for dbg_trace.c 6 ****************************************************************************** 7 * @attention 8 * 9 * <h2><center>© Copyright (c) 2019 STMicroelectronics. 10 * All rights reserved.</center></h2> 11 * 12 * This software component is licensed by ST under BSD 3-Clause license, 13 * the "License"; You may not use this file except in compliance with the 14 * License. You may obtain a copy of the License at: 15 * opensource.org/licenses/BSD-3-Clause 16 * 17 ****************************************************************************** 18 */ 19 20 21 /* Define to prevent recursive inclusion -------------------------------------*/ 22 #ifndef __DBG_TRACE_H 23 #define __DBG_TRACE_H 24 25 #ifdef __cplusplus 26 extern "C" 27 { 28 #endif 29 30 /* Exported types ------------------------------------------------------------*/ 31 /* External variables --------------------------------------------------------*/ 32 /* Exported macros -----------------------------------------------------------*/ 33 #if ( ( CFG_DEBUG_TRACE_FULL != 0 ) || ( CFG_DEBUG_TRACE_LIGHT != 0 ) ) 34 #define PRINT_LOG_BUFF_DBG(...) DbgTraceBuffer(__VA_ARGS__) 35 #if ( CFG_DEBUG_TRACE_FULL != 0 ) 36 #define PRINT_MESG_DBG(...) do{printf("\r\n [%s][%s][%d] ", DbgTraceGetFileName(__FILE__),__FUNCTION__,__LINE__);printf(__VA_ARGS__);}while(0); 37 #else 38 #define PRINT_MESG_DBG printf 39 #endif 40 #else 41 #define PRINT_LOG_BUFF_DBG(...) 42 #define PRINT_MESG_DBG(...) 43 #endif 44 45 #define PRINT_NO_MESG(...) 46 47 /* Exported functions ------------------------------------------------------- */ 48 49 /** 50 * @brief Request the user to initialize the peripheral to output traces 51 * 52 * @param None 53 * @retval None 54 */ 55 extern void DbgOutputInit( void ); 56 57 /** 58 * @brief Request the user to sent the traces on the output peripheral 59 * 60 * @param p_data: Address of the buffer to be sent 61 * @param size: Size of the data to be sent 62 * @param cb: Function to be called when the data has been sent 63 * @retval None 64 */ 65 extern void DbgOutputTraces( uint8_t *p_data, uint16_t size, void (*cb)(void) ); 66 67 /** 68 * @brief DbgTraceInit Initialize Logging feature. 69 * 70 * @param: None 71 * @retval: None 72 */ 73 void DbgTraceInit( void ); 74 75 /**********************************************************************************************************************/ 76 /** This function outputs into the log the buffer (in hex) and the provided format string and arguments. 77 *********************************************************************************************************************** 78 * 79 * @param pBuffer Buffer to be output into the logs. 80 * @param u32Length Length of the buffer, in bytes. 81 * @param strFormat The format string in printf() style. 82 * @param ... Arguments of the format string. 83 * 84 **********************************************************************************************************************/ 85 void DbgTraceBuffer( const void *pBuffer , uint32_t u32Length , const char *strFormat , ... ); 86 87 const char *DbgTraceGetFileName( const char *fullpath ); 88 89 /** 90 * @brief Override the standard lib function to redirect printf to USART. 91 * @param handle output handle (STDIO, STDERR...) 92 * @param buf buffer to write 93 * @param bufsize buffer size 94 * @retval Number of elements written 95 */ 96 size_t DbgTraceWrite(int handle, const unsigned char * buf, size_t bufSize); 97 98 #ifdef __cplusplus 99 } 100 #endif 101 102 #endif /*__DBG_TRACE_H */ 103 104 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 105