Espotel / SX1272lib

Dependents:   Elmo-Terminal LoRaWAN-test-app Elmo-Terminal-App LoRaWAN_Semtech_stack ... more

Committer:
WGorniak
Date:
Thu Oct 01 11:05:08 2015 +0200
Revision:
4:25a986defbf1
renamed debug.h to dbg.h

Who changed what in which revision?

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