498 #ifndef ti_log_Log__include 499 #define ti_log_Log__include 507 #if defined (__cplusplus) 519 #if defined(DOXYGEN) || ti_log_Log_ENABLE 529 #define Log_TI_LOG_VERSION 0.2.0 565 #define Log_MODULE_DEFINE(name, init) const Log_Module LogMod_ ## name = init 594 #if defined(DOXYGEN) || defined(__IAR_SYSTEMS_ICC__) 595 #define Log_MODULE_DEFINE_WEAK(name, init) const __weak Log_Module LogMod_ ## name = init 596 #elif defined(__TI_COMPILER_VERSION__) || (defined(__clang__) && defined(__ti_version__)) || defined(__GNUC__) 597 #define Log_MODULE_DEFINE_WEAK(name, init) const Log_Module LogMod_ ## name __attribute__((weak)) = init 599 #error "Incompatible compiler: Logging is currently supported by the following \ 600 compilers: TI ARM Compiler, TI CLANG Compiler, GCC, IAR. Please migrate to a \ 614 #define Log_MODULE_USE(name) extern const Log_Module LogMod_ ## name 622 #define LOG_MODULE_SYM(name) LogMod_ ## name 631 #define _Log_GUARD_MACRO(x) do{ x }while(0) 647 #define _Log_CAR_ARG(N, ...) N 648 #define _Log_CDR_ARG(N, ...) __VA_ARGS__ 655 #define _Log_CONCAT2_A(x,y) x ## _ ## y 656 #define _Log_CONCAT2(x,y) _Log_CONCAT2_A(x,y) 657 #define _Log_CONCAT3(x,y,z) _Log_CONCAT2(x,_Log_CONCAT2(y,z)) 660 #define _Log__TOKEN2STRING_A(x) #x 661 #define _Log_TOKEN2STRING(x) _Log__TOKEN2STRING_A(x) 664 #define _Log_APPEND_META_TO_FORMAT(opcode, \ 671 _Log_TOKEN2STRING(opcode) "\x1e" \ 672 _Log_TOKEN2STRING(file) "\x1e" \ 673 _Log_TOKEN2STRING(line) "\x1e" \ 674 _Log_TOKEN2STRING(level) "\x1e" \ 675 _Log_TOKEN2STRING(module) "\x1e" \ 676 _Log_TOKEN2STRING(format) "\x1e" \ 677 _Log_TOKEN2STRING(nargs) 682 #if defined(__IAR_SYSTEMS_ICC__) 683 #define _Log_PLACE_FORMAT_IN_SECTOR(name, opcode, level, module, format, nargs)\ 684 __root static const char name[] @ ".log_data" = \ 685 _Log_APPEND_META_TO_FORMAT(opcode, \ 692 __root static const char * const _Log_CONCAT2(Ptr, name) @ _Log_TOKEN2STRING(_Log_CONCAT2(.log_ptr, module)) = name; 693 #elif defined(__TI_COMPILER_VERSION__) || (defined(__clang__) && defined(__ti_version__)) || defined(__GNUC__) 694 #define _Log_PLACE_FORMAT_IN_SECTOR(name, opcode, level, module, format, nargs)\ 695 static const char name[] \ 696 __attribute__((used,section(".log_data"))) = \ 697 _Log_APPEND_META_TO_FORMAT(opcode, \ 704 static const char * const _Log_CONCAT2(Ptr, name) \ 705 __attribute__((used,section(_Log_TOKEN2STRING(_Log_CONCAT3(.log_ptr, __LINE__, module))))) = name; 707 #error "Incompatible compiler: Logging is currently supported by the following \ 708 compilers: TI ARM Compiler, TI CLANG Compiler, GCC, IAR. Please migrate to a \ 716 #define _Log_NUMARGS(...) _Log_NUMARGS_A(__VA_ARGS__, 8, 7, 6, 5, 4, 3, 2, 1, 0) 717 #define _Log_NUMARGS_A(...) _Log_NUMARGS_B(__VA_ARGS__) 718 #define _Log_NUMARGS_B(_first, _8, _7, _6, _5, _4, _3, _2, _1, N, ...) N 726 #define _Log_VARIANT(x, module, level, ...) \ 727 _Log_CONCAT2(x, _Log_NUMARGS_B(__VA_ARGS__, _arg8, _arg7, _arg6, _arg5, _arg4, _arg3, _arg2, _arg1, _noarg)) ( module, level, __VA_ARGS__ ) 736 #define _Log_SECOND_ARG(x, y, ...) y 741 #define _Log_TOKEN_1 0, 750 #define _Log_DEFINED(x) _Log_DEFINED_A(x) 755 #define _Log_DEFINED_A(y) _Log_DEFINED_B(_Log_TOKEN_##y) 762 #define _Log_DEFINED_B(z) _Log_SECOND_ARG(z 1, 0) 767 #define _Log_buf_C_0(module, level, format, data, size) 772 #define _Log_buf_C_1(module, level, format, data, size) \ 774 Log_MODULE_USE(module); \ 775 _Log_PLACE_FORMAT_IN_SECTOR(_Log_CONCAT2(LogSymbol, __LINE__), \ 781 LogMod_ ## module.buf(&LogMod_ ## module, \ 783 (uint32_t)&_Log_CONCAT3(Ptr, LogSymbol, __LINE__), \ 799 #define _Log_buf_B(module, level, format, data, size) \ 800 _Log_CONCAT2(_Log_buf_C, _Log_DEFINED(ti_log_Log_ENABLE_ ## module))(module, level, format, data, size) 819 #define _Log_printf__arg1(module, level, fmt, a0) \ 820 module.printf1(&module, \ 822 (uint32_t)&_Log_CONCAT3(Ptr, LogSymbol, __LINE__), \ 824 #define _Log_printf__arg2(module, level, fmt, a0, a1) \ 825 module.printf2(&module, \ 827 (uint32_t)&_Log_CONCAT3(Ptr, LogSymbol, __LINE__), \ 830 #define _Log_printf__arg3(module, level, fmt, a0, a1, a2) \ 831 module.printf3(&module, \ 833 (uint32_t)&_Log_CONCAT3(Ptr, LogSymbol, __LINE__), \ 837 #define _Log_printf__arg4(module, level, fmt, a0, a1, a2, a3) \ 838 _Log_printf__arg(module, level, fmt, (uintptr_t)a0, \ 842 #define _Log_printf__arg5(module, level, fmt, a0, a1, a2, a3, a4) \ 843 _Log_printf__arg(module, level, fmt, (uintptr_t)a0, \ 848 #define _Log_printf__arg6(module, level, fmt, a0, a1, a2, a3, a4, a5) \ 849 _Log_printf__arg(module, level, fmt, (uintptr_t)a0, \ 855 #define _Log_printf__arg7(module, level, fmt, a0, a1, a2, a3, a4, a5, a6) \ 856 _Log_printf__arg(module, level, fmt, (uintptr_t)a0, \ 863 #define _Log_printf__arg8(module, level, fmt, a0, a1, a2, a3, a4, a5, a6, a7) \ 864 _Log_printf__arg(module, level, fmt, (uintptr_t)a0, \ 873 #define _Log_printf__arg(module, level, ...) \ 874 module.printf(&module, \ 876 (uint32_t)&_Log_CONCAT3(Ptr, LogSymbol, __LINE__), \ 877 _Log_NUMARGS(__VA_ARGS__), \ 878 _Log_CDR_ARG(__VA_ARGS__)) 880 #define _Log_printf__noarg(module, level, ...) \ 881 module.printf0(&module, \ 883 (uint32_t)&_Log_CONCAT3(Ptr, LogSymbol, __LINE__)) 888 #define _Log_printf_C_0(opcode, module, level, ...) 893 #define _Log_printf_C_1(opcode, module, level, ...) \ 895 Log_MODULE_USE(module); \ 896 _Log_PLACE_FORMAT_IN_SECTOR(_Log_CONCAT2(LogSymbol, __LINE__), \ 900 _Log_CAR_ARG(__VA_ARGS__), \ 901 _Log_NUMARGS(__VA_ARGS__)) \ 902 _Log_VARIANT(_Log_printf, LogMod_ ## module, level, __VA_ARGS__); \ 916 #define _Log_printf_B(opcode, module, level, ...) \ 917 _Log_CONCAT2(_Log_printf_C, _Log_DEFINED(ti_log_Log_ENABLE_ ## module))(opcode, module, level, __VA_ARGS__) 935 #define Log_buf(module, level, format, data, size) _Log_buf_B(module, level, format, data, size) 956 #define Log_printf(module, level, ...) _Log_printf_B(LOG_OPCODE_FORMATED_TEXT, module, level, __VA_ARGS__) 962 #if defined(__IAR_SYSTEMS_ICC__) 963 #define _Log_DEFINE_LOG_VERSION(module, version) \ 964 __root static const char _Log_CONCAT2(Log_ti_log_version, __COUNTER__)[] @ ".log_data" = \ 965 _Log_APPEND_META_TO_FORMAT(LOG_OPCODE_VERSION, \ 972 #elif defined(__TI_COMPILER_VERSION__) || (defined(__clang__) && defined(__ti_version__)) || defined(__GNUC__) 973 #define _Log_DEFINE_LOG_VERSION(module, version) \ 974 static const char _Log_CONCAT2(Log_ti_log_version, __COUNTER__)[] \ 975 __attribute__((used,section(".log_data"))) = \ 976 _Log_APPEND_META_TO_FORMAT(LOG_OPCODE_VERSION, \ 984 #error "Incompatible compiler: Logging is currently supported by the following \ 985 compilers: TI ARM Compiler, TI CLANG Compiler, GCC, IAR. Please migrate to a \ 1004 #define Log_MODULE_SET_LEVELS(module, levels) \ 1006 Log_MODULE_USE(module); \ 1007 if (LogMod_ ## module.dynamicLevelsPtr != NULL) { \ 1008 *LogMod_ ## module.dynamicLevelsPtr = levels; \ 1021 #define Log_MODULE_GET_LEVELS(module) \ 1023 Log_MODULE_USE(module); \ 1024 if (LogMod_ ## module.dynamicLevelsPtr != NULL) { \ 1025 *LogMod_ ## module.dynamicLevelsPtr; \ 1028 LogMod_ ## module.levels; \ 1040 #define Log_MODULE_DEFINE(...) 1041 #define Log_MODULE_DEFINE_WEAK(name, init) 1042 #define Log_MODULE_USE(...) 1043 #define Log_printf(module, level, ...) 1044 #define Log_buf(module, level, ...) 1045 #define _Log_DEFINE_LOG_VERSION(module, version) 1046 #define Log_MODULE_SET_LEVELS(module, levels) 1047 #define Log_MODULE_GET_LEVELS(module) 1319 #define Log_MODULE_INIT_SINK_DUMMY \ 1321 .sinkConfig = NULL, \ 1322 .printf = LogSinkDummy_printf, \ 1323 .printf0 = LogSinkDummy_printfN, \ 1324 .printf1 = LogSinkDummy_printfN, \ 1325 .printf2 = LogSinkDummy_printfN, \ 1326 .printf3 = LogSinkDummy_printfN, \ 1327 .buf = LogSinkDummy_buf, \ 1329 .dynamicLevelsPtr = NULL, \ 1333 #if defined (__cplusplus) 1337 #endif // ti_log_Log__include
void(* Log_buf_fxn)(const Log_Module *handle, Log_Level level, uint32_t headerPtr, uint8_t *data, size_t size)
Definition: Log.h:1142
uint32_t *const dynamicLevelsPtr
Definition: Log.h:1172
const Log_printfN_fxn printf2
Definition: Log.h:1164
Log_Level
Log level bitmask values.
Definition: Log.h:1062
uint32_t levels
Definition: Log.h:1171
const Log_printf_fxn printf
Definition: Log.h:1155
void(* Log_printfN_fxn)(const Log_Module *handle, Log_Level level, uint32_t headerPtr,...)
Definition: Log.h:1137
const Log_printfN_fxn printf0
Definition: Log.h:1158
Log_Level level
Definition: Log.h:1200
Log_Level uint32_t headerPtr
Definition: Log.h:1200
Log_Level uint32_t uint32_t numArgs
Definition: Log.h:1200
Log_Level uint32_t uint8_t size_t size
Definition: Log.h:1293
Log module.
Definition: Log.h:1153
void * sinkConfig
Definition: Log.h:1154
Log_Level uint32_t uint8_t * data
Definition: Log.h:1289
const Log_printfN_fxn printf1
Definition: Log.h:1161
const Log_buf_fxn buf
Definition: Log.h:1170
__attribute__((weak)) void LogSinkDummy_printf(const Log_Module *handle
Dummy Log_printf delegate function implementation.
#define Log_TI_LOG_VERSION
Log version.
Definition: Log.h:529
const Log_printfN_fxn printf3
Definition: Log.h:1167
void(* Log_printf_fxn)(const Log_Module *handle, Log_Level level, uint32_t headerPtr, uint32_t numArgs,...)
Definition: Log.h:1131