tinyusb  0.4
Click here to lend your support to tinyusb donation and make a donation at pledgie.com
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Assertion

Macros

#define VOID_RETURN
 
#define _ASSERT_COUNTER   __LINE__
 
#define STATIC_ASSERT(const_expr, message)   enum { XSTRING_CONCAT_(static_assert_, _ASSERT_COUNTER) = 1/(!!(const_expr)) }
 
#define _PRINTF(...)
 
#define ASSERT_MESSAGE(format,...)   _PRINTF("Assert at %s: %s: %d: " format "\n", __BASE_FILE__, __func__ , __LINE__, __VA_ARGS__)
 
#define ASSERT_ERROR_HANDLER(x, para)   return x
 
#define ASSERT_DEFINE_WITH_HANDLER(error_handler, handler_para, setup_statement, condition, error, format,...)
 
#define ASSERT_DEFINE(...)   ASSERT_DEFINE_WITH_HANDLER(ASSERT_ERROR_HANDLER, NULL, __VA_ARGS__)
 
#define ASSERT_STATUS_MESSAGE(sts, message)
 
#define ASSERT_STATUS(sts)
 
#define ASSERT(...)   ASSERT_TRUE(__VA_ARGS__)
 
#define ASSERT_TRUE(condition, error)   ASSERT_DEFINE( , (condition), error, "%s", "evaluated to false")
 
#define ASSERT_FALSE(condition, error)   ASSERT_DEFINE( ,!(condition), error, "%s", "evaluated to true")
 
#define ASSERT_PTR(...)   ASSERT_PTR_NOT_NULL(__VA_ARGS__)
 
#define ASSERT_PTR_NOT_NULL(pointer, error)   ASSERT_DEFINE( , NULL != (pointer), error, "%s", "pointer is NULL")
 
#define ASSERT_PTR_NULL(pointer, error)   ASSERT_DEFINE( , NULL == (pointer), error, "%s", "pointer is not NULL")
 
#define ASSERT_XXX_EQUAL(type_format, expected, actual, error)
 
#define ASSERT_XXX_WITHIN(type_format, lower, upper, actual, error)
 
#define ASSERT_INT(...)   ASSERT_INT_EQUAL(__VA_ARGS__)
 
#define ASSERT_INT_EQUAL(...)   ASSERT_XXX_EQUAL("%d", __VA_ARGS__)
 
#define ASSERT_INT_WITHIN(...)   ASSERT_XXX_WITHIN("%d", __VA_ARGS__)
 
#define ASSERT_HEX(...)   ASSERT_HEX_EQUAL(__VA_ARGS__)
 
#define ASSERT_HEX_EQUAL(...)   ASSERT_XXX_EQUAL("0x%x", __VA_ARGS__)
 
#define ASSERT_HEX_WITHIN(...)   ASSERT_XXX_WITHIN("0x%x", __VA_ARGS__)
 
#define BIN8_PRINTF_PATTERN   "%d%d%d%d%d%d%d%d"
 
#define BIN8_PRINTF_CONVERT(byte)
 
#define ASSERT_BIN8(...)   ASSERT_BIN8_EQUAL(__VA_ARGS__)
 
#define ASSERT_BIN8_EQUAL(expected, actual, error)
 

Detailed Description

Macro Definition Documentation

#define ASSERT_BIN8_EQUAL (   expected,
  actual,
  error 
)
Value:
ASSERT_DEFINE(\
uint8_t exp = (expected); uint8_t act = (actual),\
exp==act,\
error,\
"expected " BIN8_PRINTF_PATTERN ", actual " BIN8_PRINTF_PATTERN, BIN8_PRINTF_CONVERT(exp), BIN8_PRINTF_CONVERT(act) )

Definition at line 177 of file assertion.h.

#define ASSERT_DEFINE_WITH_HANDLER (   error_handler,
  handler_para,
  setup_statement,
  condition,
  error,
  format,
  ... 
)
Value:
do{\
setup_statement;\
if (!(condition)) {\
hal_debugger_breakpoint();\
ASSERT_MESSAGE(format, __VA_ARGS__);\
error_handler(error, handler_para);\
}\
}while(0)

Definition at line 94 of file assertion.h.

#define ASSERT_STATUS (   sts)
Value:
ASSERT_DEFINE(tusb_error_t status = (tusb_error_t)(sts),\
TUSB_ERROR_NONE == status, status, "%s", TUSB_ErrorStr[status])
tusb_error_t
Error Code returned.
Definition: tusb_errors.h:97

Definition at line 113 of file assertion.h.

#define ASSERT_STATUS_MESSAGE (   sts,
  message 
)
Value:
ASSERT_DEFINE(tusb_error_t status = (tusb_error_t)(sts),\
TUSB_ERROR_NONE == status, status, "%s: %s", TUSB_ErrorStr[status], message)
tusb_error_t
Error Code returned.
Definition: tusb_errors.h:97

Definition at line 109 of file assertion.h.

#define ASSERT_XXX_EQUAL (   type_format,
  expected,
  actual,
  error 
)
Value:
ASSERT_DEFINE(\
uint32_t exp = (expected); uint32_t act = (actual),\
exp==act,\
error,\
"expected " type_format ", actual " type_format, exp, act)

Definition at line 134 of file assertion.h.

#define ASSERT_XXX_WITHIN (   type_format,
  lower,
  upper,
  actual,
  error 
)
Value:
ASSERT_DEFINE(\
uint32_t low = (lower); uint32_t up = (upper); uint32_t act = (actual),\
(low <= act) && (act <= up),\
error,\
"expected within " type_format " - " type_format ", actual " type_format, low, up, act)

Definition at line 141 of file assertion.h.

#define BIN8_PRINTF_CONVERT (   byte)
Value:
((byte) & 0x80 ? 1 : 0), \
((byte) & 0x40 ? 1 : 0), \
((byte) & 0x20 ? 1 : 0), \
((byte) & 0x10 ? 1 : 0), \
((byte) & 0x08 ? 1 : 0), \
((byte) & 0x04 ? 1 : 0), \
((byte) & 0x02 ? 1 : 0), \
((byte) & 0x01 ? 1 : 0)

Definition at line 166 of file assertion.h.