Original lib
Fork of SX1276Lib by
debug/debug.h@19:452450d0b8c0, 2016-03-06 (annotated)
- Committer:
- donsez
- Date:
- Sun Mar 06 11:08:53 2016 +0000
- Revision:
- 19:452450d0b8c0
- Parent:
- 10:4a0720f9b7a3
refactor PingPong in order to have a AT LoRa modem (sender and receiver)
Who changed what in which revision?
User | Revision | Line number | New 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 | |
donsez | 19:452450d0b8c0 | 29 | extern Serial pc; |
donsez | 19:452450d0b8c0 | 30 | |
donsez | 19:452450d0b8c0 | 31 | |
GregCr | 10:4a0720f9b7a3 | 32 | /** Output a debug message |
GregCr | 10:4a0720f9b7a3 | 33 | * |
GregCr | 10:4a0720f9b7a3 | 34 | * @param format printf-style format string, followed by variables |
GregCr | 10:4a0720f9b7a3 | 35 | */ |
donsez | 19:452450d0b8c0 | 36 | static inline void sx_debug(const char *format, ...) { |
GregCr | 10:4a0720f9b7a3 | 37 | va_list args; |
GregCr | 10:4a0720f9b7a3 | 38 | va_start(args, format); |
donsez | 19:452450d0b8c0 | 39 | pc.printf(format, args); |
GregCr | 10:4a0720f9b7a3 | 40 | va_end(args); |
GregCr | 10:4a0720f9b7a3 | 41 | } |
GregCr | 10:4a0720f9b7a3 | 42 | |
GregCr | 10:4a0720f9b7a3 | 43 | /** Conditionally output a debug message |
GregCr | 10:4a0720f9b7a3 | 44 | * |
GregCr | 10:4a0720f9b7a3 | 45 | * @param condition output only if condition is true |
GregCr | 10:4a0720f9b7a3 | 46 | * @param format printf-style format string, followed by variables |
GregCr | 10:4a0720f9b7a3 | 47 | */ |
donsez | 19:452450d0b8c0 | 48 | static inline void sx_debug_if(bool condition, const char *format, ...) { |
GregCr | 10:4a0720f9b7a3 | 49 | if(condition) { |
GregCr | 10:4a0720f9b7a3 | 50 | va_list args; |
GregCr | 10:4a0720f9b7a3 | 51 | va_start(args, format); |
donsez | 19:452450d0b8c0 | 52 | pc.printf(format, args); |
GregCr | 10:4a0720f9b7a3 | 53 | va_end(args); |
GregCr | 10:4a0720f9b7a3 | 54 | } |
GregCr | 10:4a0720f9b7a3 | 55 | } |
GregCr | 10:4a0720f9b7a3 | 56 | |
GregCr | 10:4a0720f9b7a3 | 57 | #else |
GregCr | 10:4a0720f9b7a3 | 58 | |
donsez | 19:452450d0b8c0 | 59 | static inline void sx_debug(const char *format, ...) {} |
donsez | 19:452450d0b8c0 | 60 | static inline void sx_debug_if(bool condition, const char *format, ...) {} |
GregCr | 10:4a0720f9b7a3 | 61 | |
GregCr | 10:4a0720f9b7a3 | 62 | #endif |
GregCr | 10:4a0720f9b7a3 | 63 | |
GregCr | 10:4a0720f9b7a3 | 64 | #endif |