Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mbed_debug.h Source File

mbed_debug.h

00001 
00002 /** \addtogroup platform */
00003 /** @{*/
00004 /* mbed Microcontroller Library
00005  * Copyright (c) 2006-2013 ARM Limited
00006  *
00007  * Licensed under the Apache License, Version 2.0 (the "License");
00008  * you may not use this file except in compliance with the License.
00009  * You may obtain a copy of the License at
00010  *
00011  *     http://www.apache.org/licenses/LICENSE-2.0
00012  *
00013  * Unless required by applicable law or agreed to in writing, software
00014  * distributed under the License is distributed on an "AS IS" BASIS,
00015  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016  * See the License for the specific language governing permissions and
00017  * limitations under the License.
00018  */
00019 #ifndef MBED_DEBUG_H
00020 #define MBED_DEBUG_H
00021 #if DEVICE_STDIO_MESSAGES
00022 #include <stdio.h>
00023 #include <stdarg.h>
00024 #endif
00025 
00026 #ifdef __cplusplus
00027 extern "C" {
00028 #endif
00029 
00030 
00031 /** Output a debug message
00032  *
00033  * @param format printf-style format string, followed by variables
00034  */
00035 static inline void debug(const char *format, ...) {
00036 #if DEVICE_STDIO_MESSAGES && !defined(NDEBUG)
00037     va_list args;
00038     va_start(args, format);
00039     vfprintf(stderr, format, args);
00040     va_end(args);
00041 #endif
00042 }
00043 
00044 
00045 /** Conditionally output a debug message
00046  *
00047  * NOTE: If the condition is constant false (== 0) and the compiler optimization
00048  * level is greater than 0, then the whole function will be compiled away.
00049  *
00050  * @param condition output only if condition is true (!= 0)
00051  * @param format printf-style format string, followed by variables
00052  */
00053 static inline void debug_if(int condition, const char *format, ...) {
00054 #if DEVICE_STDIO_MESSAGES && !defined(NDEBUG)
00055     if (condition) {
00056         va_list args;
00057         va_start(args, format);
00058         vfprintf(stderr, format, args);
00059         va_end(args);
00060     }
00061 #endif
00062 }
00063 
00064 
00065 #ifdef __cplusplus
00066 }
00067 #endif
00068 
00069 #endif
00070 
00071 /** @}*/