SX126X_PingPong_Template

Dependencies:   SX126xLib mbed

Committer:
SemBen
Date:
Tue Oct 09 14:07:38 2018 +0000
Revision:
0:ea5a948dfc97
First commit, not tested

Who changed what in which revision?

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