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