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