summaryrefslogtreecommitdiff
path: root/tinyusb/common
diff options
context:
space:
mode:
authorhathach <[email protected]>2012-11-27 15:59:47 +0700
committerhathach <[email protected]>2012-11-27 15:59:47 +0700
commit54e5289b730b387d7e494cce270aca47356e064f (patch)
tree094f41f1158f56f23ea6bdbbcafdf391ec4bef44 /tinyusb/common
parenta21ca6c0f10b8ed057e10ad7c31ded8eea763d5c (diff)
added assert macro
Diffstat (limited to 'tinyusb/common')
-rw-r--r--tinyusb/common/common.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/tinyusb/common/common.h b/tinyusb/common/common.h
index 03d6387d7..9fc483b5b 100644
--- a/tinyusb/common/common.h
+++ b/tinyusb/common/common.h
@@ -42,10 +42,39 @@
extern "C" {
#endif
+#include <stddef.h>
#include "arch/arch.h"
#include "compiler/compiler.h"
#include "errors.h"
+//#if ( defined CFG_PRINTF_UART || defined CFG_PRINTF_USBCDC || defined CFG_PRINTF_DEBUG )
+#if 1
+ #define PRINTF_LOCATION(mess) printf("Assert: %s at line %d: %s\n", __func__, __LINE__, mess)
+#else
+ #define PRINTF_LOCATION(mess)
+#endif
+
+#define ASSERT_MESSAGE(condition, value, message) \
+ do{\
+ if (!(condition)) {\
+ PRINTF_LOCATION(message);\
+ return (value);\
+ }\
+ }while(0)
+
+#define ASSERT(condition, value) ASSERT_MESSAGE(condition, value, NULL)
+
+#define ASSERT_STATUS_MESSAGE(sts, message) \
+ do{\
+ ErrorCode_t status = (sts);\
+ if (LPC_OK != status) {\
+ PRINTF_LOCATION(message);\
+ return status;\
+ }\
+ }while(0)
+
+#define ASSERT_STATUS(sts) ASSERT_STATUS_MESSAGE(sts, NULL)
+
#ifdef __cplusplus
}
#endif