This fork captures the mbed lib v125 for ease of integration into older projects.

Fork of mbed-dev by mbed official

Committer:
apluscw
Date:
Fri Jul 20 21:24:42 2018 +0000
Revision:
187:92cbb9eec47b
Mbed library with source code from mbed lib v125. Posted to ease integration with some older projects.

Who changed what in which revision?

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