diff options
| author | hathach <[email protected]> | 2013-02-06 12:03:01 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-02-06 12:03:01 +0700 |
| commit | e20025b54d16deccbd6e86433f31d80f5a976fd4 (patch) | |
| tree | b94fc6905de315cc5ce3778d297cc711cc195f0f /tinyusb/common | |
| parent | aeccdfde3f4462fae5e3b9cbb4eae76526bdb204 (diff) | |
refractor move test enum to its own file
add assert with handler
add task assert with error catcher
Diffstat (limited to 'tinyusb/common')
| -rw-r--r-- | tinyusb/common/assertion.h | 14 | ||||
| -rw-r--r-- | tinyusb/common/common.h | 3 | ||||
| -rw-r--r-- | tinyusb/common/errors.h | 1 |
3 files changed, 11 insertions, 7 deletions
diff --git a/tinyusb/common/assertion.h b/tinyusb/common/assertion.h index f6aff004e..e8ce24c0a 100644 --- a/tinyusb/common/assertion.h +++ b/tinyusb/common/assertion.h @@ -69,25 +69,25 @@ extern "C" // Assert Helper //--------------------------------------------------------------------+ #define ASSERT_MESSAGE(format, ...)\ - _PRINTF("Assert at %s: %s:%d: " format "\n", __FILE__, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__) + _PRINTF("Assert at %s %s %d: " format "\n", __BASE_FILE__, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__) #ifndef _TEST_ASSERT_ - #define ASSERT_ERROR_HANDLER(x) return (x) + #define ASSERT_ERROR_HANDLER(x, para) return (x) #else - #define ASSERT_ERROR_HANDLER(x) Throw(x) + #define ASSERT_ERROR_HANDLER(x, para) Throw(x) #endif -#define ASSERT_DEFINE(...) ASSERT_DEFINE_WITH_HANDLER(ASSERT_ERROR_HANDLER, __VA_ARGS__) - -#define ASSERT_DEFINE_WITH_HANDLER(error_handler, setup_statement, condition, error, format, ...) \ +#define ASSERT_DEFINE_WITH_HANDLER(error_handler, handler_para, setup_statement, condition, error, format, ...) \ do{\ setup_statement;\ if (!(condition)) {\ ASSERT_MESSAGE(format, __VA_ARGS__);\ - error_handler(error);\ + error_handler(error, handler_para);\ }\ }while(0) +#define ASSERT_DEFINE(...) ASSERT_DEFINE_WITH_HANDLER(ASSERT_ERROR_HANDLER, NULL, __VA_ARGS__) + //--------------------------------------------------------------------+ // tusb_error_t Status Assert TODO use ASSERT_DEFINE //--------------------------------------------------------------------+ diff --git a/tinyusb/common/common.h b/tinyusb/common/common.h index 403ca5d6c..a3c8cfef5 100644 --- a/tinyusb/common/common.h +++ b/tinyusb/common/common.h @@ -98,6 +98,9 @@ #define U32_TO_U8S_BE(u32) U32_B1_U8(u32), U32_B2_U8(u32), U32_B3_U8(u32), U32_B4_U8(u32) #define U32_TO_U8S_LE(u32) U32_B4_U8(u32), U32_B3_U8(u32), U32_B2_U8(u32), U32_B1_U8(u32) + +#define memclr_(buffer, size) memset(buffer, 0, size) + /// form an uint32_t from 4 x uint8_t static inline uint32_t u32_from_u8(uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4) ATTR_ALWAYS_INLINE ATTR_CONST; static inline uint32_t u32_from_u8(uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4) diff --git a/tinyusb/common/errors.h b/tinyusb/common/errors.h index 2d8a80e22..42a7a3975 100644 --- a/tinyusb/common/errors.h +++ b/tinyusb/common/errors.h @@ -66,6 +66,7 @@ ENTRY(TUSB_ERROR_CLASS_DEVICE_DONT_SUPPORT)\ ENTRY(TUSB_ERROR_CLASS_DATA_NOT_AVAILABLE)\ ENTRY(TUSB_ERROR_HCD_FAILED)\ + ENTRY(TUSB_ERROR_USBH_MOUNT_FAILED)\ ENTRY(TUSB_ERROR_OSAL_TIMEOUT)\ ENTRY(TUSB_ERROR_OSAL_TASK_FAILED)\ ENTRY(TUSB_ERROR_OSAL_QUEUE_FAILED)\ |
