summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNathan Conrad <[email protected]>2019-09-16 09:24:27 -0400
committerNathan Conrad <[email protected]>2019-09-16 09:24:27 -0400
commit889c17a442fead48826bf4241f05539cef44bf57 (patch)
tree16c13dcacf75264ce577a72228fb6268cfd250a3 /src/common
parent9593463367cca64acc7732013efdc634e84c2a81 (diff)
parent0c70948d0d97d89b37ec35bba4c7ee0365232e1a (diff)
Merge branch 'master' into TI_compiler_quirks
Diffstat (limited to 'src/common')
-rw-r--r--src/common/tusb_common.h2
-rw-r--r--src/common/tusb_types.h3
-rw-r--r--src/common/tusb_verify.h30
3 files changed, 30 insertions, 5 deletions
diff --git a/src/common/tusb_common.h b/src/common/tusb_common.h
index 4f0105d13..57c6e2fcf 100644
--- a/src/common/tusb_common.h
+++ b/src/common/tusb_common.h
@@ -38,7 +38,7 @@
//--------------------------------------------------------------------+
// Macros Helper
//--------------------------------------------------------------------+
-#define TU_ARRAY_SZIE(_arr) ( sizeof(_arr) / sizeof(_arr[0]) )
+#define TU_ARRAY_SIZE(_arr) ( sizeof(_arr) / sizeof(_arr[0]) )
#define TU_MIN(_x, _y) ( (_x) < (_y) ) ? (_x) : (_y) )
#define TU_MAX(_x, _y) ( (_x) > (_y) ) ? (_x) : (_y) )
diff --git a/src/common/tusb_types.h b/src/common/tusb_types.h
index a50e89934..ad42baad7 100644
--- a/src/common/tusb_types.h
+++ b/src/common/tusb_types.h
@@ -125,7 +125,8 @@ typedef enum
{
TUSB_REQ_TYPE_STANDARD = 0,
TUSB_REQ_TYPE_CLASS,
- TUSB_REQ_TYPE_VENDOR
+ TUSB_REQ_TYPE_VENDOR,
+ TUSB_REQ_TYPE_INVALID
} tusb_request_type_t;
typedef enum
diff --git a/src/common/tusb_verify.h b/src/common/tusb_verify.h
index 2727ce043..fae0c88ae 100644
--- a/src/common/tusb_verify.h
+++ b/src/common/tusb_verify.h
@@ -36,10 +36,34 @@
* as C++ for the sake of code simplicity. Beware of a headache macro
* manipulation that you are told to stay away.
*
- * e.g
*
- * - TU_VERIFY( cond ) will return false if cond is false
- * - TU_VERIFY( cond, err) will return err instead if cond is false
+ * This contains macros for both VERIFY and ASSERT:
+ *
+ * VERIFY: Used when there is an error condition which is not the
+ * fault of the MCU. For example, bounds checking on data
+ * sent to the micro over USB should use this function.
+ * Another example is checking for buffer overflows, where
+ * returning from the active function causes a NAK.
+ *
+ * ASSERT: Used for error conditions that are caused by MCU firmware
+ * bugs. This is used to discover bugs in the code more
+ * quickly. One example would be adding assertions in library
+ * function calls to confirm a function's (untainted)
+ * parameters are valid.
+ *
+ *
+ * The difference in behaviour is that ASSERT triggers a breakpoint while
+ * verify does not.
+ *
+ * #define TU_VERIFY(cond) if(cond) return false;
+ * #define TU_VERIFY(cond,ret) if(cond) return ret;
+ *
+ * #define TU_VERIFY_HDLR(cond,handler) if(cond) {handler; return false;}
+ * #define TU_VERIFY_HDLR(cond,ret,handler) if(cond) {handler; return ret;}
+ *
+ * #define TU_ASSERT(cond) if(cond) {_MESS_FAILED(); TU_BREAKPOINT(), return false;}
+ * #define TU_ASSERT(cond,ret) if(cond) {_MESS_FAILED(); TU_BREAKPOINT(), return ret;}
+ *
*------------------------------------------------------------------*/
#ifdef __cplusplus