aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2010-09-05 19:11:01 -0400
committerbnewbold <bnewbold@robocracy.org>2010-09-05 22:59:16 -0400
commit340cdc7966fbda1a28ce011cbaaeb6878b0b6064 (patch)
treee14de3f9d6db73fa7d015214b675ca31c250895f
parentb6e3624a705b36b15e7f4c0637d133c7dab059bd (diff)
downloadlibrambutan-340cdc7966fbda1a28ce011cbaaeb6878b0b6064.tar.gz
librambutan-340cdc7966fbda1a28ce011cbaaeb6878b0b6064.zip
debug verbosity levels
-rw-r--r--libmaple/exc.c12
-rw-r--r--libmaple/libmaple.h6
-rw-r--r--libmaple/util.h23
3 files changed, 31 insertions, 10 deletions
diff --git a/libmaple/exc.c b/libmaple/exc.c
index dd02476..a5c67fa 100644
--- a/libmaple/exc.c
+++ b/libmaple/exc.c
@@ -24,7 +24,7 @@
* ****************************************************************************/
/**
- * @brief libmaple exception handlers. If MAPLE_DEBUG is set, then these
+ * @brief libmaple exception handlers. If DEBUG_LEVEL > DEBUG_FAULT, then these
* exceptions will ASSERT fail and call into the default _fail() light
* blinking.
*/
@@ -32,31 +32,31 @@
#include "util.h"
void NMIException(void) {
- ASSERT(0);
+ ASSERT_FAULT(0);
while(1)
;
}
void HardFaultException(void) {
- ASSERT(0);
+ ASSERT_FAULT(0);
while(1)
;
}
void MemManageException(void) {
- ASSERT(0);
+ ASSERT_FAULT(0);
while(1)
;
}
void BusFaultException(void) {
- ASSERT(0);
+ ASSERT_FAULT(0);
while(1)
;
}
void UsageFaultException(void) {
- ASSERT(0);
+ ASSERT_FAULT(0);
while(1)
;
}
diff --git a/libmaple/libmaple.h b/libmaple/libmaple.h
index db05c96..c5763c8 100644
--- a/libmaple/libmaple.h
+++ b/libmaple/libmaple.h
@@ -34,7 +34,11 @@
#include "libmaple_types.h"
// General configuration
-#define MAPLE_DEBUG 1
+#ifndef DEBUG_LEVEL
+ //#define DEBUG_LEVEL DEBUG_ALL
+ #define DEBUG_LEVEL DEBUG_FAULT
+ //#define DEBUG_LEVEL DEBUG_NONE
+#endif
// MCU-specific configuration
#ifdef MCU_STM32F103RB
diff --git a/libmaple/util.h b/libmaple/util.h
index 053731a..63e305d 100644
--- a/libmaple/util.h
+++ b/libmaple/util.h
@@ -32,6 +32,8 @@
#ifndef _UTIL_H_
#define _UTIL_H_
+#include "libmaple.h"
+
#define BIT(shift) (1 << (shift))
#define BIT_MASK_SHIFT(mask, shift) ((mask) << (shift))
@@ -70,9 +72,14 @@ void _fail(const char*, int, const char*);
#endif
-/* Assert for sanity checks, undefine MAPLE_DEBUG to compile
- * out these checks */
-#if MAPLE_DEBUG
+// Asserts for sanity checks, redefine DEBUG_LEVEL in libmaple.h to compile out
+// these checks
+
+#define DEBUG_NONE 0
+#define DEBUG_FAULT 1
+#define DEBUG_ALL 2
+
+#if DEBUG_LEVEL >= DEBUG_ALL
#define ASSERT(exp) \
if (exp) \
{} \
@@ -82,5 +89,15 @@ void _fail(const char*, int, const char*);
#define ASSERT(exp) (void)((0))
#endif
+#if DEBUG_LEVEL >= DEBUG_FAULT
+#define ASSERT_FAULT(exp) \
+ if (exp) \
+ {} \
+ else \
+ _fail(__FILE__, __LINE__, #exp)
+#else
+#define ASSERT_FAULT(exp) (void)((0))
+#endif
+
#endif