mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
AnnaBridge
Date:
Wed Feb 20 22:31:08 2019 +0000
Revision:
189:f392fc9709a3
Parent:
187:0387e8f68319
mbed library release version 165

Who changed what in which revision?

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