hh
Dependents: VL53L0X-mbedOS-master VL53L0X-mbedOS-masterbb
vl53l0x_platform_log.h@2:a1dffa1ff38a, 2019-04-23 (annotated)
- Committer:
- mohamedachour
- Date:
- Tue Apr 23 14:27:07 2019 +0000
- Revision:
- 2:a1dffa1ff38a
- Parent:
- 0:e6fcdb78a136
xc
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mjarvisal | 0:e6fcdb78a136 | 1 | /******************************************************************************* |
mjarvisal | 0:e6fcdb78a136 | 2 | Copyright © 2015, STMicroelectronics International N.V. |
mjarvisal | 0:e6fcdb78a136 | 3 | All rights reserved. |
mjarvisal | 0:e6fcdb78a136 | 4 | |
mjarvisal | 0:e6fcdb78a136 | 5 | Redistribution and use in source and binary forms, with or without |
mjarvisal | 0:e6fcdb78a136 | 6 | modification, are permitted provided that the following conditions are met: |
mjarvisal | 0:e6fcdb78a136 | 7 | * Redistributions of source code must retain the above copyright |
mjarvisal | 0:e6fcdb78a136 | 8 | notice, this list of conditions and the following disclaimer. |
mjarvisal | 0:e6fcdb78a136 | 9 | * Redistributions in binary form must reproduce the above copyright |
mjarvisal | 0:e6fcdb78a136 | 10 | notice, this list of conditions and the following disclaimer in the |
mjarvisal | 0:e6fcdb78a136 | 11 | documentation and/or other materials provided with the distribution. |
mjarvisal | 0:e6fcdb78a136 | 12 | * Neither the name of STMicroelectronics nor the |
mjarvisal | 0:e6fcdb78a136 | 13 | names of its contributors may be used to endorse or promote products |
mjarvisal | 0:e6fcdb78a136 | 14 | derived from this software without specific prior written permission. |
mjarvisal | 0:e6fcdb78a136 | 15 | |
mjarvisal | 0:e6fcdb78a136 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
mjarvisal | 0:e6fcdb78a136 | 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
mjarvisal | 0:e6fcdb78a136 | 18 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND |
mjarvisal | 0:e6fcdb78a136 | 19 | NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED. |
mjarvisal | 0:e6fcdb78a136 | 20 | IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY |
mjarvisal | 0:e6fcdb78a136 | 21 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
mjarvisal | 0:e6fcdb78a136 | 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
mjarvisal | 0:e6fcdb78a136 | 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
mjarvisal | 0:e6fcdb78a136 | 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
mjarvisal | 0:e6fcdb78a136 | 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
mjarvisal | 0:e6fcdb78a136 | 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mjarvisal | 0:e6fcdb78a136 | 27 | ********************************************************************************/ |
mjarvisal | 0:e6fcdb78a136 | 28 | |
mjarvisal | 0:e6fcdb78a136 | 29 | |
mjarvisal | 0:e6fcdb78a136 | 30 | #ifndef _VL53L0X_PLATFORM_LOG_H_ |
mjarvisal | 0:e6fcdb78a136 | 31 | #define _VL53L0X_PLATFORM_LOG_H_ |
mjarvisal | 0:e6fcdb78a136 | 32 | |
mjarvisal | 0:e6fcdb78a136 | 33 | #include <stdio.h> |
mjarvisal | 0:e6fcdb78a136 | 34 | #include <string.h> |
mjarvisal | 0:e6fcdb78a136 | 35 | /* LOG Functions */ |
mjarvisal | 0:e6fcdb78a136 | 36 | |
mjarvisal | 0:e6fcdb78a136 | 37 | #ifdef __cplusplus |
mjarvisal | 0:e6fcdb78a136 | 38 | extern "C" { |
mjarvisal | 0:e6fcdb78a136 | 39 | #endif |
mjarvisal | 0:e6fcdb78a136 | 40 | |
mjarvisal | 0:e6fcdb78a136 | 41 | /** |
mjarvisal | 0:e6fcdb78a136 | 42 | * @file vl53l0_platform_log.h |
mjarvisal | 0:e6fcdb78a136 | 43 | * |
mjarvisal | 0:e6fcdb78a136 | 44 | * @brief platform log function definition |
mjarvisal | 0:e6fcdb78a136 | 45 | */ |
mjarvisal | 0:e6fcdb78a136 | 46 | |
mjarvisal | 0:e6fcdb78a136 | 47 | //#define VL53L0X_LOG_ENABLE 0 |
mjarvisal | 0:e6fcdb78a136 | 48 | |
mjarvisal | 0:e6fcdb78a136 | 49 | enum { |
mjarvisal | 0:e6fcdb78a136 | 50 | TRACE_LEVEL_NONE, |
mjarvisal | 0:e6fcdb78a136 | 51 | TRACE_LEVEL_ERRORS, |
mjarvisal | 0:e6fcdb78a136 | 52 | TRACE_LEVEL_WARNING, |
mjarvisal | 0:e6fcdb78a136 | 53 | TRACE_LEVEL_INFO, |
mjarvisal | 0:e6fcdb78a136 | 54 | TRACE_LEVEL_DEBUG, |
mjarvisal | 0:e6fcdb78a136 | 55 | TRACE_LEVEL_ALL, |
mjarvisal | 0:e6fcdb78a136 | 56 | TRACE_LEVEL_IGNORE |
mjarvisal | 0:e6fcdb78a136 | 57 | }; |
mjarvisal | 0:e6fcdb78a136 | 58 | |
mjarvisal | 0:e6fcdb78a136 | 59 | enum { |
mjarvisal | 0:e6fcdb78a136 | 60 | TRACE_FUNCTION_NONE = 0, |
mjarvisal | 0:e6fcdb78a136 | 61 | TRACE_FUNCTION_I2C = 1, |
mjarvisal | 0:e6fcdb78a136 | 62 | TRACE_FUNCTION_ALL = 0x7fffffff //all bits except sign |
mjarvisal | 0:e6fcdb78a136 | 63 | }; |
mjarvisal | 0:e6fcdb78a136 | 64 | |
mjarvisal | 0:e6fcdb78a136 | 65 | enum { |
mjarvisal | 0:e6fcdb78a136 | 66 | TRACE_MODULE_NONE = 0x0, |
mjarvisal | 0:e6fcdb78a136 | 67 | TRACE_MODULE_API = 0x1, |
mjarvisal | 0:e6fcdb78a136 | 68 | TRACE_MODULE_PLATFORM = 0x2, |
mjarvisal | 0:e6fcdb78a136 | 69 | TRACE_MODULE_ALL = 0x7fffffff //all bits except sign |
mjarvisal | 0:e6fcdb78a136 | 70 | }; |
mjarvisal | 0:e6fcdb78a136 | 71 | |
mjarvisal | 0:e6fcdb78a136 | 72 | |
mjarvisal | 0:e6fcdb78a136 | 73 | #ifdef VL53L0X_LOG_ENABLE |
mjarvisal | 0:e6fcdb78a136 | 74 | |
mjarvisal | 0:e6fcdb78a136 | 75 | #include <sys/time.h> |
mjarvisal | 0:e6fcdb78a136 | 76 | |
mjarvisal | 0:e6fcdb78a136 | 77 | extern uint32_t _trace_level; |
mjarvisal | 0:e6fcdb78a136 | 78 | |
mjarvisal | 0:e6fcdb78a136 | 79 | |
mjarvisal | 0:e6fcdb78a136 | 80 | |
mjarvisal | 0:e6fcdb78a136 | 81 | int32_t VL53L0X_trace_config(char *filename, uint32_t modules, uint32_t level, uint32_t functions); |
mjarvisal | 0:e6fcdb78a136 | 82 | |
mjarvisal | 0:e6fcdb78a136 | 83 | void trace_print_module_function(uint32_t module, uint32_t level, uint32_t function, const char *format, ...); |
mjarvisal | 0:e6fcdb78a136 | 84 | |
mjarvisal | 0:e6fcdb78a136 | 85 | |
mjarvisal | 0:e6fcdb78a136 | 86 | //extern FILE * log_file; |
mjarvisal | 0:e6fcdb78a136 | 87 | |
mjarvisal | 0:e6fcdb78a136 | 88 | #define LOG_GET_TIME() (int)clock() |
mjarvisal | 0:e6fcdb78a136 | 89 | |
mjarvisal | 0:e6fcdb78a136 | 90 | #define _LOG_FUNCTION_START(module, fmt, ... ) \ |
mjarvisal | 0:e6fcdb78a136 | 91 | trace_print_module_function(module, _trace_level, TRACE_FUNCTION_ALL, "%ld <START> %s "fmt"\n", LOG_GET_TIME(), __FUNCTION__, ##__VA_ARGS__); |
mjarvisal | 0:e6fcdb78a136 | 92 | |
mjarvisal | 0:e6fcdb78a136 | 93 | #define _LOG_FUNCTION_END(module, status, ... )\ |
mjarvisal | 0:e6fcdb78a136 | 94 | trace_print_module_function(module, _trace_level, TRACE_FUNCTION_ALL, "%ld <END> %s %d\n", LOG_GET_TIME(), __FUNCTION__, (int)status, ##__VA_ARGS__) |
mjarvisal | 0:e6fcdb78a136 | 95 | |
mjarvisal | 0:e6fcdb78a136 | 96 | #define _LOG_FUNCTION_END_FMT(module, status, fmt, ... )\ |
mjarvisal | 0:e6fcdb78a136 | 97 | trace_print_module_function(module, _trace_level, TRACE_FUNCTION_ALL, "%ld <END> %s %d "fmt"\n", LOG_GET_TIME(), __FUNCTION__, (int)status,##__VA_ARGS__) |
mjarvisal | 0:e6fcdb78a136 | 98 | |
mjarvisal | 0:e6fcdb78a136 | 99 | // __func__ is gcc only |
mjarvisal | 0:e6fcdb78a136 | 100 | //#define VL53L0X_ErrLog( fmt, ...) fprintf(stderr, "VL53L0X_ErrLog %s" fmt "\n", __func__, ##__VA_ARGS__) |
mjarvisal | 0:e6fcdb78a136 | 101 | |
mjarvisal | 0:e6fcdb78a136 | 102 | #else /* VL53L0X_LOG_ENABLE no logging */ |
mjarvisal | 0:e6fcdb78a136 | 103 | #define VL53L0X_ErrLog(...) (void)0 |
mjarvisal | 0:e6fcdb78a136 | 104 | #define _LOG_FUNCTION_START(module, fmt, ... ) (void)0 |
mjarvisal | 0:e6fcdb78a136 | 105 | #define _LOG_FUNCTION_END(module, status, ... ) (void)0 |
mjarvisal | 0:e6fcdb78a136 | 106 | #define _LOG_FUNCTION_END_FMT(module, status, fmt, ... ) (void)0 |
mjarvisal | 0:e6fcdb78a136 | 107 | #endif /* else */ |
mjarvisal | 0:e6fcdb78a136 | 108 | |
mjarvisal | 0:e6fcdb78a136 | 109 | #define VL53L0X_COPYSTRING(str, ...) strcpy(str, ##__VA_ARGS__) |
mjarvisal | 0:e6fcdb78a136 | 110 | |
mjarvisal | 0:e6fcdb78a136 | 111 | #ifdef __cplusplus |
mjarvisal | 0:e6fcdb78a136 | 112 | } |
mjarvisal | 0:e6fcdb78a136 | 113 | #endif |
mjarvisal | 0:e6fcdb78a136 | 114 | |
mjarvisal | 0:e6fcdb78a136 | 115 | #endif /* _VL53L0X_PLATFORM_LOG_H_ */ |
mjarvisal | 0:e6fcdb78a136 | 116 | |
mjarvisal | 0:e6fcdb78a136 | 117 | |
mjarvisal | 0:e6fcdb78a136 | 118 |