1 /** 2 * Copyright (c) 2017, Realtek Semiconductor Corporation. All rights reserved. 3 */ 4 5 #ifndef _TRACE_APP_H_ 6 #define _TRACE_APP_H_ 7 8 #include <stdint.h> 9 #include <stdbool.h> 10 11 #ifdef __cplusplus 12 extern "C" { 13 #endif 14 15 #include "trace.h" 16 17 #define LOG_LEVEL_ERROR 0 18 #define LOG_LEVEL_WARN 1 19 #define LOG_LEVEL_INFO 2 20 #define LOG_LEVEL_TRACE 3 21 #define LOG_LEVEL_NUM 4 22 23 #define TRACE_APP_DATA __attribute__((section(".BTTRACE"))) __attribute__((aligned(4))) __attribute__((used)) 24 25 #define COMBINE_TRACE_INFO_APP(type, subtype, module, level) (uint32_t)(((type)<<24) | ((subtype)<<16) | ((module)<<8) | (level)) 26 27 /* Internal macro that is wrapped by internal macro DBG_BUFFER. */ 28 #if 0 29 #define DBG_BUFFER_APP(type, sub_type, module, level, fmt, param_num, ...) do {\ 30 static const char format[] TRACE_APP_DATA = fmt;\ 31 trace_log_buffer(COMBINE_TRACE_INFO_APP(type, sub_type, module, level), (uint32_t)format, param_num, ##__VA_ARGS__);\ 32 } while (0) 33 #else 34 #define DBG_BUFFER_APP 35 #endif 36 37 /** 38 * trace_app.h 39 * 40 * \name APP_PRINT_TRACE 41 * \brief Bluetooth APP Trace Interfaces. 42 * \anchor APP_PRINT_TRACE 43 */ 44 /** 45 * \ingroup TRACE 46 */ 47 /**@{*/ 48 #define APP_PRINT_ERROR0(fmt) \ 49 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_ERROR, "!!!"fmt, 0) 50 #define APP_PRINT_ERROR1(fmt, arg0) \ 51 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_ERROR, "!!!"fmt, 1, arg0) 52 #define APP_PRINT_ERROR2(fmt, arg0, arg1) \ 53 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_ERROR, "!!!"fmt, 2, arg0, arg1) 54 #define APP_PRINT_ERROR3(fmt, arg0, arg1, arg2) \ 55 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_ERROR, "!!!"fmt, 3, arg0, arg1, arg2) 56 #define APP_PRINT_ERROR4(fmt, arg0, arg1, arg2, arg3) \ 57 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_ERROR, "!!!"fmt, 4, arg0, arg1, arg2, arg3) 58 #define APP_PRINT_ERROR5(fmt, arg0, arg1, arg2, arg3, arg4) \ 59 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_ERROR, "!!!"fmt, 5, arg0, arg1, arg2, arg3, arg4) 60 #define APP_PRINT_ERROR6(fmt, arg0, arg1, arg2, arg3, arg4, arg5) \ 61 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_ERROR, "!!!"fmt, 6, arg0, arg1, arg2, arg3, arg4, arg5) 62 #define APP_PRINT_ERROR7(fmt, arg0, arg1, arg2, arg3, arg4, arg5, arg6) \ 63 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_ERROR, "!!!"fmt, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6) 64 #define APP_PRINT_ERROR8(fmt, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ 65 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_ERROR, "!!!"fmt, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) 66 #define APP_PRINT_WARN0(fmt) \ 67 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_WARN, "!!*"fmt, 0) 68 #define APP_PRINT_WARN1(fmt, arg0) \ 69 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_WARN, "!!*"fmt, 1, arg0) 70 #define APP_PRINT_WARN2(fmt, arg0, arg1) \ 71 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_WARN, "!!*"fmt, 2, arg0, arg1) 72 #define APP_PRINT_WARN3(fmt, arg0, arg1, arg2) \ 73 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_WARN, "!!*"fmt, 3, arg0, arg1, arg2) 74 #define APP_PRINT_WARN4(fmt, arg0, arg1, arg2, arg3) \ 75 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_WARN, "!!*"fmt, 4, arg0, arg1, arg2, arg3) 76 #define APP_PRINT_WARN5(fmt, arg0, arg1, arg2, arg3, arg4) \ 77 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_WARN, "!!*"fmt, 5, arg0, arg1, arg2, arg3, arg4) 78 #define APP_PRINT_WARN6(fmt, arg0, arg1, arg2, arg3, arg4, arg5) \ 79 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_WARN, "!!*"fmt, 6, arg0, arg1, arg2, arg3, arg4, arg5) 80 #define APP_PRINT_WARN7(fmt, arg0, arg1, arg2, arg3, arg4, arg5, arg6) \ 81 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_WARN, "!!*"fmt, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6) 82 #define APP_PRINT_WARN8(fmt, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ 83 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_WARN, "!!*"fmt, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) 84 #define APP_PRINT_INFO0(fmt) \ 85 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_INFO, "!**"fmt, 0) 86 #define APP_PRINT_INFO1(fmt, arg0) \ 87 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_INFO, "!**"fmt, 1, arg0) 88 #define APP_PRINT_INFO2(fmt, arg0, arg1) \ 89 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_INFO, "!**"fmt, 2, arg0, arg1) 90 #define APP_PRINT_INFO3(fmt, arg0, arg1, arg2) \ 91 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_INFO, "!**"fmt, 3, arg0, arg1, arg2) 92 #define APP_PRINT_INFO4(fmt, arg0, arg1, arg2, arg3) \ 93 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_INFO, "!**"fmt, 4, arg0, arg1, arg2, arg3) 94 #define APP_PRINT_INFO5(fmt, arg0, arg1, arg2, arg3, arg4) \ 95 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_INFO, "!**"fmt, 5, arg0, arg1, arg2, arg3, arg4) 96 #define APP_PRINT_INFO6(fmt, arg0, arg1, arg2, arg3, arg4, arg5) \ 97 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_INFO, "!**"fmt, 6, arg0, arg1, arg2, arg3, arg4, arg5) 98 #define APP_PRINT_INFO7(fmt, arg0, arg1, arg2, arg3, arg4, arg5, arg6) \ 99 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_INFO, "!**"fmt, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6) 100 #define APP_PRINT_INFO8(fmt, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ 101 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_INFO, "!**"fmt, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) 102 #define APP_PRINT_TRACE0(fmt) \ 103 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_TRACE, fmt, 0) 104 #define APP_PRINT_TRACE1(fmt, arg0) \ 105 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_TRACE, fmt, 1, arg0) 106 #define APP_PRINT_TRACE2(fmt, arg0, arg1) \ 107 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_TRACE, fmt, 2, arg0, arg1) 108 #define APP_PRINT_TRACE3(fmt, arg0, arg1, arg2) \ 109 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_TRACE, fmt, 3, arg0, arg1, arg2) 110 #define APP_PRINT_TRACE4(fmt, arg0, arg1, arg2, arg3) \ 111 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_TRACE, fmt, 4, arg0, arg1, arg2, arg3) 112 #define APP_PRINT_TRACE5(fmt, arg0, arg1, arg2, arg3, arg4) \ 113 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_TRACE, fmt, 5, arg0, arg1, arg2, arg3, arg4) 114 #define APP_PRINT_TRACE6(fmt, arg0, arg1, arg2, arg3, arg4, arg5) \ 115 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_TRACE, fmt, 6, arg0, arg1, arg2, arg3, arg4, arg5) 116 #define APP_PRINT_TRACE7(fmt, arg0, arg1, arg2, arg3, arg4, arg5, arg6) \ 117 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_TRACE, fmt, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6) 118 #define APP_PRINT_TRACE8(fmt, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ 119 DBG_BUFFER_APP(TYPE_BTLIB, SUBTYPE_FORMAT, TRACE_MODULE_APP, LOG_LEVEL_TRACE, fmt, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) 120 /**@}*/ 121 122 /** 123 * trace_app.h 124 * 125 * \brief Initialize module trace task. 126 * 127 * \param[in] NULL. 128 * 129 * \return True ok, false fail. 130 * 131 * \ingroup 132 */ 133 bool bt_trace_init(void); 134 135 /** 136 * trace_app.h 137 * 138 * \brief DeInitialize module trace task. 139 * 140 * \param[in] NULL. 141 * 142 * \return True ok, false fail. 143 * 144 * \ingroup 145 */ 146 bool bt_trace_deinit(void); 147 148 #ifdef __cplusplus 149 } 150 #endif 151 152 #endif /* _TRACE_H_ */ 153