Nicolas Borla
/
BBR_1Ebene
BBR 1 Ebene
mbed-os/platform/mbed_debug.h@0:fbdae7e6d805, 2018-05-14 (annotated)
- Committer:
- borlanic
- Date:
- Mon May 14 11:29:06 2018 +0000
- Revision:
- 0:fbdae7e6d805
BBR
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
borlanic | 0:fbdae7e6d805 | 1 | |
borlanic | 0:fbdae7e6d805 | 2 | /** \addtogroup platform */ |
borlanic | 0:fbdae7e6d805 | 3 | /** @{*/ |
borlanic | 0:fbdae7e6d805 | 4 | /** |
borlanic | 0:fbdae7e6d805 | 5 | * \defgroup platform_debug Debug functions |
borlanic | 0:fbdae7e6d805 | 6 | * @{ |
borlanic | 0:fbdae7e6d805 | 7 | */ |
borlanic | 0:fbdae7e6d805 | 8 | |
borlanic | 0:fbdae7e6d805 | 9 | /* mbed Microcontroller Library |
borlanic | 0:fbdae7e6d805 | 10 | * Copyright (c) 2006-2013 ARM Limited |
borlanic | 0:fbdae7e6d805 | 11 | * |
borlanic | 0:fbdae7e6d805 | 12 | * Licensed under the Apache License, Version 2.0 (the "License"); |
borlanic | 0:fbdae7e6d805 | 13 | * you may not use this file except in compliance with the License. |
borlanic | 0:fbdae7e6d805 | 14 | * You may obtain a copy of the License at |
borlanic | 0:fbdae7e6d805 | 15 | * |
borlanic | 0:fbdae7e6d805 | 16 | * http://www.apache.org/licenses/LICENSE-2.0 |
borlanic | 0:fbdae7e6d805 | 17 | * |
borlanic | 0:fbdae7e6d805 | 18 | * Unless required by applicable law or agreed to in writing, software |
borlanic | 0:fbdae7e6d805 | 19 | * distributed under the License is distributed on an "AS IS" BASIS, |
borlanic | 0:fbdae7e6d805 | 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
borlanic | 0:fbdae7e6d805 | 21 | * See the License for the specific language governing permissions and |
borlanic | 0:fbdae7e6d805 | 22 | * limitations under the License. |
borlanic | 0:fbdae7e6d805 | 23 | */ |
borlanic | 0:fbdae7e6d805 | 24 | #ifndef MBED_DEBUG_H |
borlanic | 0:fbdae7e6d805 | 25 | #define MBED_DEBUG_H |
borlanic | 0:fbdae7e6d805 | 26 | #if DEVICE_STDIO_MESSAGES |
borlanic | 0:fbdae7e6d805 | 27 | #include <stdio.h> |
borlanic | 0:fbdae7e6d805 | 28 | #include <stdarg.h> |
borlanic | 0:fbdae7e6d805 | 29 | #endif |
borlanic | 0:fbdae7e6d805 | 30 | |
borlanic | 0:fbdae7e6d805 | 31 | #ifdef __cplusplus |
borlanic | 0:fbdae7e6d805 | 32 | extern "C" { |
borlanic | 0:fbdae7e6d805 | 33 | #endif |
borlanic | 0:fbdae7e6d805 | 34 | |
borlanic | 0:fbdae7e6d805 | 35 | |
borlanic | 0:fbdae7e6d805 | 36 | /** Output a debug message |
borlanic | 0:fbdae7e6d805 | 37 | * |
borlanic | 0:fbdae7e6d805 | 38 | * @param format printf-style format string, followed by variables |
borlanic | 0:fbdae7e6d805 | 39 | */ |
borlanic | 0:fbdae7e6d805 | 40 | static inline void debug(const char *format, ...) { |
borlanic | 0:fbdae7e6d805 | 41 | #if DEVICE_STDIO_MESSAGES && !defined(NDEBUG) |
borlanic | 0:fbdae7e6d805 | 42 | va_list args; |
borlanic | 0:fbdae7e6d805 | 43 | va_start(args, format); |
borlanic | 0:fbdae7e6d805 | 44 | vfprintf(stderr, format, args); |
borlanic | 0:fbdae7e6d805 | 45 | va_end(args); |
borlanic | 0:fbdae7e6d805 | 46 | #endif |
borlanic | 0:fbdae7e6d805 | 47 | } |
borlanic | 0:fbdae7e6d805 | 48 | |
borlanic | 0:fbdae7e6d805 | 49 | |
borlanic | 0:fbdae7e6d805 | 50 | /** Conditionally output a debug message |
borlanic | 0:fbdae7e6d805 | 51 | * |
borlanic | 0:fbdae7e6d805 | 52 | * NOTE: If the condition is constant false (== 0) and the compiler optimization |
borlanic | 0:fbdae7e6d805 | 53 | * level is greater than 0, then the whole function will be compiled away. |
borlanic | 0:fbdae7e6d805 | 54 | * |
borlanic | 0:fbdae7e6d805 | 55 | * @param condition output only if condition is true (!= 0) |
borlanic | 0:fbdae7e6d805 | 56 | * @param format printf-style format string, followed by variables |
borlanic | 0:fbdae7e6d805 | 57 | */ |
borlanic | 0:fbdae7e6d805 | 58 | static inline void debug_if(int condition, const char *format, ...) { |
borlanic | 0:fbdae7e6d805 | 59 | #if DEVICE_STDIO_MESSAGES && !defined(NDEBUG) |
borlanic | 0:fbdae7e6d805 | 60 | if (condition) { |
borlanic | 0:fbdae7e6d805 | 61 | va_list args; |
borlanic | 0:fbdae7e6d805 | 62 | va_start(args, format); |
borlanic | 0:fbdae7e6d805 | 63 | vfprintf(stderr, format, args); |
borlanic | 0:fbdae7e6d805 | 64 | va_end(args); |
borlanic | 0:fbdae7e6d805 | 65 | } |
borlanic | 0:fbdae7e6d805 | 66 | #endif |
borlanic | 0:fbdae7e6d805 | 67 | } |
borlanic | 0:fbdae7e6d805 | 68 | |
borlanic | 0:fbdae7e6d805 | 69 | |
borlanic | 0:fbdae7e6d805 | 70 | #ifdef __cplusplus |
borlanic | 0:fbdae7e6d805 | 71 | } |
borlanic | 0:fbdae7e6d805 | 72 | #endif |
borlanic | 0:fbdae7e6d805 | 73 | |
borlanic | 0:fbdae7e6d805 | 74 | #endif |
borlanic | 0:fbdae7e6d805 | 75 | |
borlanic | 0:fbdae7e6d805 | 76 | /**@}*/ |
borlanic | 0:fbdae7e6d805 | 77 | |
borlanic | 0:fbdae7e6d805 | 78 | /**@}*/ |
borlanic | 0:fbdae7e6d805 | 79 |