mbed library for NZ32-SC151

Committer:
modtronix-com
Date:
Fri Aug 19 15:46:42 2016 +1000
Revision:
17:639ed60ce759
Parent:
1:71204b8406f2
Added tag v1.1 for changeset 076cbe3e55be

Who changed what in which revision?

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