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