Add missing undefined symbols to be sure to use mine

Dependents:   DS130x_I2CApp MCP41xxxApp FM24Vxx_I2CApp MCP320xApp ... more

Committer:
Yann
Date:
Mon Nov 22 11:36:57 2010 +0000
Revision:
2:12cc94a627cf
Parent:
1:fbb7a9674868
Child:
3:be0c7a9bd686
V0.0.3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Yann 0:311a0646b95a 1 /* mbed Debug library used by all my developed program
Yann 0:311a0646b95a 2 * Copyright (c) 2010 ygarcia
Yann 0:311a0646b95a 3 *
Yann 0:311a0646b95a 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
Yann 0:311a0646b95a 5 * of this software and associated documentation files (the "Software"), to deal
Yann 0:311a0646b95a 6 * in the Software without restriction, including without limitation the rights
Yann 0:311a0646b95a 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Yann 0:311a0646b95a 8 * copies of the Software, and to permit persons to whom the Software is
Yann 0:311a0646b95a 9 * furnished to do so, subject to the following conditions:
Yann 0:311a0646b95a 10 *
Yann 0:311a0646b95a 11 * The above copyright notice and this permission notice shall be included in
Yann 0:311a0646b95a 12 * all copies or substantial portions of the Software.
Yann 0:311a0646b95a 13 *
Yann 0:311a0646b95a 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Yann 0:311a0646b95a 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Yann 0:311a0646b95a 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Yann 0:311a0646b95a 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Yann 0:311a0646b95a 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Yann 0:311a0646b95a 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Yann 0:311a0646b95a 20 * THE SOFTWARE.
Yann 0:311a0646b95a 21 */
Yann 0:311a0646b95a 22 #if !defined(__DEBUG_H__)
Yann 0:311a0646b95a 23 #define __DEBUG_H__
Yann 0:311a0646b95a 24
Yann 0:311a0646b95a 25 #include "mbed.h"
Yann 0:311a0646b95a 26
Yann 0:311a0646b95a 27 /** The steps below describe how to use this library:
Yann 0:311a0646b95a 28 * 1. Import this library to your project 'As file', because you will need to modify this file as described in step 2
Yann 0:311a0646b95a 29 * 2. Edit this library
Yann 0:311a0646b95a 30 * 3. Remove comment from line 57 (search for '//#define __DEBUG' in this file) to get the DEBUG macro defimed properly. By default, __DEBUG flahg is undef
Yann 0:311a0646b95a 31 * 4. Rebuild this library and use the debug macro as decribe in sample code
Yann 0:311a0646b95a 32 *
Yann 0:311a0646b95a 33 * IMPORTANT: If you modify this libray, please keep this comment up to date for future users
Yann 0:311a0646b95a 34 *
Yann 0:311a0646b95a 35 * Please refer to handbook (http://mbed.org/handbook/Debugging) for mbed Debugging support
Yann 0:311a0646b95a 36 *
Yann 0:311a0646b95a 37 * @code
Yann 0:311a0646b95a 38 * #include "Debug.h" // This header alway includes mbed.h file
Yann 0:311a0646b95a 39 *
Yann 0:311a0646b95a 40 * DigitalOut myled(LED1);
Yann 0:311a0646b95a 41 *
Yann 0:311a0646b95a 42 * int main() {
Yann 0:311a0646b95a 43 * DEBUG_ENTER("main") // Log the entry of the C function 'main'
Yann 0:311a0646b95a 44 * int counter = 0;
Yann 0:311a0646b95a 45 * while(1) {
Yann 0:311a0646b95a 46 * DEBUG("In loop [%d]", counter++) // A sample message
Yann 0:311a0646b95a 47 * myled = 1;
Yann 0:311a0646b95a 48 * wait(0.2);
Yann 0:311a0646b95a 49 * myled = 0;
Yann 0:311a0646b95a 50 * wait(0.2);
Yann 0:311a0646b95a 51 * DEBUG_BREAK() // Wait for any key pressed to continue
Yann 0:311a0646b95a 52 * } // End of 'while' statement
Yann 0:311a0646b95a 53 * DEBUG_LEAVE("main, never reached") // Log the end of the C function 'main'
Yann 0:311a0646b95a 54 * }
Yann 0:311a0646b95a 55 * @endcode
Yann 0:311a0646b95a 56 */
Yann 2:12cc94a627cf 57 //#undef __DEBUG //<!To deactivate debug message
Yann 2:12cc94a627cf 58 #define __DEBUG //<!To activate debug message
Yann 0:311a0646b95a 59
Yann 0:311a0646b95a 60 // Undefined DEBUG symbols to be sure to use mines
Yann 0:311a0646b95a 61 #undef DEBUG_ENTER
Yann 0:311a0646b95a 62 #undef DEBUG_LEAVE
Yann 0:311a0646b95a 63 #undef DEBUG
Yann 0:311a0646b95a 64
Yann 0:311a0646b95a 65 #ifdef __DEBUG
Yann 0:311a0646b95a 66
Yann 2:12cc94a627cf 67 /** This class implements debug functionalities based on USB console interface. V0.0.0.3
Yann 0:311a0646b95a 68 *
Yann 0:311a0646b95a 69 * Note that this class is based on Helper pattern
Yann 0:311a0646b95a 70 */
Yann 0:311a0646b95a 71 class DebugHelper
Yann 0:311a0646b95a 72 {
Yann 0:311a0646b95a 73 public:
Yann 0:311a0646b95a 74 /** Log method
Yann 0:311a0646b95a 75 */
Yann 0:311a0646b95a 76 static void Debug(const char* format, ...);
Yann 0:311a0646b95a 77 /** Break point method based on getchar() C function
Yann 0:311a0646b95a 78 */
Yann 0:311a0646b95a 79 static void BreakPoint(const char* file, int line);
Yann 0:311a0646b95a 80 }; // End of class DebugHelper
Yann 0:311a0646b95a 81
Yann 0:311a0646b95a 82 /** Used to log function/method entry (>>)
Yann 0:311a0646b95a 83 *
Yann 0:311a0646b95a 84 * Note that \ for multiline macro is not supported yet
Yann 0:311a0646b95a 85 */
Yann 0:311a0646b95a 86 #define DEBUG_ENTER(...) do { DebugHelper::Debug(">> "); DebugHelper::Debug(__VA_ARGS__); DebugHelper::Debug("\r\n"); } while(false);
Yann 0:311a0646b95a 87 /** Used to log function end of function/method (<<)
Yann 0:311a0646b95a 88 *
Yann 0:311a0646b95a 89 * Note that \ for multiline macro is not supported yet
Yann 0:311a0646b95a 90 */
Yann 0:311a0646b95a 91 #define DEBUG_LEAVE(...) do { DebugHelper::Debug("<< "); DebugHelper::Debug(__VA_ARGS__); DebugHelper::Debug("\r\n"); } while(false);
Yann 0:311a0646b95a 92 /** Used to log a standard message
Yann 0:311a0646b95a 93 *
Yann 0:311a0646b95a 94 * Note that \ for multiline macro is not supported yet
Yann 0:311a0646b95a 95 */
Yann 0:311a0646b95a 96 #define DEBUG(...) do { DebugHelper::Debug(__VA_ARGS__); DebugHelper::Debug("\r\n"); } while(false);
Yann 1:fbb7a9674868 97 /** Used to log an error message (?? )
Yann 0:311a0646b95a 98 *
Yann 0:311a0646b95a 99 * Note that \ for multiline macro is not supported yet
Yann 0:311a0646b95a 100 */
Yann 2:12cc94a627cf 101 #define DEBUG_ERROR(...) do { DebugHelper::Debug("?? "); DebugHelper::Debug(__VA_ARGS__); DebugHelper::Debug("\r\n"); } while(false);
Yann 1:fbb7a9674868 102 /** Used to log a warning message (!! )
Yann 0:311a0646b95a 103 *
Yann 0:311a0646b95a 104 * Note that \ for multiline macro is not supported yet
Yann 0:311a0646b95a 105 */
Yann 0:311a0646b95a 106 #define DEBUG_WARNING(...) do { DebugHelper::Debug("!! "); DebugHelper::Debug(__VA_ARGS__); DebugHelper::Debug("\r\n"); } while(false);
Yann 0:311a0646b95a 107
Yann 0:311a0646b95a 108 /** Break point macro
Yann 0:311a0646b95a 109 */
Yann 0:311a0646b95a 110 #define DEBUG_BREAK() DebugHelper::BreakPoint(__FILE__, __LINE__);
Yann 0:311a0646b95a 111
Yann 0:311a0646b95a 112 /** Used to stop program on fatal error
Yann 0:311a0646b95a 113 */
Yann 0:311a0646b95a 114 #define DEBUG_FATAL(cause) error(cause);
Yann 0:311a0646b95a 115
Yann 0:311a0646b95a 116 #else // __DEBUG
Yann 0:311a0646b95a 117
Yann 0:311a0646b95a 118 /** Undefine DEBUG macro, used when __DEBUG is undefined
Yann 0:311a0646b95a 119 */
Yann 0:311a0646b95a 120 #define DEBUG_ENTER(...)
Yann 0:311a0646b95a 121 /** Undefine DEBUG macro, used when __DEBUG is undefined
Yann 0:311a0646b95a 122 */
Yann 0:311a0646b95a 123 #define DEBUG_LEAVE(...)
Yann 0:311a0646b95a 124 /** Undefine DEBUG macro, used when __DEBUG is undefined
Yann 0:311a0646b95a 125 */
Yann 0:311a0646b95a 126 #define DEBUG(...)
Yann 2:12cc94a627cf 127 /** Undefine DEBUG_ERROR macro, used when __DEBUG is undefined
Yann 0:311a0646b95a 128 */
Yann 2:12cc94a627cf 129 #define DEBUG_ERROR(...)
Yann 0:311a0646b95a 130 /** Undefine DEBUG_WARNING macro, used when __DEBUG is undefined
Yann 0:311a0646b95a 131 */
Yann 0:311a0646b95a 132 #define DEBUG_WARNING(...)
Yann 0:311a0646b95a 133
Yann 0:311a0646b95a 134 /** Undefine DEBUG_BREAK macro, used when __DEBUG is undefined
Yann 0:311a0646b95a 135 */
Yann 0:311a0646b95a 136 #define DEBUG_BREAK()
Yann 0:311a0646b95a 137
Yann 0:311a0646b95a 138 /** Undefine DEBUG_FATAL macro, used when __DEBUG is undefined
Yann 0:311a0646b95a 139 */
Yann 0:311a0646b95a 140 #define DEBUG_FATAL(cause)
Yann 0:311a0646b95a 141
Yann 0:311a0646b95a 142 #endif // __DEBUG
Yann 0:311a0646b95a 143
Yann 0:311a0646b95a 144 #endif // __DEBUG_H__