Library for Modtronix NZ32 STM32 boards, like the NZ32-SC151, NZ32-SB072, NZ32-SE411 and others

Revision:
13:328bfac0e686
Parent:
12:0303f1aef603
Child:
14:f8583913e1c1
--- a/mx_default_debug.h	Thu Sep 17 11:53:01 2015 +1000
+++ b/mx_default_debug.h	Wed Oct 21 14:53:20 2015 +1100
@@ -82,21 +82,40 @@
 #endif
 
 #if !defined(MX_DEBUG_IS_POINTER)
-#define MX_DEBUG_IS_POINTER 0
+#define MX_DEBUG_IS_POINTER 1
+#endif
+
+#if !defined(DEBUG_ENABLE)
+#define DEBUG_ENABLE 0
 #endif
 
+#if !defined(DEBUG_ENABLE_INFO)
+#define DEBUG_ENABLE_INFO 0
+#endif
+
+#if (DEBUG_ENABLE==0) && (DEBUG_ENABLE_INFO==1)
+#error "Can not have DEBUG_ENABLE=0 and DEBUG_ENABLE_INFO=1!"
+#endif
+
+
 ///////////////////////////////////////////////////////////////////////////////
 // Following is for main file - file that has mxDebug() defined in it
 #if defined(DEBUG_ENABLE_MAIN)
+    #if (DEBUG_ENABLE_MAIN==1) && !defined(NDEBUG)
+        #define MX_DEBUG  pMxDebug->printf
+        //#define MX_DEBUG(format, args...) ((void)0) //DISABLE Debugging
+    #else
+        //GCC's CPP has extensions; it allows for macros with a variable number of arguments. We use this extension here to preprocess pmesg away.
+        #define MX_DEBUG(format, args...) ((void)0)
+    #endif
 
-#if (DEBUG_ENABLE_MAIN==1) && !defined(NDEBUG)
-    #define MX_DEBUG  pMxDebug->printf
-    //#define MX_DEBUG(format, args...) ((void)0) //DISABLE Debugging
-#else
-    //GCC's CPP has extensions; it allows for macros with a variable number of arguments. We use this extension here to preprocess pmesg away.
-    #define MX_DEBUG(format, args...) ((void)0)
-#endif
-
+    #if (DEBUG_ENABLE_MAIN==1) && (DEBUG_ENABLE_INFO_MAIN==1) && !defined(NDEBUG)
+        #define MX_DEBUG_INFO  pMxDebug->printf
+        //#define MX_DEBUG(format, args...) ((void)0) //DISABLE Debugging
+    #else
+        //GCC's CPP has extensions; it allows for macros with a variable number of arguments. We use this extension here to preprocess pmesg away.
+        #define MX_DEBUG_INFO(format, args...) ((void)0)
+    #endif
 
 ///////////////////////////////////////////////////////////////////////////////
 // Following is for any file that uses debugging (except main file that has mxDebug() defined in it)
@@ -106,25 +125,33 @@
 //- If (MX_DEBUG_IS_POINTER==1), ensure there is global Stream pointer defined somewhere in code to override "pMxDebug = NULL" below!
 //- If (MX_DEBUG_IS_POINTER==0), define a mxDebug() function somewhere in code to handle debug output
 
-#if (DEBUG_ENABLE==1) && !defined(NDEBUG)
-//Alternative method in stead of using NULL below. This requires to create derived Stream class in each file we want to use debugging
-//    class modtronixDebugStream : public Stream {int _putc(int value) {return 0;}int _getc() {return 0;}};
-//    static modtronixDebugStream modtronixDebug;
-//    WEAK Stream* pMxDebug = &modtronixDebug;
-    #if (MX_DEBUG_IS_POINTER==1)        //More efficient, but only works if pMxDebug is defined in code. Disabled by default!
-        WEAK Stream* pMxDebug = NULL;
-        #define MX_DEBUG  pMxDebug->printf
+    #if (DEBUG_ENABLE==1) && !defined(NDEBUG)
+    //Alternative method in stead of using NULL below. This requires to create derived Stream class in each file we want to use debugging
+    //    class modtronixDebugStream : public Stream {int _putc(int value) {return 0;}int _getc() {return 0;}};
+    //    static modtronixDebugStream modtronixDebug;
+    //    WEAK Stream* pMxDebug = &modtronixDebug;
+        #if (MX_DEBUG_IS_POINTER==1)        //More efficient, but only works if pMxDebug is defined in code. Disabled by default!
+            WEAK Stream* pMxDebug = NULL;
+            #define MX_DEBUG  pMxDebug->printf
+        #else
+            WEAK void mxDebug(const char *format, ...) {}
+            #define MX_DEBUG mxDebug
+        #endif
     #else
-        WEAK void mxDebug(const char *format, ...) {}
-        #define MX_DEBUG mxDebug
+        //GCC's CPP has extensions; it allows for macros with a variable number of arguments. We use this extension here to preprocess pmesg away.
+        #define MX_DEBUG(format, args...) ((void)0)
     #endif
-#else
-    //GCC's CPP has extensions; it allows for macros with a variable number of arguments. We use this extension here to preprocess pmesg away.
-    #define MX_DEBUG(format, args...) ((void)0)
-#endif
+
+    #if (DEBUG_ENABLE==1) && (DEBUG_ENABLE_INFO==1) && !defined(NDEBUG)
+        #if (MX_DEBUG_IS_POINTER==1)        //More efficient, but only works if pMxDebug is defined in code. Disabled by default!
+            #define MX_DEBUG_INFO   pMxDebug->printf
+        #else
+            #define MX_DEBUG_INFO   mxDebug
+        #endif
+    #else
+        //GCC's CPP has extensions; it allows for macros with a variable number of arguments. We use this extension here to preprocess pmesg away.
+        #define MX_DEBUG_INFO(format, args...) ((void)0)
+    #endif
 
 #endif  //#if defined(DEBUG_ENABLE_MAIN)
-
-
-
 #endif /* SRC_MX_DEFAULT_DEBUG_H_ */