Jim Cooper
/
simple_debug
Simple sample of using a debug class and macros.
Revision 0:885c11431d59, committed 2015-08-30
- Comitter:
- jimcooper
- Date:
- Sun Aug 30 00:05:14 2015 +0000
- Commit message:
- Simple example of using a debug object and macros.
Changed in this revision
diff -r 000000000000 -r 885c11431d59 debug.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debug.cpp Sun Aug 30 00:05:14 2015 +0000 @@ -0,0 +1,20 @@ +#include "mbed.h" +#include "debug.h" + + +Serial g_console(USBTX, USBRX); + + +#ifdef DEBUG + +debug g_debugger; + + + +void debug::error(const char* text) +{ + g_console.printf("!!!!!!!!!!!!!!!!! %s\n", text); +} + + +#endif
diff -r 000000000000 -r 885c11431d59 debug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debug.h Sun Aug 30 00:05:14 2015 +0000 @@ -0,0 +1,33 @@ +#ifndef __DEBUG_H__ +#define __DEBUG_H__ + + +#ifndef DEBUG + #define DEBUG // Comment this out for release mode builds. +#endif + + +// Simple error reporting. +#ifdef DEBUG + #define DEBUG_ERROR(x) g_debugger.error(x); +#else + #define DEBUG_ERROR(x) // x; +#endif + + + +// debug error reporting object +class debug +{ + public: + + void error(const char* text); +}; + + +// Created in the debug.cpp file. +extern debug g_debugger; + + + +#endif // __DEBUG_H__
diff -r 000000000000 -r 885c11431d59 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Aug 30 00:05:14 2015 +0000 @@ -0,0 +1,12 @@ +#include "mbed.h" +#include "debug.h" + + + +int main() +{ + Serial g_console(USBTX, USBRX); + + g_console.printf("I Rule!!\n\n"); +} +
diff -r 000000000000 -r 885c11431d59 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Aug 30 00:05:14 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/8ed44a420e5c \ No newline at end of file