20171208

Fork of SX1276Lib by Semtech

Committer:
cdebank
Date:
Fri Dec 08 14:22:00 2017 +0000
Revision:
27:5a56a5d281bf
Parent:
10:4a0720f9b7a3
20171208

Who changed what in which revision?

UserRevisionLine numberNew contents of line
GregCr 10:4a0720f9b7a3 1 /* Copyright (c) 2012 mbed.org, MIT License
GregCr 10:4a0720f9b7a3 2 *
GregCr 10:4a0720f9b7a3 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
GregCr 10:4a0720f9b7a3 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
GregCr 10:4a0720f9b7a3 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
GregCr 10:4a0720f9b7a3 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
GregCr 10:4a0720f9b7a3 7 * furnished to do so, subject to the following conditions:
GregCr 10:4a0720f9b7a3 8 *
GregCr 10:4a0720f9b7a3 9 * The above copyright notice and this permission notice shall be included in all copies or
GregCr 10:4a0720f9b7a3 10 * substantial portions of the Software.
GregCr 10:4a0720f9b7a3 11 *
GregCr 10:4a0720f9b7a3 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
GregCr 10:4a0720f9b7a3 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
GregCr 10:4a0720f9b7a3 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
GregCr 10:4a0720f9b7a3 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
GregCr 10:4a0720f9b7a3 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
GregCr 10:4a0720f9b7a3 17 */
GregCr 10:4a0720f9b7a3 18
GregCr 10:4a0720f9b7a3 19 #ifndef DEBUG_H
GregCr 10:4a0720f9b7a3 20 #define DEBUG_H
GregCr 10:4a0720f9b7a3 21
GregCr 10:4a0720f9b7a3 22 /** @file debug.h */
GregCr 10:4a0720f9b7a3 23
GregCr 10:4a0720f9b7a3 24 #ifndef NDEBUG
GregCr 10:4a0720f9b7a3 25
GregCr 10:4a0720f9b7a3 26 #include <stdarg.h>
GregCr 10:4a0720f9b7a3 27 #include <stdio.h>
GregCr 10:4a0720f9b7a3 28
GregCr 10:4a0720f9b7a3 29 /** Output a debug message
GregCr 10:4a0720f9b7a3 30 *
GregCr 10:4a0720f9b7a3 31 * @param format printf-style format string, followed by variables
GregCr 10:4a0720f9b7a3 32 */
GregCr 10:4a0720f9b7a3 33 static inline void debug(const char *format, ...) {
GregCr 10:4a0720f9b7a3 34 va_list args;
GregCr 10:4a0720f9b7a3 35 va_start(args, format);
GregCr 10:4a0720f9b7a3 36 vfprintf(stderr, format, args);
GregCr 10:4a0720f9b7a3 37 va_end(args);
GregCr 10:4a0720f9b7a3 38 }
GregCr 10:4a0720f9b7a3 39
GregCr 10:4a0720f9b7a3 40 /** Conditionally output a debug message
GregCr 10:4a0720f9b7a3 41 *
GregCr 10:4a0720f9b7a3 42 * @param condition output only if condition is true
GregCr 10:4a0720f9b7a3 43 * @param format printf-style format string, followed by variables
GregCr 10:4a0720f9b7a3 44 */
GregCr 10:4a0720f9b7a3 45 static inline void debug_if(bool condition, const char *format, ...) {
GregCr 10:4a0720f9b7a3 46 if(condition) {
GregCr 10:4a0720f9b7a3 47 va_list args;
GregCr 10:4a0720f9b7a3 48 va_start(args, format);
GregCr 10:4a0720f9b7a3 49 vfprintf(stderr, format, args);
GregCr 10:4a0720f9b7a3 50 va_end(args);
GregCr 10:4a0720f9b7a3 51 }
GregCr 10:4a0720f9b7a3 52 }
GregCr 10:4a0720f9b7a3 53
GregCr 10:4a0720f9b7a3 54 #else
GregCr 10:4a0720f9b7a3 55
GregCr 10:4a0720f9b7a3 56 static inline void debug(const char *format, ...) {}
GregCr 10:4a0720f9b7a3 57 static inline void debug(bool condition, const char *format, ...) {}
GregCr 10:4a0720f9b7a3 58
GregCr 10:4a0720f9b7a3 59 #endif
GregCr 10:4a0720f9b7a3 60
GregCr 10:4a0720f9b7a3 61 #endif